--PackageMetadata; and a handful of efficiency improvements as well
This commit is contained in:
parent
acbe5b960e
commit
1210ec313a
@ -40,15 +40,13 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
PlasmoidServiceJob::PlasmoidServiceJob(const QString &plasmoidLocation,
|
PlasmoidServiceJob::PlasmoidServiceJob(const QString &destination,
|
||||||
const QString &destination,
|
|
||||||
const QString &operation,
|
const QString &operation,
|
||||||
QHash<QString,QVariant>& parameters,
|
QHash<QString,QVariant>& parameters,
|
||||||
PlasmoidService *service)
|
PlasmoidService *service)
|
||||||
: Plasma::ServiceJob(destination, operation, parameters,
|
: Plasma::ServiceJob(destination, operation, parameters,
|
||||||
static_cast<Plasma::Service*>(service)),
|
static_cast<Plasma::Service*>(service)),
|
||||||
m_service(service),
|
m_service(service)
|
||||||
m_packagePath(plasmoidLocation)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,12 +63,10 @@ void PlasmoidServiceJob::start()
|
|||||||
setResult(file.readAll());
|
setResult(file.readAll());
|
||||||
} else {
|
} else {
|
||||||
kDebug() << "file doesn't exists, we're sending the plugin name";
|
kDebug() << "file doesn't exists, we're sending the plugin name";
|
||||||
setResult(m_packagePath);
|
setResult(m_service->m_packagePath);
|
||||||
}
|
}
|
||||||
} else if (operationName() == "GetMetaData") {
|
} else if (operationName() == "GetMetaData") {
|
||||||
KTemporaryFile tempFile;
|
QFile file(m_service->m_metadata);
|
||||||
m_service->m_metadata.write(tempFile.fileName());
|
|
||||||
QFile file(tempFile.fileName());
|
|
||||||
setResult(file.readAll());
|
setResult(file.readAll());
|
||||||
} else if (operationName() == "DataEngine") {
|
} else if (operationName() == "DataEngine") {
|
||||||
DataEngine *engine = m_service->dataEngine(parameters()["EngineName"].toString());
|
DataEngine *engine = m_service->dataEngine(parameters()["EngineName"].toString());
|
||||||
@ -97,20 +93,23 @@ PlasmoidService::PlasmoidService(const QString &packageLocation)
|
|||||||
location.append('/');
|
location.append('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
m_metadata.read(location + "metadata.desktop");
|
m_metadata = location + "metadata.desktop";
|
||||||
if (!m_metadata.isValid()) {
|
|
||||||
|
/*FIXME: either do something useful on error or don't waste time with them
|
||||||
|
if (!QFile::exists(m_metadata)) {
|
||||||
kDebug() << "not a valid package";
|
kDebug() << "not a valid package";
|
||||||
}
|
}
|
||||||
if (!m_tempFile.open()) {
|
*/
|
||||||
kDebug() << "could not create tempfile";
|
|
||||||
}
|
m_tempFile.open();
|
||||||
QString packagePath = m_tempFile.fileName();
|
m_packagePath = m_tempFile.fileName();
|
||||||
m_tempFile.close();
|
m_tempFile.close();
|
||||||
|
|
||||||
// put everything into a zip archive
|
// put everything into a zip archive
|
||||||
KZip creation(packagePath);
|
KZip creation(m_packagePath);
|
||||||
creation.setCompression(KZip::NoCompression);
|
creation.setCompression(KZip::NoCompression);
|
||||||
if (!creation.open(QIODevice::WriteOnly)) {
|
if (!creation.open(QIODevice::WriteOnly)) {
|
||||||
|
/*FIXME: either do something useful on error or don't waste time with it */
|
||||||
kDebug() << "could not open archive";
|
kDebug() << "could not open archive";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,8 +117,6 @@ PlasmoidService::PlasmoidService(const QString &packageLocation)
|
|||||||
location.append("contents/");
|
location.append("contents/");
|
||||||
creation.addLocalDirectory(location, "contents");
|
creation.addLocalDirectory(location, "contents");
|
||||||
creation.close();
|
creation.close();
|
||||||
|
|
||||||
m_packagePath = packagePath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmoidService::PlasmoidService(Applet *applet)
|
PlasmoidService::PlasmoidService(Applet *applet)
|
||||||
@ -131,14 +128,9 @@ PlasmoidService::PlasmoidService(Applet *applet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageMetadata PlasmoidService::metadata() const
|
|
||||||
{
|
|
||||||
return m_metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasma::ServiceJob* PlasmoidService::createJob(const QString& operation, QHash<QString,QVariant>& parameters)
|
Plasma::ServiceJob* PlasmoidService::createJob(const QString& operation, QHash<QString,QVariant>& parameters)
|
||||||
{
|
{
|
||||||
return new PlasmoidServiceJob(m_packagePath, destination(), operation, parameters, this);
|
return new PlasmoidServiceJob(destination(), operation, parameters, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,17 +41,15 @@ class PlasmoidServiceJob : public ServiceJob
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlasmoidServiceJob(const QString &plasmoidLocation,
|
PlasmoidServiceJob(const QString &destination,
|
||||||
const QString &destination,
|
|
||||||
const QString &operation,
|
const QString &operation,
|
||||||
QHash<QString,QVariant>& parameters,
|
QHash<QString,QVariant>& parameters,
|
||||||
PlasmoidService *parent = 0);
|
PlasmoidService *parent);
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlasmoidService *m_service;
|
PlasmoidService *m_service;
|
||||||
QString m_packagePath;
|
|
||||||
QString m_pluginName;
|
QString m_pluginName;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -62,16 +60,13 @@ class PlasmoidService : public Service, DataEngineConsumer
|
|||||||
public:
|
public:
|
||||||
PlasmoidService(const QString &plasmoidLocation);
|
PlasmoidService(const QString &plasmoidLocation);
|
||||||
PlasmoidService(Applet *applet);
|
PlasmoidService(Applet *applet);
|
||||||
PackageMetadata metadata() const;
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Plasma::ServiceJob* createJob(const QString& operation,
|
Plasma::ServiceJob* createJob(const QString& operation, QHash<QString,QVariant>& parameters);
|
||||||
QHash<QString,QVariant>& parameters);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_packagePath;
|
QString m_packagePath;
|
||||||
PackageMetadata m_metadata;
|
QString m_metadata;
|
||||||
KTemporaryFile m_tempFile;
|
KTemporaryFile m_tempFile;
|
||||||
|
|
||||||
friend class PlasmoidServiceJob;
|
friend class PlasmoidServiceJob;
|
||||||
|
Loading…
Reference in New Issue
Block a user