summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2010-02-01 18:54:19 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2010-02-01 18:54:19 +0100
commit5d04894e73a52e69968cb4a4bfd9a581cd2fb86c (patch)
tree648c782dd85d3905f1162b4914a87262f92487be
parentclean + strip (diff)
downloadpyload-5d04894e73a52e69968cb4a4bfd9a581cd2fb86c.tar.xz
new update system for remote clients
-rw-r--r--module/download_thread.py4
-rw-r--r--module/file_list.py24
-rw-r--r--module/gui/Collector.py230
-rw-r--r--module/gui/Queue.py132
-rw-r--r--module/gui/connector.py19
-rwxr-xr-xpyLoadCore.py9
-rwxr-xr-xpyLoadGui.py16
7 files changed, 258 insertions, 176 deletions
diff --git a/module/download_thread.py b/module/download_thread.py
index 4a031a04c..65c7e1e23 100644
--- a/module/download_thread.py
+++ b/module/download_thread.py
@@ -23,6 +23,7 @@ from os.path import join
from time import sleep, time
from module.network.Request import AbortDownload
+from module.PullEvents import UpdateEvent
class Status(object):
""" Saves all status information
@@ -116,6 +117,7 @@ class Download_Thread(threading.Thread):
self.loadedPyFile.status.error = str(e)
finally:
self.parent.job_finished(self.loadedPyFile)
+ self.parent.parent.pullManager.addEvent(UpdateEvent("file", self.loadedPyFile.id, "queue"))
else:
sleep(3)
sleep(0.8)
@@ -126,6 +128,7 @@ class Download_Thread(threading.Thread):
def download(self, pyfile):
status = pyfile.status
status.type = "starting"
+ self.parent.parent.pullManager.addEvent(UpdateEvent("file", pyfile.id, "queue"))
pyfile.init_download()
@@ -136,6 +139,7 @@ class Download_Thread(threading.Thread):
status.type = "decrypting"
else:
status.type = "downloading"
+ self.parent.parent.pullManager.addEvent(UpdateEvent("file", pyfile.id, "queue"))
location = join(pyfile.folder, status.filename)
pyfile.plugin.proceed(status.url, location)
diff --git a/module/file_list.py b/module/file_list.py
index 7c68a7427..b9f70bd27 100644
--- a/module/file_list.py
+++ b/module/file_list.py
@@ -33,6 +33,8 @@ from operator import attrgetter
from os import sep
from time import sleep
+from module.PullEvents import UpdateEvent, RemoveEvent, InsertEvent
+
class NoSuchElementException(Exception):
pass
@@ -148,6 +150,10 @@ class File_List(object):
info["size"] = pyfile.status.size()
info["active"] = pyfile.active
info["plugin"] = pyfile.plugin.props['name']
+ try:
+ info["package"] = pypack.data["id"]
+ except:
+ pass
return info
def continueAborted(self):
@@ -194,6 +200,7 @@ class File_List(object):
try:
n, pyfile = collector._getFileFromID(id)
del collector.file_list.data["collector"][n]
+ collector.file_list.core.pullManager.addEvent(RemoveEvent("file", id, "collector"))
except Exception, e:
raise Exception, e
else:
@@ -211,6 +218,7 @@ class File_List(object):
collector.file_list.lock.acquire()
collector.file_list.data["collector"].append(pyfile)
collector.file_list.lock.release()
+ collector.file_list.core.pullManager.addEvent(InsertEvent("file", pyfile.id, -2, "collector"))
return pyfile.id
def removeFile(collector, id):
@@ -218,6 +226,7 @@ class File_List(object):
removes PyLoadFile instance with the given id from collector
"""
collector.popFile(id)
+ collector.file_list.core.pullManager.addEvent(RemoveEvent("file", id, "collector"))
def replaceFile(collector, newpyfile):
"""
@@ -227,6 +236,7 @@ class File_List(object):
try:
n, pyfile = collector._getFileFromID(newpyfile.id)
collector.file_list.data["collector"][n] = newpyfile
+ collector.file_list.core.pullManager.addEvent(UpdateEvent("file", newpyfile.id, "collector"))
finally:
collector.file_list.lock.release()
@@ -277,6 +287,7 @@ class File_List(object):
if package_name is not None:
pypack.data["package_name"] = package_name
packager.file_list.data["packages"].append(pypack)
+ packager.file_list.core.pullManager.addEvent(InsertEvent("pack", pypack.data["id"], -2, "packages"))
return pypack.data["id"]
def removePackage(packager, id):
@@ -287,6 +298,9 @@ class File_List(object):
pyfile.plugin.req.abort = True
sleep(0.1)
del packager.file_list.data[key][n]
+ if key == "packages":
+ key = "collector"
+ packager.file_list.core.pullManager.addEvent(RemoveEvent("pack", id, key))
finally:
packager.file_list.lock.release()
@@ -312,6 +326,8 @@ class File_List(object):
if key == "packages":
del packager.file_list.data["packages"][n]
packager.file_list.data["queue"].append(pypack)
+ packager.file_list.core.pullManager.addEvent(RemoveEvent("pack", id, "packages"))
+ packager.file_list.core.pullManager.addEvent(InsertEvent("pack", id, -2, "queue"))
finally:
packager.file_list.lock.release()
@@ -322,6 +338,8 @@ class File_List(object):
if key == "queue":
del packager.file_list.data["queue"][n]
packager.file_list.data["packages"].append(pypack)
+ packager.file_list.core.pullManager.addEvent(RemoveEvent("pack", id, "queue"))
+ packager.file_list.core.pullManager.addEvent(InsertEvent("pack", id, -2, "packages"))
finally:
packager.file_list.lock.release()
@@ -334,6 +352,7 @@ class File_List(object):
if folder is not None:
pypack.data["folder"] = folder
packager.file_list.data[key][n] = pypack
+ packager.file_list.core.pullManager.addEvent(UpdateEvent("pack", id, key))
finally:
packager.file_list.lock.release()
@@ -352,6 +371,7 @@ class File_List(object):
pyfile.package = pypack
pypack.files.append(pyfile)
packager.file_list.data[key][n] = pypack
+ packager.file_list.core.pullManager.addEvent(InsertEvent("file", pyfile.id, -2, key))
def resetFileStatus(packager, fileid):
packager.file_list.lock.acquire()
@@ -359,6 +379,7 @@ class File_List(object):
key, n, pyfile, pypack, pid = packager._getFileFromID(fileid)
pyfile.init()
pyfile.status.type = None
+ packager.file_list.core.pullManager.addEvent(UpdateEvent("file", fileid, key))
finally:
packager.file_list.lock.release()
@@ -367,15 +388,16 @@ class File_List(object):
try:
key, n, pyfile, pypack, pid = packager._getFileFromID(fileid)
pyfile.plugin.req.abort = True
+ packager.file_list.core.pullManager.addEvent(UpdateEvent("file", fileid, key))
finally:
packager.file_list.lock.release()
- #oooops, duplicate?
def removeFileFromPackage(packager, id, pid):
key, n, pypack = packager._getPackageFromID(pid)
for k, pyfile in enumerate(pypack.files):
if id == pyfile.id:
del pypack.files[k]
+ packager.file_list.core.pullManager.addEvent(RemoveEvent("file", pyfile.id, key))
if not pypack.files:
packager.removePackage(pid)
return True
diff --git a/module/gui/Collector.py b/module/gui/Collector.py
index 0aad5d1ba..c0754aa42 100644
--- a/module/gui/Collector.py
+++ b/module/gui/Collector.py
@@ -27,7 +27,6 @@ class PackageCollector(QObject):
self.view = view
self.connector = connector
self.collector = []
- self.interval = 2
self.rootItem = self.view.invisibleRootItem()
self.mutex = QMutex()
item = self.PackageCollectorPack(self)
@@ -36,48 +35,80 @@ class PackageCollector(QObject):
item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
self.rootItem.addChild(item)
self.linkCollector = item
- self.pauseIDs = []
- self.updater = self.CollectorUpdater(self.interval)
- self.connect(self.updater, SIGNAL("update()"), self.update)
- class CollectorUpdater(QThread):
- def __init__(self, interval):
- QThread.__init__(self)
- self.interval = interval
- self.running = True
-
- def run(self):
- while self.running:
- self.emit(SIGNAL("update()"))
- self.sleep(self.interval)
-
- def start(self):
- self.updater.start()
-
- def wait(self):
- self.updater.wait()
-
- def stop(self):
- self.updater.running = False
-
- def update(self):
+ def fullReload(self):
locker = QMutexLocker(self.mutex)
+ self.clearAll()
packs = self.connector.getPackageCollector()
- ids = []
- for data in packs:
- ids.append(data["id"])
- self.clear(ids)
for data in packs:
- if data["id"] in self.pauseIDs:
- continue
- ids.append(data["id"])
- pack = self.getPack(data["id"])
- if not pack:
- pack = self.PackageCollectorPack(self)
+ pack = self.PackageCollectorPack(self)
pack.setPackData(data)
+ files = self.connector.getPackageFiles(data["id"])
+ for fid in files:
+ info = self.connector.getLinkInfo(fid)
+ child = self.PackageCollectorFile(self, pack)
+ child.setFileData(info)
+ pack.addPackChild(fid, child)
self.addPack(data["id"], pack)
+
+ def addEvent(self, event):
+ if event[0] == "reload":
+ self.fullReload()
+ elif event[0] == "remove":
+ self.removeEvent(event)
+ elif event[0] == "insert":
+ self.insertEvent(event)
+ elif event[0] == "update":
+ self.updateEvent(event)
+
+ def removeEvent(self, event):
+ if event[2] == "file":
+ for pack in ItemIterator(self.rootItem):
+ for k, child in enumerate(pack.getChildren()):
+ if child.getFileData()["id"] == event[3]:
+ pack.takeChild(k)
+ break
+ else:
+ for k, pack in enumerate(ItemIterator(self.rootItem)):
+ if pack.getPackData()["id"] == event[3]:
+ self.rootItem.takeChild(k)
+ break
+
+ def insertEvent(self, event):
+ if event[2] == "file":
+ info = self.connector.getLinkInfo(event[3])
+ for pack in ItemIterator(self.rootItem):
+ if pack.getPackData()["id"] == info["package"]:
+ child = self.PackageCollectorFile(self, pack)
+ child.setFileData(info)
+ pack.addPackChild(info["id"], child)
+ break
+ else:
+ data = self.connector.getPackageInfo(event[3])
+ pack = self.PackageCollectorPack(self)
+ pack.setPackData(data)
+ self.addPack(data["id"], pack)
+ files = self.connector.getPackageFiles(data["id"])
+ for fid in files:
+ info = self.connector.getLinkInfo(fid)
+ child = self.PackageCollectorFile(self, pack)
+ child.setFileData(info)
+ pack.addPackChild(fid, child)
+ self.addPack(data["id"], pack)
+
+ def updateEvent(self, event):
+ if event[2] == "file":
+ info = self.connector.getLinkInfo(event[3])
+ for pack in ItemIterator(self.rootItem):
+ if pack.getPackData()["id"] == info["package"]:
+ child = pack.getChild(event[3])
+ child.setFileData(info)
+ pack.addPackChild(info["id"], child)
+ else:
+ data = self.connector.getPackageInfo(event[3])
+ pack = self.getPack(event[3])
+ pack.setPackData(data)
files = self.connector.getPackageFiles(data["id"])
- pack.clear(files)
for fid in files:
info = self.connector.getLinkInfo(fid)
child = pack.getChild(fid)
@@ -85,6 +116,7 @@ class PackageCollector(QObject):
child = self.PackageCollectorFile(self, pack)
child.setFileData(info)
pack.addPackChild(fid, child)
+ self.addPack(data["id"], pack)
def addPack(self, pid, newPack):
pos = None
@@ -110,38 +142,10 @@ class PackageCollector(QObject):
return pack
return None
- def clear(self, ids):
- clear = False
- remove = []
+ def clearAll(self):
for k, pack in enumerate(ItemIterator(self.rootItem)):
- if not pack.getPackData()["id"] in ids and not pack.getPackData()["id"] == "fixed":
- clear = True
- remove.append(k)
- if not clear:
- return
- remove.sort()
- remove.reverse()
- for k in remove:
- self.rootItem.takeChild(k)
- for pack in ItemIterator(self.rootItem):
- if pack.getPackData()["id"] == "fixed":
- return
- item = self.PackageCollectorPack(self)
- item.setPackData({"id":"fixed"})
- item.setData(0, Qt.DisplayRole, QVariant("Single Links"))
- item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
- self.rootItem.addChild(item)
- self.linkCollector = item
-
- def pauseItemUpdate(self, pid, pause=True):
- locker = QMutexLocker(self.mutex)
- if pause and not pid in self.pauseIDs:
- self.pauseIDs.append(int(pid))
- else:
- try:
- self.pauseIDs.remove(int(pid))
- except:
- pass
+ if not pack.getPackData()["id"] == "fixed":
+ self.rootItem.takeChild(k)
class PackageCollectorPack(QTreeWidgetItem):
def __init__(self, collector):
@@ -184,25 +188,6 @@ class PackageCollector(QObject):
if item.getFileData()["id"] == cid:
return item
return None
-
- def clear(self, ids):
- clear = False
- remove = []
- children = []
- for k, file in enumerate(self.getChildren()):
- if not file.getFileData()["id"] in ids:
- remove.append(file.getFileData()["id"])
- if file.getFileData()["id"] in children and not file.getFileData()["id"] in remove:
- remove.append(file.getFileData()["id"])
- continue
- children.append(file.getFileData()["id"])
- if not remove:
- return
- remove.sort()
- remove.reverse()
- parent = self
- for k in remove:
- parent.takeChild(k)
class PackageCollectorFile(QTreeWidgetItem):
def __init__(self, collector, pack):
@@ -226,44 +211,50 @@ class LinkCollector(QObject):
QObject.__init__(self)
self.view = view
self.connector = connector
- self.interval = 2
self.rootItem = root
self.mutex = QMutex()
- self.updater = self.CollectorUpdater(self.interval)
- self.connect(self.updater, SIGNAL("update()"), self.update)
- class CollectorUpdater(QThread):
- def __init__(self, interval):
- QThread.__init__(self)
- self.interval = interval
- self.running = True
-
- def run(self):
- while self.running:
- self.emit(SIGNAL("update()"))
- self.sleep(self.interval)
-
- def start(self):
- self.updater.start()
-
- def wait(self):
- self.updater.wait()
-
- def stop(self):
- self.updater.running = False
-
- def update(self):
+ def fullReload(self):
locker = QMutexLocker(self.mutex)
+ self.clearAll()
ids = self.connector.getLinkCollector()
- self.clear(ids)
for fid in ids:
data = self.connector.getLinkInfo(fid)
- file = self.getFile(fid)
- if not file:
- file = self.LinkCollectorFile(self)
+ file = self.LinkCollectorFile(self)
file.setFileData(data)
self.addFile(fid, file)
+ def addEvent(self, event):
+ if event[0] == "reload":
+ self.fullReload()
+ elif event[0] == "remove":
+ self.removeEvent(event)
+ elif event[0] == "insert":
+ self.insertEvent(event)
+ elif event[0] == "update":
+ self.updateEvent(event)
+
+ def removeEvent(self, event):
+ if event[2] == "file":
+ for k, file in enumerate(ItemIterator(self.rootItem)):
+ if file.getFileData()["id"] == event[3]:
+ self.rootItem.takeChild(k)
+ break
+
+ def insertEvent(self, event):
+ if event[2] == "file":
+ data = self.connector.getLinkInfo(event[3])
+ file = self.LinkCollectorFile(self)
+ file.setFileData(data)
+ self.addFile(event[3], file)
+
+ def updateEvent(self, event):
+ if event[2] == "file":
+ data = self.connector.getLinkInfo(event[3])
+ file = getFile(event[3])
+ file.setFileData(data)
+ self.addFile(event[3], file)
+
def addFile(self, pid, newFile):
pos = None
try:
@@ -289,16 +280,9 @@ class LinkCollector(QObject):
return file
return None
- def clear(self, ids):
- clear = False
- for file in ItemIterator(self.rootItem):
- if not file.getFileData()["id"] in ids:
- clear = True
- break
- if not clear:
- return
+ def clearAll(self):
self.rootItem.takeChildren()
-
+
class LinkCollectorFile(QTreeWidgetItem):
def __init__(self, collector):
QTreeWidgetItem.__init__(self)
diff --git a/module/gui/Queue.py b/module/gui/Queue.py
index 8681d3bb1..9659137ec 100644
--- a/module/gui/Queue.py
+++ b/module/gui/Queue.py
@@ -77,28 +77,101 @@ class Queue(QObject):
del d["name"]
del d["status"]
downloading[did] = d
- ids = []
- for data in packs:
- ids.append(data["id"])
- self.clear(ids)
+ for pack in ItemIterator(self.rootItem):
+ for child in pack.getChildren():
+ info = child.getFileData()
+ try:
+ info["downloading"] = downloading[info["id"]]
+ except:
+ info["downloading"] = None
+ child.setFileData(info)
+ pack.addPackChild(info["id"], child)
+ self.addPack(pack.getPackData()["id"], pack)
+
+ def fullReload(self):
+ locker = QMutexLocker(self.mutex)
+ self.clearAll()
+ packs = self.connector.getPackageQueue()
for data in packs:
- pack = self.getPack(data["id"])
- if not pack:
- pack = self.QueuePack(self)
+ pack = self.QueuePack(self)
pack.setPackData(data)
files = self.connector.getPackageFiles(data["id"])
- pack.clear(files)
+ for fid in files:
+ info = self.connector.getLinkInfo(fid)
+ child = self.QueueFile(self, pack)
+ if not info["status_type"]:
+ info["status_type"] = "queued"
+ child.setFileData(info)
+ pack.addPackChild(fid, child)
self.addPack(data["id"], pack)
+
+ def addEvent(self, event):
+ if event[0] == "reload":
+ self.fullReload()
+ elif event[0] == "remove":
+ self.removeEvent(event)
+ elif event[0] == "insert":
+ self.insertEvent(event)
+ elif event[0] == "update":
+ self.updateEvent(event)
+
+ def removeEvent(self, event):
+ if event[2] == "file":
+ for pack in ItemIterator(self.rootItem):
+ for k, child in enumerate(pack.getChildren()):
+ if child.getFileData()["id"] == event[3]:
+ pack.takeChild(k)
+ break
+ else:
+ for k, pack in enumerate(ItemIterator(self.rootItem)):
+ if pack.getPackData()["id"] == event[3]:
+ self.rootItem.takeChild(k)
+ break
+
+ def insertEvent(self, event):
+ if event[2] == "file":
+ info = self.connector.getLinkInfo(event[3])
+ for pack in ItemIterator(self.rootItem):
+ if pack.getPackData()["id"] == info["package"]:
+ child = self.QueueFile(self, pack)
+ child.setFileData(info)
+ pack.addPackChild(info["id"], child)
+ break
+ else:
+ data = self.connector.getPackageInfo(event[3])
+ pack = self.QueuePack(self)
+ pack.setPackData(data)
+ self.addPack(data["id"], pack)
+ files = self.connector.getPackageFiles(data["id"])
+ for fid in files:
+ info = self.connector.getLinkInfo(fid)
+ child = self.QueueFile(self, pack)
+ if not info["status_type"]:
+ info["status_type"] = "queued"
+ child.setFileData(info)
+ pack.addPackChild(fid, child)
+ self.addPack(data["id"], pack)
+
+ def updateEvent(self, event):
+ if event[2] == "file":
+ info = self.connector.getLinkInfo(event[3])
+ for pack in ItemIterator(self.rootItem):
+ if pack.getPackData()["id"] == info["package"]:
+ child = pack.getChild(event[3])
+ if not info["status_type"]:
+ info["status_type"] = "queued"
+ child.setFileData(info)
+ pack.addPackChild(info["id"], child)
+ else:
+ data = self.connector.getPackageInfo(event[3])
+ pack = self.getPack(event[3])
+ pack.setPackData(data)
+ files = self.connector.getPackageFiles(data["id"])
for fid in files:
info = self.connector.getLinkInfo(fid)
child = pack.getChild(fid)
if not child:
child = self.QueueFile(self, pack)
- info["downloading"] = None
- try:
- info["downloading"] = downloading[info["id"]]
- except:
- pass
if not info["status_type"]:
info["status_type"] = "queued"
child.setFileData(info)
@@ -145,19 +218,8 @@ class Queue(QObject):
return pack
return None
- def clear(self, ids):
- clear = False
- remove = []
- for k, pack in enumerate(ItemIterator(self.rootItem)):
- if not pack.getPackData()["id"] in ids:
- clear = True
- remove.append(k)
- if not clear:
- return
- remove.sort()
- remove.reverse()
- for k in remove:
- self.rootItem.takeChild(k)
+ def clearAll(self):
+ self.rootItem.takeChildren()
def getWaitingProgress(self, q):
locker = QMutexLocker(self.mutex)
@@ -282,24 +344,6 @@ class Queue(QObject):
if item.getFileData()["id"] == cid:
return item
return None
-
- def clear(self, ids):
- clear = False
- remove = []
- children = []
- for k, file in enumerate(self.getChildren()):
- if not file.getFileData()["id"] in ids:
- remove.append(file.getFileData()["id"])
- if file.getFileData()["id"] in children and not file.getFileData()["id"] in remove:
- remove.append(file.getFileData()["id"])
- continue
- children.append(file.getFileData()["id"])
- if not remove:
- return
- remove.sort()
- remove.reverse()
- for k in remove:
- self.takeChild(k)
class QueueFile(QTreeWidgetItem):
def __init__(self, queue, pack):
diff --git a/module/gui/connector.py b/module/gui/connector.py
index 432999161..3146ecf5b 100644
--- a/module/gui/connector.py
+++ b/module/gui/connector.py
@@ -19,6 +19,7 @@
SERVER_VERSION = "0.3"
from time import sleep
+from uuid import uuid4 as uuid
from PyQt4.QtCore import *
from PyQt4.QtGui import *
@@ -35,6 +36,7 @@ class connector(QThread):
self.running = True
self.proxy = None
self.addr = None
+ self.connectionID = None
self.errorQueue = []
self.connect(self, SIGNAL("proxy_error"), self._proxyError)
@@ -72,6 +74,7 @@ class connector(QThread):
self.proxy = ServerProxy(addr, allow_none=True)
try:
server_version = self.proxy.get_server_version()
+ self.connectionID = uuid().hex
except:
return False
if not server_version == SERVER_VERSION:
@@ -124,7 +127,9 @@ class connector(QThread):
"""
self.mutex.lock()
try:
- return self.proxy.get_file_info(id)
+ info = self.proxy.get_file_info(id)
+ info["downloading"] = None
+ return info
except Exception, e:
self.emit(SIGNAL("proxy_error"), "getLinkInfo", e)
finally:
@@ -421,4 +426,16 @@ class connector(QThread):
self.emit(SIGNAL("proxy_error"), "setCaptchaResult", e)
finally:
self.mutex.unlock()
+
+ def getEvents(self):
+ """
+ get events
+ """
+ self.mutex.lock()
+ try:
+ return self.proxy.get_events(self.connectionID)
+ except Exception, e:
+ self.emit(SIGNAL("proxy_error"), "getEvents", e)
+ finally:
+ self.mutex.unlock()
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 7aa38b9b1..dbc9dc1cd 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -59,6 +59,7 @@ from module.network.Request import Request
import module.remote.SecureXMLRPCServer as Server
from module.thread_list import Thread_List
from module.web.ServerThread import WebServer
+from module.PullEvents import PullManager
class Core(object):
""" pyLoad Core """
@@ -138,7 +139,8 @@ class Core(object):
self.lastGuiConnected = 0
self.server_methods = ServerMethods(self)
- self.file_list = File_List(self)
+ self.file_list = File_List(self)
+ self.pullManager = PullManager(self)
self.thread_list = Thread_List(self)
self.captchaManager = CaptchaManager(self)
@@ -571,7 +573,10 @@ class ServerMethods():
return True
else:
return False
-
+
+ def get_events(self, uuid):
+ return self.core.pullManager.getEvents(uuid)
+
#def move_urls_up(self, ids):
# for id in ids:
# self.core.file_list.move(id)
diff --git a/pyLoadGui.py b/pyLoadGui.py
index 9e04cc003..c3deb9a6e 100755
--- a/pyLoadGui.py
+++ b/pyLoadGui.py
@@ -87,7 +87,6 @@ class main(QObject):
self.mainloop.start()
self.clipboard = self.app.clipboard()
self.connect(self.clipboard, SIGNAL('dataChanged()'), self.slotClipboardChange)
- self.connect(self.mainWindow, SIGNAL("pauseItemUpdate"), self.packageCollector.pauseItemUpdate)
self.mainWindow.actions["clipboard"].setChecked(self.checkClipboard)
def stopMain(self):
@@ -106,8 +105,6 @@ class main(QObject):
self.mainloop.wait()
self.connector.wait()
self.queue.wait()
- self.linkCollector.wait()
- self.packageCollector.wait()
def connectSignals(self):
"""
@@ -216,7 +213,6 @@ class main(QObject):
view.setDragDropOverwriteMode(True)
self.connect(view, SIGNAL("droppedToPack"), self.slotAddFileToPackage)
self.packageCollector = PackageCollector(view, self.connector)
- self.packageCollector.start()
def initLinkCollector(self):
"""
@@ -224,7 +220,6 @@ class main(QObject):
* refresh thread
"""
self.linkCollector = LinkCollector(self.mainWindow.tabs["collector"]["package_view"], self.packageCollector.linkCollector, self.connector)
- self.linkCollector.start()
def initQueue(self):
"""
@@ -579,6 +574,16 @@ class main(QObject):
def slotCaptchaDone(self, cid, result):
self.connector.setCaptchaResult(str(cid), str(result))
+ def pullEvents(self):
+ events = self.connector.getEvents()
+ for event in events:
+ if event[1] == "queue":
+ self.queue.addEvent(event)
+ elif event[1] == "packages":
+ self.packageCollector.addEvent(event)
+ elif event[1] == "collector":
+ self.linkCollector.addEvent(event)
+
class Loop(QThread):
"""
main loop (not application loop)
@@ -602,6 +607,7 @@ class main(QObject):
self.parent.refreshLog()
self.parent.updateAvailable()
self.parent.checkCaptcha()
+ self.parent.pullEvents()
def stop(self):
self.running = False