Changeset View
Changeset View
Standalone View
Standalone View
plugins/htmlinterface/htmlinterfaceplugin.cpp
Show All 23 Lines | |||||
24 | 24 | | |||
25 | #include <KActionCollection> | 25 | #include <KActionCollection> | ||
26 | #include <KLocalizedString> | 26 | #include <KLocalizedString> | ||
27 | #include <KMainWindow> | 27 | #include <KMainWindow> | ||
28 | #include <KPluginFactory> | 28 | #include <KPluginFactory> | ||
29 | #include <QThread> | 29 | #include <QThread> | ||
30 | 30 | | |||
31 | #include "htmlinterfaceplugin.h" | 31 | #include "htmlinterfaceplugin.h" | ||
32 | // #include <util/fileops.h> | | |||
33 | // #include <interfaces/guiinterface.h> | | |||
34 | #include <interfaces/coreinterface.h> | 32 | #include <interfaces/coreinterface.h> | ||
35 | #include <interfaces/torrentinterface.h> | 33 | #include <interfaces/torrentinterface.h> | ||
36 | // #include <interfaces/torrentfileinterface.h> | | |||
37 | #include <torrent/queuemanager.h> | 34 | #include <torrent/queuemanager.h> | ||
38 | #include "mongoose.h" | | |||
39 | // #include "htmlinterfacemanager.h" | | |||
40 | // #include "htmlinterfacedialog.h" | | |||
41 | #include "webserver.h" | 35 | #include "webserver.h" | ||
42 | 36 | | |||
43 | 37 | | |||
44 | 38 | | |||
45 | K_PLUGIN_FACTORY_WITH_JSON(ktorrent_htmlinterface, "ktorrent_htmlinterface.json", registerPlugin<kt::HtmlInterfacePlugin>();) | 39 | K_PLUGIN_FACTORY_WITH_JSON(ktorrent_htmlinterface, "ktorrent_htmlinterface.json", registerPlugin<kt::HtmlInterfacePlugin>();) | ||
46 | 40 | | |||
47 | using namespace bt; | 41 | using namespace bt; | ||
48 | using namespace std; | 42 | using namespace std; | ||
Show All 20 Lines | 54 | // managers.setAutoDelete(true); | |||
69 | bool HtmlInterfacePlugin::versionCheck(const QString& version) const | 63 | bool HtmlInterfacePlugin::versionCheck(const QString& version) const | ||
70 | { | 64 | { | ||
71 | return version == QStringLiteral(KT_VERSION_MACRO); | 65 | return version == QStringLiteral(KT_VERSION_MACRO); | ||
72 | } | 66 | } | ||
73 | 67 | | |||
74 | void HtmlInterfacePlugin::load() | 68 | void HtmlInterfacePlugin::load() | ||
75 | { | 69 | { | ||
76 | qInfo("I've been loaded"); | 70 | qInfo("I've been loaded"); | ||
77 | HtmlInterfacePlugin::instance = this; | 71 | WebServer * ws = new WebServer(getCore()); | ||
78 | thread = new QThread; | 72 | ws->process(); | ||
79 | worker = new WebServer(getCore()); | 73 | // HtmlInterfacePlugin::instance = this; | ||
80 | worker->moveToThread(thread); | 74 | // thread = new QThread; | ||
81 | // connect(worker, SIGNAL (error(QString)), this, SLOT (errorString(QString))); | 75 | // worker = new WebServer(getCore()); | ||
82 | connect(thread, SIGNAL (started()), worker, SLOT (process())); | 76 | // worker->moveToThread(thread); | ||
83 | connect(worker, SIGNAL (finished()), thread, SLOT (quit())); | 77 | // // connect(worker, SIGNAL (error(QString)), this, SLOT (errorString(QString))); | ||
84 | connect(worker, SIGNAL (finished()), worker, SLOT (deleteLater())); | 78 | // connect(thread, SIGNAL (started()), worker, SLOT (process())); | ||
85 | connect(thread, SIGNAL (finished()), thread, SLOT (deleteLater())); | 79 | // connect(worker, SIGNAL (finished()), thread, SLOT (quit())); | ||
86 | thread->start(); | 80 | // connect(worker, SIGNAL (finished()), worker, SLOT (deleteLater())); | ||
87 | // TorrentActivityInterface* ta = getGUI()->getTorrentActivity(); | 81 | // connect(thread, SIGNAL (finished()), thread, SLOT (deleteLater())); | ||
88 | // ta->addViewListener(this); | 82 | // thread->start(); | ||
89 | // connect(getCore(), SIGNAL(torrentAdded(bt::TorrentInterface*)), this, SLOT(torrentAdded(bt::TorrentInterface*))); | | |||
90 | // connect(getCore(), SIGNAL(torrentRemoved(bt::TorrentInterface*)), this, SLOT(torrentRemoved(bt::TorrentInterface*))); | | |||
91 | // currentTorrentChanged(ta->getCurrentTorrent()); | | |||
92 | // | | |||
93 | // kt::QueueManager* qman = getCore()->getQueueManager(); | | |||
94 | // for (kt::QueueManager::iterator i = qman->begin(); i != qman->end(); i++) | | |||
95 | // torrentAdded(*i); | | |||
96 | } | 83 | } | ||
97 | 84 | | |||
98 | void HtmlInterfacePlugin::unload() | 85 | void HtmlInterfacePlugin::unload() | ||
99 | { | 86 | { | ||
100 | // TorrentActivityInterface* ta = getGUI()->getTorrentActivity(); | 87 | } | ||
101 | // ta->removeViewListener(this); | 88 | | ||
102 | // disconnect(getCore(), SIGNAL(torrentAdded(bt::TorrentInterface*)), this, SLOT(torrentAdded(bt::TorrentInterface*))); | | |||
103 | // disconnect(getCore(), SIGNAL(torrentRemoved(bt::TorrentInterface*)), this, SLOT(torrentRemoved(bt::TorrentInterface*))); | | |||
104 | // managers.clear(); | | |||
105 | } | | |||
106 | | ||||
107 | // void HtmlInterfacePlugin::showHtmlInterfaceDialog() | | |||
108 | // { | | |||
109 | // bt::TorrentInterface* tor = getGUI()->getTorrentActivity()->getCurrentTorrent(); | | |||
110 | // if (!tor || !tor->getStats().multi_file_torrent) | | |||
111 | // return; | | |||
112 | // | | |||
113 | // HtmlInterfaceDialog dlg(this, tor, getGUI()->getMainWindow()); | | |||
114 | // dlg.exec(); | | |||
115 | // } | | |||
116 | // | | |||
117 | void HtmlInterfacePlugin::currentTorrentChanged(bt::TorrentInterface* tc) | 89 | void HtmlInterfacePlugin::currentTorrentChanged(bt::TorrentInterface* tc) | ||
118 | { | 90 | { | ||
119 | // download_order_action->setEnabled(tc && tc->getStats().multi_file_torrent); | | |||
120 | } | 91 | } | ||
121 | // | 92 | | ||
122 | // HtmlInterfaceManager* HtmlInterfacePlugin::manager(bt::TorrentInterface* tc) | | |||
123 | // { | | |||
124 | // return managers.find(tc);Aumyenne | | |||
125 | | ||||
126 | // } | | |||
127 | // | | |||
128 | // HtmlInterfaceManager* HtmlInterfacePlugin::createManager(bt::TorrentInterface* tc) | | |||
129 | // { | | |||
130 | // HtmlInterfaceManager* m = manager(tc); | | |||
131 | // if (m) | | |||
132 | // return m; | | |||
133 | // | | |||
134 | // m = new HtmlInterfaceManager(tc); | | |||
135 | // managers.insert(tc, m); | | |||
136 | // return m; | | |||
137 | // } | | |||
138 | // | | |||
139 | // void HtmlInterfacePlugin::destroyManager(bt::TorrentInterface* tc) | | |||
140 | // { | | |||
141 | // managers.erase(tc); | | |||
142 | // } | | |||
143 | // | | |||
144 | // void HtmlInterfacePlugin::torrentAdded(bt::TorrentInterface* tc) | | |||
145 | // { | | |||
146 | // if (bt::Exists(tc->getTorDir() + QStringLiteral("download_order"))) | | |||
147 | // { | | |||
148 | // HtmlInterfaceManager* m = createManager(tc); | | |||
149 | // m->load(); | | |||
150 | // m->update(); | | |||
151 | // connect(tc, SIGNAL(chunkDownloaded(bt::TorrentInterface*, bt::Uint32)), | | |||
152 | // m, SLOT(chunkDownloaded(bt::TorrentInterface*, bt::Uint32))); | | |||
153 | // } | | |||
154 | // } | | |||
155 | // | | |||
156 | // void HtmlInterfacePlugin::torrentRemoved(bt::TorrentInterface* tc) | | |||
157 | // { | | |||
158 | // managers.erase(tc); | | |||
159 | // } | | |||
160 | } | 93 | } | ||
161 | 94 | | |||
162 | 95 | | |||
163 | 96 | | |||
164 | #include <htmlinterfaceplugin.moc> | 97 | #include <htmlinterfaceplugin.moc> |