ftp manager plugin added to the main repository
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
## plugins/ftp_manager/ftp_manager.py
|
||||
##
|
||||
## Copyright (C) 2010 Denis Fomin <fominde AT gmail.com>
|
||||
##
|
||||
## This file is part of Gajim.
|
||||
##
|
||||
## Gajim is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published
|
||||
## by the Free Software Foundation; version 3 only.
|
||||
##
|
||||
## Gajim is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
import gtk
|
||||
import pango
|
||||
import gobject
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user