From 17af7902e45fbbb1e213d84dd665e82efc1f4a1a Mon Sep 17 00:00:00 2001 From: Stephan Erb Date: Thu, 5 Nov 2009 22:16:38 +0100 Subject: [PATCH] Make it explicit whether an ordinary Contact, a Self Contact or a Not-In-Roster Contact is created. --- src/common/contacts.py | 15 +++++++++++++++ src/dialogs.py | 4 +--- src/gui_interface.py | 15 +++++++-------- src/roster_window.py | 17 +++++++++-------- src/search_window.py | 4 +--- src/session.py | 3 ++- 6 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/common/contacts.py b/src/common/contacts.py index a151e216c..c423fe275 100644 --- a/src/common/contacts.py +++ b/src/common/contacts.py @@ -187,6 +187,7 @@ class Contact(CommonContact): return False + class GC_Contact(CommonContact): '''Information concerning each groupchat contact''' def __init__(self, room_jid, account, name='', show='', status='', role='', @@ -260,6 +261,20 @@ class Contacts: keyID=keyID, client_caps=client_caps, our_chatstate=our_chatstate, chatstate=chatstate, last_status_time=last_status_time, composing_xep=composing_xep, mood=mood, tune=tune, activity=activity) + + def create_self_contact(self, jid, account, resource, show, status, priority, keyID=''): + conn = common.gajim.connections[account] + nick = common.gajim.nicks[account] + return self.create_contact(jid=jid, account=account, + name=nick, groups=['self_contact'], show=show, status=status, + sub='both', ask='none', priority=priority, keyID=keyID, + resource=resource, mood=conn.mood, tune=conn.tune, + activity=conn.activity) + + def create_not_in_roster_contact(self, jid, account, resource='', name='', keyID=''): + return self.create_contact(jid=jid, account=account, resource=resource, + name=name, groups=[_('Not in Roster')], show='not in roster', + status='', sub='none', keyID=keyID) def copy_contact(self, contact): return self.create_contact(jid=contact.jid, account=contact.account, diff --git a/src/dialogs.py b/src/dialogs.py index d9cf91328..8be8e9201 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -1888,9 +1888,7 @@ class SubscriptionRequestWindow: if self.jid in gajim.interface.instances[self.account]['infos']: gajim.interface.instances[self.account]['infos'][self.jid].window.present() else: - contact = gajim.contacts.create_contact(jid=self.jid, account=self.account, name='', - groups=[], show='', status='', sub='', ask='', resource='', - priority=5, keyID='', our_chatstate=None, chatstate=None) + contact = gajim.contacts.create_contact(jid=self.jid, account=self.account) gajim.interface.instances[self.account]['infos'][self.jid] = \ vcard.VcardWindow(contact, self.account) # Remove jabber page diff --git a/src/gui_interface.py b/src/gui_interface.py index 179a9c02b..d65625ffa 100644 --- a/src/gui_interface.py +++ b/src/gui_interface.py @@ -344,11 +344,9 @@ class Interface: # Ignore offline presence of unknown self resource if new_show < 2: return - contact1 = gajim.contacts.create_contact(jid=ji, account=account, - name=gajim.nicks[account], groups=['self_contact'], - show=array[1], status=status_message, sub='both', ask='none', - priority=priority, keyID=keyID, resource=resource, - mood=conn.mood, tune=conn.tune, activity=conn.activity) + contact1 = gajim.contacts.create_self_contact(jid=ji, + account=account, show=array[1], status=status_message, + priority=priority, keyID=keyID, resource=resource) old_show = 0 gajim.contacts.add_contact(account, contact1) lcontact.append(contact1) @@ -1353,9 +1351,8 @@ class Interface: 'attached_gpg_keys').split() if jid in attached_keys: keyID = attached_keys[attached_keys.index(jid) + 1] - contact = gajim.contacts.create_contact(jid=jid, account=account, name='', - groups=[_('Not in Roster')], show='not in roster', status='', - sub='none', keyID=keyID) + contact = gajim.contacts.create_not_in_roster_contact(jid=jid, + account=account, keyID=keyID) gajim.contacts.add_contact(account, contact) self.roster.add_contact(contact.jid, account) file_props = array[1] @@ -2567,6 +2564,7 @@ class Interface: account): # Join new groupchat if minimize: + #GCMIN contact = gajim.contacts.create_contact(jid=room_jid, account=account, name=nick) gc_control = GroupchatControl(None, contact, account) gajim.interface.minimized_controls[account][room_jid] = gc_control @@ -2590,6 +2588,7 @@ class Interface: def new_room(self, room_jid, nick, account, is_continued=False): # Get target window, create a control, and associate it with the window + # GCMIN contact = gajim.contacts.create_contact(jid=room_jid, account=account, name=nick) mw = self.msg_win_mgr.get_window(contact.jid, account) if not mw: diff --git a/src/roster_window.py b/src/roster_window.py index 07a48b287..8c85a70d1 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -806,6 +806,7 @@ class RosterWindow: else: name = jid.split('@')[0] # New groupchat + #GCMIN contact = gajim.contacts.create_contact(jid=jid, account=account, name=name, groups=[_('Groupchats')], show=show, status=status, sub='none') gajim.contacts.add_contact(account, contact) @@ -841,6 +842,7 @@ class RosterWindow: Return the added contact instance.''' contact = gajim.contacts.get_contact_with_highest_priority(account, jid) if contact is None: + #TRANSP contact = gajim.contacts.create_contact(jid=jid, account=account, name=jid, groups=[_('Transports')], show='offline', status='offline', sub='from') @@ -982,9 +984,8 @@ class RosterWindow: 'attached_gpg_keys').split() if jid in attached_keys: keyID = attached_keys[attached_keys.index(jid) + 1] - contact = gajim.contacts.create_contact(jid=jid, account=account, name=nick, - groups=[_('Not in Roster')], show='not in roster', status='', - sub='none', resource=resource, keyID=keyID) + contact = gajim.contacts.create_not_in_roster_contact(jid=jid, + account=account, resource=resource, name=nick, keyID=keyID) gajim.contacts.add_contact(account, contact) self.add_contact(contact.jid, account) return contact @@ -1772,6 +1773,7 @@ class RosterWindow: if gajim.jid_is_transport(jid): array[jid]['groups'] = [_('Transports')] + #TRANSP - potential contact1 = gajim.contacts.create_contact(jid=ji, account=account, name=name, groups=array[jid]['groups'], show=show, status=status, sub=array[jid]['subscription'], ask=array[jid]['ask'], @@ -2538,11 +2540,10 @@ class RosterWindow: show = roster.getShow(jid+'/'+resource) if not show: show = 'online' - contact = gajim.contacts.create_contact(jid=jid, account=account, - name=account, groups=['self_contact'], show=show, - status=roster.getStatus(jid + '/' + resource), - resource=resource, - priority=roster.getPriority(jid + '/' + resource)) + contact = gajim.contacts.create_self_contact(jid=jid, + account=account, show=show, status=roster.getStatus(jid + '/' + resource), + priority=roster.getPriority(jid + '/' + resource), + resource=resource) contacts.append(contact) if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: self.tooltip.id = row diff --git a/src/search_window.py b/src/search_window.py index e383e7c4f..3a21db543 100644 --- a/src/search_window.py +++ b/src/search_window.py @@ -110,9 +110,7 @@ class SearchWindow: if jid in gajim.interface.instances[self.account]['infos']: gajim.interface.instances[self.account]['infos'][jid].window.present() else: - contact = gajim.contacts.create_contact(jid=jid, account=self.account, name='', groups=[], - show='', status='', sub='', ask='', resource='', priority=0, - keyID='', our_chatstate=None, chatstate=None) + contact = gajim.contacts.create_contact(jid=jid, account=self.account) gajim.interface.instances[self.account]['infos'][jid] = \ vcard.VcardWindow(contact, self.account) diff --git a/src/session.py b/src/session.py index 6438c518e..52f7b6045 100644 --- a/src/session.py +++ b/src/session.py @@ -203,7 +203,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): if not contact: # contact is not in the roster, create a fake one to display # notification - contact = gajim.contacts.create_contact(jid=jid, account=self.conn.name, resource=resource) + contact = gajim.contacts.create_not_in_roster_contact(jid=jid, + account=self.conn.name, resource=resource) advanced_notif_num = notify.get_advanced_notification('message_received', self.conn.name, contact)