core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:

- QuickContactManagement is not used anymore and will be removed, ContactList + Core are used instead
	- disconnected contacts are now displayed in Primitivus (M-d to show/hide them)
	- avatars are temporary unavailable in wix
	- new bridge method: getContactsFromGroup
This commit is contained in:
Goffi 2012-09-25 00:58:34 +02:00
commit b44412ec0d
17 changed files with 207 additions and 130 deletions

View file

@ -255,6 +255,12 @@ class DbusObject(dbus.service.Object):
def getContacts(self, profile_key="@DEFAULT@"):
return self._callback("getContacts", unicode(profile_key))
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='ss', out_signature='as',
async_callbacks=None)
def getContactsFromGroup(self, group, profile_key="@DEFAULT@"):
return self._callback("getContactsFromGroup", unicode(group), unicode(profile_key))
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='ssib', out_signature='a(dsss)',
async_callbacks=('callback', 'errback'))
@ -366,7 +372,7 @@ class DbusObject(dbus.service.Object):
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
in_signature='sssss', out_signature='',
async_callbacks=None)
def sendMessage(self, to_jid, message, subject='', mess_type="chat", profile_key="@DEFAULT@"):
def sendMessage(self, to_jid, message, subject='', mess_type="auto", profile_key="@DEFAULT@"):
return self._callback("sendMessage", unicode(to_jid), unicode(message), unicode(subject), unicode(mess_type), unicode(profile_key))
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,

View file

@ -271,6 +271,17 @@ doc_return=array of tuples with the following values:
- list of attributes as in [newContact]
- groups where the contact is
[getContactsFromGroup]
type=method
category=core
sig_in=ss
sig_out=as
param_1_default="@DEFAULT@"
doc=Return informations about all contacts
doc_param_0=group: name of the group to check
doc_param_1=%(doc_profile_key)s
doc_return=array of jids
[getLastResource]
type=method
category=core

View file

@ -30,3 +30,6 @@ class ConnectedProfileError(Exception):
class UnknownEntityError(Exception):
pass
class UnknownGroupError(Exception):
pass

View file

@ -126,6 +126,7 @@ class SAT(service.Service):
self.bridge.register("asyncConnect", self.asyncConnect)
self.bridge.register("disconnect", self.disconnect)
self.bridge.register("getContacts", self.getContacts)
self.bridge.register("getContactsFromGroup", self.getContactsFromGroup)
self.bridge.register("getLastResource", self.memory.getLastResource)
self.bridge.register("getPresenceStatus", self.memory.getPresenceStatus)
self.bridge.register("getWaitingSub", self.memory.getWaitingSub)
@ -276,8 +277,7 @@ class SAT(service.Service):
def getContacts(self, profile_key):
client = self.getClient(profile_key)
if not client:
error(_('Asking contacts for a non-existant profile'))
return []
raise ProfileUnknownError(_('Asking contacts for a non-existant profile'))
ret = []
for item in client.roster.getItems(): #we get all item for client's roster
#and convert them to expected format
@ -285,6 +285,12 @@ class SAT(service.Service):
ret.append([item.jid.userhost(), attr, item.groups])
return ret
def getContactsFromGroup(self, group, profile_key):
client = self.getClient(profile_key)
if not client:
raise ProfileUnknownError(_("Asking group's contacts for a non-existant profile"))
return client.roster.getJidsFromGroup(group)
def purgeClient(self, profile):
"""Remove reference to a profile client and purge cache
the garbage collector can then free the memory"""

View file

@ -23,6 +23,7 @@ from twisted.internet import task, defer
from twisted.words.protocols.jabber import jid, xmlstream
from wokkel import client, disco, xmppim, generic, compat
from logging import debug, info, error
from sat.core import exceptions
class SatXMPPClient(client.XMPPClient):
@ -164,9 +165,9 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
"""Return dictionary of attributes as used in bridge from a RosterItem
@param item: RosterItem
@return: dictionary of attributes"""
item_attr = {'to': str(item.subscriptionTo),
'from': str(item.subscriptionFrom),
'ask': str(item.ask)
item_attr = {'to': unicode(item.subscriptionTo),
'from': unicode(item.subscriptionFrom),
'ask': unicode(item.ask)
}
if item.name:
item_attr['name'] = item.name
@ -235,6 +236,12 @@ class SatRosterProtocol(xmppim.RosterClientProtocol):
def getItems(self):
"""Return all items of the roster"""
return self._jids.values()
def getJidsFromGroup(self, group):
try:
return self._groups[group]
except KeyError:
return exceptions.UnknownGroupError
class SatPresenceProtocol(xmppim.PresenceClientProtocol):

View file

@ -55,7 +55,7 @@ class TriggerManager:
"""This put a trigger point
All the trigger for that point will be run
@param point_name: name of the trigger point
@return: True if the action must be continue, False else"""
@return: True if the action must be continued, False else"""
if not self.__triggers.has_key(point_name):
return True