Commit aad3a355 authored by Daniel Nicoletti's avatar Daniel Nicoletti

Make kded module async, fix crash, modernize it's code, fix leak

parent 9187e96a
......@@ -20,4 +20,4 @@
#include "Debug.h"
Q_LOGGING_CATEGORY(PM_KDED, "pm.kded")
Q_LOGGING_CATEGORY(PM_KDED, "print-manager.kded")
......@@ -24,12 +24,13 @@
#include <QtDBus/QDBusContext>
#include <QThread>
class KNotification;
class NewPrinterNotification : public QObject, protected QDBusContext
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "com.redhat.NewPrinterNotification")
public:
NewPrinterNotification();
NewPrinterNotification(QObject *parent);
~NewPrinterNotification();
public slots:
......@@ -37,17 +38,18 @@ public slots:
void NewPrinter(int status, const QString &name, const QString &make, const QString &model, const QString &des, const QString &cmd);
private slots:
void init();
bool registerService();
void configurePrinter();
void searchDrivers();
void printTestPage();
void findDriver();
void installDriver();
void setupPrinter();
private:
QStringList getMissingExecutables(const QString &ppdFileName) const;
void setupPrinterNotification(KNotification *notify, const QString &make, const QString &model, const QString &description, const QString &arg);
void getMissingExecutables(KNotification *notify, int status, const QString &name, const QString &ppdFileName);
void checkPrinterCurrentDriver(KNotification *notify, const QString &name);
void printerReadyNotification(KNotification *notify, const QString &name);
QThread *m_thread;
QString m_destName;
};
......
......@@ -29,19 +29,14 @@ PrintManagerKded::PrintManagerKded(QObject *parent, const QVariantList &args) :
{
Q_UNUSED(args)
QTimer::singleShot(0, this, &PrintManagerKded::loadThread);
QTimer::singleShot(0, this, [this] () {
new NewPrinterNotification(this);
});
}
PrintManagerKded::~PrintManagerKded()
{
if (m_newPrinterNotification) {
m_newPrinterNotification->deleteLater();
}
}
void PrintManagerKded::loadThread()
{
m_newPrinterNotification = new NewPrinterNotification;
}
#include "moc_PrintManagerKded.cpp"
......@@ -26,18 +26,12 @@
#include <QVariantList>
class NewPrinterNotification;
class PrintManagerKded : public KDEDModule
{
Q_OBJECT
public:
PrintManagerKded(QObject *parent, const QVariantList &args);
~PrintManagerKded();
private:
void loadThread();
NewPrinterNotification *m_newPrinterNotification = nullptr;
};
K_PLUGIN_FACTORY(PrintDFactory, registerPlugin<PrintManagerKded>();)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment