Skip to content
Snippets Groups Projects
Commit be43c2c8 authored by dkirov's avatar dkirov
Browse files

added add_contact and remove_contact methods

parent 08a1bae7
No related branches found
No related tags found
No related merge requests found
......@@ -173,7 +173,23 @@ def __init__(self):
_('Write the current state of Gajim preferences to the \
.config file'),
[ ]
],
'remove_contact': [
_('Remove contact from roster'),
[
('jid', _('JID of the contact'), True),
(_('account'), _('if specified, contact is taken from \
the contact list of this account'), False)
]
],
'add_contact': [
_('Add contact to roster'),
[
(_('account'), _('Add new contact to this account.'), True)
]
]
}
if self.argv_len < 2 or \
sys.argv[1] not in self.commands.keys(): # no args or bad args
......
......@@ -25,7 +25,7 @@
from common import gajim
from time import time
from common import i18n
from dialogs import AddNewContactWindow
_ = i18n._
try:
......@@ -107,6 +107,8 @@ def __init__(self, service, plugin):
self.prefs_store,
self.prefs_del,
self.prefs_put,
self.add_contact,
self.remove_contact
])
def raise_signal(self, signal, arg):
......@@ -410,6 +412,32 @@ def prefs_put(self, *args):
gajim.config.set_per(key_path[0], key_path[1], subname, value)
return True
def add_contact(self, *args):
[account] = self._get_real_arguments(args, 1)
if gajim.contacts.has_key(account):
AddNewContactWindow(self.plugin, account)
return True
return False
def remove_contact(self, *args):
[jid, account] = self._get_real_arguments(args, 2)
accounts = gajim.contacts.keys()
# if there is only one account in roster, take it as default
if account:
accounts = [account]
else:
accounts = gajim.contacts.keys()
contact_exists = False
for account in accounts:
if gajim.contacts[account].has_key(jid):
gajim.connections[account].unsubscribe(jid)
for contact in gajim.contacts[account][jid]:
self.plugin.roster.remove_contact(contact, account)
del gajim.contacts[account][jid]
contact_exists = True
return contact_exists
def _is_first(self):
if self.first_show:
self.first_show = False
......@@ -479,6 +507,8 @@ def _serialized_contacts(self, contacts):
prefs_put = method(INTERFACE)(prefs_put)
prefs_del = method(INTERFACE)(prefs_del)
prefs_store = method(INTERFACE)(prefs_store)
remove_contact = method(INTERFACE)(remove_contact)
add_contact = method(INTERFACE)(add_contact)
class SessionBusNotPresent(Exception):
''' This exception indicates that there is no session daemon '''
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment