1 // 2 // This file is part of the aMule Project. 3 // 4 // Copyright (c) 2010-2011 Werner Mahr (Vollstrecker) <amule@vollstreckernet.de> 5 // 6 // Any parts of this program contributed by third-party developers are copyrighted 7 // by their respective authors. 8 // 9 // This program is free software; you can redistribute it and/or modify 10 // it under the terms of the GNU General Public License as published by 11 // the Free Software Foundation; either version 3 of the License, or 12 // (at your option) any later version. 13 // 14 // This program is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 // 19 // You should have received a copy of the GNU General Public License 20 // along with this program; if not, write to the Free Software 21 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 22 // 23 24 #ifndef PLASMAMULENGINE_H 25 #define PLASMAMULENGINE_H 26 27 #include <kdirwatch.h> 28 29 #include <kio/jobclasses.h> 30 31 #include <plasma/dataengine.h> 32 33 #include <QtDBus/QtDBus> 34 #include <QFile> 35 #include <QStringList> 36 37 class PlasmaMuleEngine : public Plasma::DataEngine 38 { 39 40 Q_OBJECT 41 42 public: 43 PlasmaMuleEngine(QObject* parent, const QVariantList& args); 44 QStringList sources() const; 45 void init (); 46 47 public Q_SLOTS: 48 Q_SCRIPTABLE void engine_add_link (const QString &link, const int &category, const QString &printname); 49 50 protected: 51 bool sourceRequestEvent(const QString& name); 52 bool updateSourceEvent(const QString& name); 53 54 protected Q_SLOTS: 55 void downloadFinished (KIO::Job *,const QByteArray&); 56 void file_changed (const QString &path); 57 void new_file (const QString &path); 58 void timeout (); 59 60 private: 61 void initVals (); 62 void regDbus (); 63 64 bool m_OSActive, m_timer; 65 66 int m_debugChannel; 67 KDirWatch m_dirwatcher; 68 QFile m_OSFile; 69 QStringList m_incoming_dirs, downloadsNames; 70 QString Home; 71 }; 72 73 class EngineAdaptor: public QDBusAbstractAdaptor 74 { 75 Q_OBJECT 76 Q_CLASSINFO("D-Bus Interface", "org.amule.engine") 77 Q_CLASSINFO("D-Bus Introspection", "" 78 " <interface name=\"org.amule.engine\" >\n" 79 " <method name=\"engine_add_link\" >\n" 80 " <arg direction=\"in\" type=\"as\" name=\"link\" />\n" 81 " <arg direction=\"in\" type=\"i\" name=\"category\" />\n" 82 " </method>\n" 83 " </interface>\n" 84 "") 85 86 public: 87 EngineAdaptor(QObject *parent); 88 virtual ~EngineAdaptor(); 89 90 public Q_SLOTS: 91 void engine_add_link(const QString &link, const int &category); 92 }; 93 94 #endif // PLASMAMULENGINE_H 95