diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-08-27 14:00:31 +0200 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-08-27 14:00:31 +0200 |
commit | 1dbb6423000e2fcd3fe9a1b6ddbf6200d522d470 (patch) | |
tree | d08261580175c8ad796d86bacbbc094c7aa08636 /src | |
parent | bc17e32391578ee0128fe73719d1f691613d18fe (diff) | |
download | abrt-1dbb6423000e2fcd3fe9a1b6ddbf6200d522d470.tar.gz abrt-1dbb6423000e2fcd3fe9a1b6ddbf6200d522d470.tar.xz abrt-1dbb6423000e2fcd3fe9a1b6ddbf6200d522d470.zip |
added signal JobStarted => removed the ugly sleep() hack
Diffstat (limited to 'src')
-rw-r--r-- | src/Daemon/CommLayerServer.h | 1 | ||||
-rw-r--r-- | src/Daemon/CommLayerServerDBus.cpp | 9 | ||||
-rw-r--r-- | src/Daemon/CommLayerServerDBus.h | 2 | ||||
-rw-r--r-- | src/Daemon/CrashWatcher.cpp | 13 | ||||
-rw-r--r-- | src/Gui/CCDBusBackend.py | 17 | ||||
-rw-r--r-- | src/Gui/CCMainWindow.py | 2 |
6 files changed, 28 insertions, 16 deletions
diff --git a/src/Daemon/CommLayerServer.h b/src/Daemon/CommLayerServer.h index ededee5..3a1177d 100644 --- a/src/Daemon/CommLayerServer.h +++ b/src/Daemon/CommLayerServer.h @@ -17,6 +17,7 @@ class CCommLayerServer { virtual void Update(const std::string& pMessage, uint64_t pJobID) {}; virtual void Warning(const std::string& pMessage) {}; virtual void JobDone(const std::string &pDest, uint64_t pJobID) {}; + virtual void JobStarted(const std::string &pDest, uint64_t pJobID) {}; virtual void Warning(const std::string& pMessage, uint64_t pJobID) {}; }; diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp index d3e157d..8077757 100644 --- a/src/Daemon/CommLayerServerDBus.cpp +++ b/src/Daemon/CommLayerServerDBus.cpp @@ -230,6 +230,15 @@ void CCommLayerServerDBus::JobDone(const std::string &pDest, uint64_t job_id) emit_signal(sig); } +void CCommLayerServerDBus::JobStarted(const std::string &pDest, uint64_t job_id) +{ + ::DBus::SignalMessage sig("JobStarted"); + ::DBus::MessageIter wi = sig.writer(); + wi << pDest; + wi << job_id; + emit_signal(sig); +} + void CCommLayerServerDBus::Error(const std::string& arg1) { ::DBus::SignalMessage sig("Error"); diff --git a/src/Daemon/CommLayerServerDBus.h b/src/Daemon/CommLayerServerDBus.h index a3b54a7..eda2196 100644 --- a/src/Daemon/CommLayerServerDBus.h +++ b/src/Daemon/CommLayerServerDBus.h @@ -38,7 +38,9 @@ class CCommLayerServerDBus virtual void AnalyzeComplete(const map_crash_report_t& arg1); virtual void Error(const std::string& arg1); virtual void Update(const std::string& pMessage, uint64_t pJobID); + //the job id should be enough in jobdone virtual void JobDone(const std::string& pDest, uint64_t pJobID); + virtual void JobStarted(const std::string& pDest, uint64_t pJobID); virtual void Warning(const std::string& pMessage); virtual void Warning(const std::string& pMessage, uint64_t pJobID); }; diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index 2713179..288ecc0 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -119,18 +119,7 @@ static void *create_report(void *arg) thread_data_t *thread_data = (thread_data_t *) arg; map_crash_info_t crashReport; - /* Ugly hack. - * We use DBus signals to talk to clients. - * If the report thread emits a signal with embedded job id before - * main thread returns this job id as a CreateReport() DBus call's - * return value, the client will not be able to understand - * that this signal is for its job. - * By no means this is the right solution. The right one would be - * to ensure that CreateReport() DBus call returns _before_ - * we continue here. This will need substantial surgery - * on our DBus machinery. TODO. - */ - usleep(10*1000); + g_pCommLayer->JobStarted(thread_data->dest, thread_data->thread_id); log("Creating report..."); try diff --git a/src/Gui/CCDBusBackend.py b/src/Gui/CCDBusBackend.py index 34a3000..864b366 100644 --- a/src/Gui/CCDBusBackend.py +++ b/src/Gui/CCDBusBackend.py @@ -60,7 +60,7 @@ class DBusManager(gobject.GObject): gobject.signal_new ("abrt-error", self, gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,)) gobject.signal_new ("warning", self, gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,)) # signal emited to update gui with current status - gobject.signal_new ("update", self, gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,)) + gobject.signal_new ("update", self, gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,gobject.TYPE_PYOBJECT)) # signal emited to show gui if user try to run it again gobject.signal_new ("show", self, gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,()) # signal emited to show gui if user try to run it again @@ -101,12 +101,14 @@ class DBusManager(gobject.GObject): self.emit("crash") def update_cb(self, message, job_id=0): + print "Update >>%s<< for job: %s" % (message, job_id) # FIXME: use dest instead of 0 once we implement it in daemon #if self.uniq_name == dest: if job_id == 0 or job_id in self.pending_jobs: - self.emit("update", message) + self.emit("update", message, job_id) def warning_cb(self, message, job_id=0): + print "Warning >>%s<< for job: %s" % (message, job_id) # FIXME: use dest instead of 0 once we implement it in daemon #if self.uniq_name == dest: if job_id == 0 or job_id in self.pending_jobs: @@ -156,14 +158,22 @@ class DBusManager(gobject.GObject): self.acconnection = self.proxy.connect_to_signal("Warning",self.warning_cb,dbus_interface=CC_IFACE) # watch for job-done signals self.acconnection = self.proxy.connect_to_signal("JobDone",self.jobdone_cb,dbus_interface=CC_IFACE) + self.acconnection = self.proxy.connect_to_signal("JobStarted",self.jobstarted_cb,dbus_interface=CC_IFACE) else: raise Exception(_("Please check if abrt daemon is running.")) def addJob(self, job_id): self.pending_jobs.append(job_id) + def jobstarted_cb(self, dest, job_id): + # the job belongs to this client + if self.uniq_name == dest: + print "Started our job: %s" % job_id + self.addJob(job_id) + def jobdone_cb(self, dest, job_id): if self.uniq_name == dest: + print "Our job: %s is done." % job_id dump = self.cc.GetJobResult(job_id) if dump: self.emit("analyze-complete", dump) @@ -178,7 +188,8 @@ class DBusManager(gobject.GObject): # let's try it async # even if it's async it timeouts, so let's try to set the timeout to 60sec #self.cc.CreateReport(UUID, reply_handler=self.addJob, error_handler=self.error_handler, timeout=60) - self.addJob(self.cc.CreateReport(UUID, timeout=60)) + # we don't need the return value, as the job_id is sent via JobStarted signal + self.cc.CreateReport(UUID, timeout=60) except dbus.exceptions.DBusException, e: raise Exception(e) diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index d1eaff7..2b1dc78 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -155,7 +155,7 @@ class MainWindow(): pass gui_error_message(_("Unable to get report!\n%s" % message),parent_dialog=self.window) - def update_cb(self, daemon, message): + def update_cb(self, daemon, message, job_id): message = message.replace('\n',' ') self.wTree.get_widget("lStatus").set_text(message) |