diff options
author | Denis Fomin <fominde@gmail.com> | 2010-11-05 16:41:00 +0300 |
---|---|---|
committer | Denis Fomin <fominde@gmail.com> | 2010-11-05 16:41:00 +0300 |
commit | c97e45f20ae7eb7017488faee7f98a6d435a6f53 (patch) | |
tree | 2a79ad53d3a8110930604ac5cc3e3f5303b8e3b9 /ubuntu_integration/plugin.py | |
parent | 714ba62722014acd747f6fd7286e85589bfc6599 (diff) |
ftp manager plugin added to the main repository
Diffstat (limited to 'ubuntu_integration/plugin.py')
-rw-r--r-- | ubuntu_integration/plugin.py | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/ubuntu_integration/plugin.py b/ubuntu_integration/plugin.py index 7f67ec0..6e7d136 100644 --- a/ubuntu_integration/plugin.py +++ b/ubuntu_integration/plugin.py @@ -44,24 +44,28 @@ class UbuntuIntegrationPlugin(GajimPlugin): """ Class for Messaging Menu and Me Menu. """ - + @log_calls("UbuntuIntegrationPlugin") def init(self): """ Does nothing. """ self.config_dialog = None - + @log_calls("UbuntuIntegrationPlugin") def activate(self): """ Displays gajim in the Messaging Menu. """ + # {(account, jid): (indicator, [event, ...]), ...} + self.events = {} + self.server = None + if not HAS_INDICATE: raise GajimPluginException("python-indicate is missing!") if not HAS_PYXDG: raise GajimPluginException("python-xdg is missing!") - + self.server = indicate.indicate_server_ref_default() self.server.set_type("message.im") dfile = "" @@ -72,13 +76,10 @@ class UbuntuIntegrationPlugin(GajimPlugin): raise GajimPluginException("Can't locate gajim.desktop!") self.server.set_desktop_file(dfile) self.server.show() - - # {(account, jid): (indicator, [event, ...]), ...} - self.events = {} - + gajim.events.event_added_subscribe(self.on_event_added) gajim.events.event_removed_subscribe(self.on_event_removed) - + @log_calls("UbuntuIntegrationPlugin") def deactivate(self): """ @@ -86,14 +87,14 @@ class UbuntuIntegrationPlugin(GajimPlugin): """ gajim.events.event_added_unsubscribe(self.on_event_added) gajim.events.event_removed_unsubscribe(self.on_event_removed) - + for (_, event) in self.events: event[0].hide() self.server.hide() - + del self.server del self.events - + def on_indicator_activate(self, indicator, _): """ Forwards the action to gajims event handler. @@ -101,20 +102,20 @@ class UbuntuIntegrationPlugin(GajimPlugin): key = indicator.key event = self.events[key][1][0] gajim.interface.handle_event(event.account, event.jid, event.type_) - + def on_event_added(self, event): """ Adds "Nickname Time" to the Messaging menu. """ print "----", event.type_ - + # Basic variables account = event.account jid = event.jid when = time.time() contact = "" key = (account, jid) - + # Check if the event is valid and modify the variables if event.type_ == "chat" or \ event.type_ == "printed_chat" or \ @@ -135,9 +136,9 @@ class UbuntuIntegrationPlugin(GajimPlugin): else: print "ignored"; return - + print account, jid, when, contact - + # Add a new indicator if necessary if not self.events.has_key(key): indicator = indicate.Indicator() @@ -152,11 +153,11 @@ class UbuntuIntegrationPlugin(GajimPlugin): indicator.show() indicator.key = key self.events[key] = (indicator, []) - + # Prepare the event and save it event.time = when self.events[key][1].append(event); - + def on_event_removed(self, events): """ Goes through the events and removes them from the array and @@ -164,13 +165,13 @@ class UbuntuIntegrationPlugin(GajimPlugin): """ for event in events: print "====", event.type_ - + key = (event.account, event.jid) - + if self.events.has_key(key) and \ event in self.events[key][1]: self.events[key][1].remove(event) - + if len(self.events[key][1]) == 0: # remove indicator self.events[key][0].hide() del self.events[key] |