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:
parent
97420f39d5
commit
b44412ec0d
17 changed files with 207 additions and 130 deletions
|
|
@ -19,7 +19,7 @@ You should have received a copy of the GNU Affero General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
from logging import debug, info, error
|
||||
from logging import debug, info, warning, error
|
||||
from sat.tools.jid import JID
|
||||
from sat_frontends.bridge.DBus import DBusBridgeFrontend,BridgeExceptionNoService
|
||||
from optparse import OptionParser
|
||||
|
|
@ -32,7 +32,6 @@ class QuickApp():
|
|||
"""This class contain the main methods needed for the frontend"""
|
||||
|
||||
def __init__(self, single_profile=True):
|
||||
self.rosterList = {}
|
||||
self.profiles = {}
|
||||
self.single_profile = single_profile
|
||||
self.check_options()
|
||||
|
|
@ -157,7 +156,7 @@ class QuickApp():
|
|||
|
||||
### now we fill the contact list ###
|
||||
for contact in self.bridge.getContacts(profile):
|
||||
self.newContact(contact[0], contact[1], contact[2], profile)
|
||||
self.newContact(*contact, profile=profile)
|
||||
|
||||
presences = self.bridge.getPresenceStatus(profile)
|
||||
for contact in presences:
|
||||
|
|
@ -207,8 +206,7 @@ class QuickApp():
|
|||
if not self.check_profile(profile):
|
||||
return
|
||||
debug(_("Disconnected"))
|
||||
self.CM.clear()
|
||||
self.contactList.clear_contacts()
|
||||
self.contactList.clearContacts()
|
||||
self.setStatusOnline(False)
|
||||
|
||||
def connectionError(self, error_type, profile):
|
||||
|
|
@ -227,10 +225,7 @@ class QuickApp():
|
|||
return
|
||||
entity=JID(JabberId)
|
||||
_groups = list(groups)
|
||||
self.rosterList[entity.short]=(dict(attributes), _groups)
|
||||
if entity in self.CM:
|
||||
self.CM.update(entity, 'groups', _groups)
|
||||
self.contactList.replace(entity, self.CM.getAttr(entity, 'groups'))
|
||||
self.contact_list._replace(entity, _groups, attributes)
|
||||
|
||||
def newMessage(self, from_jid, msg, type, to_jid, profile):
|
||||
if not self.check_profile(profile):
|
||||
|
|
@ -266,36 +261,20 @@ class QuickApp():
|
|||
self.setStatusOnline(False)
|
||||
return
|
||||
|
||||
self.contact_list.updatePresence(from_jid, show, priority, statuses)
|
||||
|
||||
if show != 'unavailable':
|
||||
name=""
|
||||
groups = []
|
||||
if self.rosterList.has_key(from_jid.short):
|
||||
if self.rosterList[from_jid.short][0].has_key("name"):
|
||||
name=self.rosterList[from_jid.short][0]["name"]
|
||||
groups=self.rosterList[from_jid.short][1]
|
||||
|
||||
|
||||
#FIXME: must be moved in a plugin
|
||||
if from_jid.short in self.profiles[profile]['watched'] and not from_jid.short in self.profiles[profile]['onlineContact']:
|
||||
self.showAlert(_("Watched jid [%s] is connected !") % from_jid.short)
|
||||
|
||||
self.profiles[profile]['onlineContact'].add(from_jid) #FIXME onlineContact is useless with CM, must be removed
|
||||
self.CM.add(from_jid)
|
||||
self.CM.update(from_jid, 'name', unicode(name))
|
||||
self.CM.update(from_jid, 'show', show)
|
||||
self.CM.update(from_jid, 'statuses', statuses)
|
||||
self.CM.update(from_jid, 'groups', groups)
|
||||
cache = self.bridge.getCardCache(from_jid, profile)
|
||||
if cache.has_key('nick'):
|
||||
self.CM.update(from_jid, 'nick', unicode(cache['nick']))
|
||||
if cache.has_key('avatar'):
|
||||
self.CM.update(from_jid, 'avatar', self.bridge.getAvatarFile(cache['avatar']))
|
||||
self.contactList.replace(from_jid, self.CM.getAttr(from_jid, 'groups'))
|
||||
|
||||
#TODO: vcard data (avatar)
|
||||
|
||||
if show=="unavailable" and from_jid in self.profiles[profile]['onlineContact']:
|
||||
self.profiles[profile]['onlineContact'].remove(from_jid)
|
||||
self.CM.remove(from_jid)
|
||||
if not self.CM.isConnected(from_jid):
|
||||
self.contactList.disconnect(from_jid)
|
||||
|
||||
def roomJoined(self, room_jid, room_nicks, user_nick, profile):
|
||||
"""Called when a MUC room is joined"""
|
||||
|
|
@ -491,27 +470,27 @@ class QuickApp():
|
|||
if not self.check_profile(profile):
|
||||
return
|
||||
target = JID(jid)
|
||||
self.contactList.remove(self.CM.get_full(target))
|
||||
self.CM.remove(target)
|
||||
self.contactList.remove(target)
|
||||
try:
|
||||
self.profiles[profile]['onlineContact'].remove(target.short)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def updatedValue(self, name, data, profile):
|
||||
#FIXME: to be removed
|
||||
if not self.check_profile(profile):
|
||||
return
|
||||
if name == "card_nick":
|
||||
target = JID(data['jid'])
|
||||
if target in self.contactList:
|
||||
self.CM.update(target, 'nick', unicode(data['nick']))
|
||||
self.contactList.replace(target)
|
||||
#self.CM.update(target, 'nick', unicode(data['nick']))
|
||||
self.contact_list._replace(target)
|
||||
elif name == "card_avatar":
|
||||
target = JID(data['jid'])
|
||||
if target in self.contactList:
|
||||
filename = self.bridge.getAvatarFile(data['avatar'])
|
||||
self.CM.update(target, 'avatar', filename)
|
||||
self.contactList.replace(target)
|
||||
#self.CM.update(target, 'avatar', filename)
|
||||
self.contact_list._replace(target)
|
||||
|
||||
def askConfirmation(self, type, id, data):
|
||||
raise NotImplementedError
|
||||
|
|
|
|||
Loading…
Reference in a new issue