Make it explicit whether an ordinary Contact, a Self Contact or a Not-In-Roster Contact is created.

This commit is contained in:
Stephan Erb 2009-11-05 22:16:38 +01:00
parent a87693c735
commit 17af7902e4
6 changed files with 35 additions and 23 deletions

View File

@ -187,6 +187,7 @@ class Contact(CommonContact):
return False return False
class GC_Contact(CommonContact): class GC_Contact(CommonContact):
'''Information concerning each groupchat contact''' '''Information concerning each groupchat contact'''
def __init__(self, room_jid, account, name='', show='', status='', role='', def __init__(self, room_jid, account, name='', show='', status='', role='',
@ -261,6 +262,20 @@ class Contacts:
chatstate=chatstate, last_status_time=last_status_time, chatstate=chatstate, last_status_time=last_status_time,
composing_xep=composing_xep, mood=mood, tune=tune, activity=activity) 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): def copy_contact(self, contact):
return self.create_contact(jid=contact.jid, account=contact.account, return self.create_contact(jid=contact.jid, account=contact.account,
name=contact.name, groups=contact.groups, show=contact.show, status=contact.status, name=contact.name, groups=contact.groups, show=contact.show, status=contact.status,

View File

@ -1888,9 +1888,7 @@ class SubscriptionRequestWindow:
if self.jid in gajim.interface.instances[self.account]['infos']: if self.jid in gajim.interface.instances[self.account]['infos']:
gajim.interface.instances[self.account]['infos'][self.jid].window.present() gajim.interface.instances[self.account]['infos'][self.jid].window.present()
else: else:
contact = gajim.contacts.create_contact(jid=self.jid, account=self.account, name='', contact = gajim.contacts.create_contact(jid=self.jid, account=self.account)
groups=[], show='', status='', sub='', ask='', resource='',
priority=5, keyID='', our_chatstate=None, chatstate=None)
gajim.interface.instances[self.account]['infos'][self.jid] = \ gajim.interface.instances[self.account]['infos'][self.jid] = \
vcard.VcardWindow(contact, self.account) vcard.VcardWindow(contact, self.account)
# Remove jabber page # Remove jabber page

View File

@ -344,11 +344,9 @@ class Interface:
# Ignore offline presence of unknown self resource # Ignore offline presence of unknown self resource
if new_show < 2: if new_show < 2:
return return
contact1 = gajim.contacts.create_contact(jid=ji, account=account, contact1 = gajim.contacts.create_self_contact(jid=ji,
name=gajim.nicks[account], groups=['self_contact'], account=account, show=array[1], status=status_message,
show=array[1], status=status_message, sub='both', ask='none', priority=priority, keyID=keyID, resource=resource)
priority=priority, keyID=keyID, resource=resource,
mood=conn.mood, tune=conn.tune, activity=conn.activity)
old_show = 0 old_show = 0
gajim.contacts.add_contact(account, contact1) gajim.contacts.add_contact(account, contact1)
lcontact.append(contact1) lcontact.append(contact1)
@ -1353,9 +1351,8 @@ class Interface:
'attached_gpg_keys').split() 'attached_gpg_keys').split()
if jid in attached_keys: if jid in attached_keys:
keyID = attached_keys[attached_keys.index(jid) + 1] keyID = attached_keys[attached_keys.index(jid) + 1]
contact = gajim.contacts.create_contact(jid=jid, account=account, name='', contact = gajim.contacts.create_not_in_roster_contact(jid=jid,
groups=[_('Not in Roster')], show='not in roster', status='', account=account, keyID=keyID)
sub='none', keyID=keyID)
gajim.contacts.add_contact(account, contact) gajim.contacts.add_contact(account, contact)
self.roster.add_contact(contact.jid, account) self.roster.add_contact(contact.jid, account)
file_props = array[1] file_props = array[1]
@ -2567,6 +2564,7 @@ class Interface:
account): account):
# Join new groupchat # Join new groupchat
if minimize: if minimize:
#GCMIN
contact = gajim.contacts.create_contact(jid=room_jid, account=account, name=nick) contact = gajim.contacts.create_contact(jid=room_jid, account=account, name=nick)
gc_control = GroupchatControl(None, contact, account) gc_control = GroupchatControl(None, contact, account)
gajim.interface.minimized_controls[account][room_jid] = gc_control 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): def new_room(self, room_jid, nick, account, is_continued=False):
# Get target window, create a control, and associate it with the window # 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) contact = gajim.contacts.create_contact(jid=room_jid, account=account, name=nick)
mw = self.msg_win_mgr.get_window(contact.jid, account) mw = self.msg_win_mgr.get_window(contact.jid, account)
if not mw: if not mw:

View File

@ -806,6 +806,7 @@ class RosterWindow:
else: else:
name = jid.split('@')[0] name = jid.split('@')[0]
# New groupchat # New groupchat
#GCMIN
contact = gajim.contacts.create_contact(jid=jid, account=account, name=name, contact = gajim.contacts.create_contact(jid=jid, account=account, name=name,
groups=[_('Groupchats')], show=show, status=status, sub='none') groups=[_('Groupchats')], show=show, status=status, sub='none')
gajim.contacts.add_contact(account, contact) gajim.contacts.add_contact(account, contact)
@ -841,6 +842,7 @@ class RosterWindow:
Return the added contact instance.''' Return the added contact instance.'''
contact = gajim.contacts.get_contact_with_highest_priority(account, jid) contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
if contact is None: if contact is None:
#TRANSP
contact = gajim.contacts.create_contact(jid=jid, account=account, name=jid, contact = gajim.contacts.create_contact(jid=jid, account=account, name=jid,
groups=[_('Transports')], show='offline', status='offline', groups=[_('Transports')], show='offline', status='offline',
sub='from') sub='from')
@ -982,9 +984,8 @@ class RosterWindow:
'attached_gpg_keys').split() 'attached_gpg_keys').split()
if jid in attached_keys: if jid in attached_keys:
keyID = attached_keys[attached_keys.index(jid) + 1] keyID = attached_keys[attached_keys.index(jid) + 1]
contact = gajim.contacts.create_contact(jid=jid, account=account, name=nick, contact = gajim.contacts.create_not_in_roster_contact(jid=jid,
groups=[_('Not in Roster')], show='not in roster', status='', account=account, resource=resource, name=nick, keyID=keyID)
sub='none', resource=resource, keyID=keyID)
gajim.contacts.add_contact(account, contact) gajim.contacts.add_contact(account, contact)
self.add_contact(contact.jid, account) self.add_contact(contact.jid, account)
return contact return contact
@ -1772,6 +1773,7 @@ class RosterWindow:
if gajim.jid_is_transport(jid): if gajim.jid_is_transport(jid):
array[jid]['groups'] = [_('Transports')] array[jid]['groups'] = [_('Transports')]
#TRANSP - potential
contact1 = gajim.contacts.create_contact(jid=ji, account=account, name=name, contact1 = gajim.contacts.create_contact(jid=ji, account=account, name=name,
groups=array[jid]['groups'], show=show, status=status, groups=array[jid]['groups'], show=show, status=status,
sub=array[jid]['subscription'], ask=array[jid]['ask'], sub=array[jid]['subscription'], ask=array[jid]['ask'],
@ -2538,11 +2540,10 @@ class RosterWindow:
show = roster.getShow(jid+'/'+resource) show = roster.getShow(jid+'/'+resource)
if not show: if not show:
show = 'online' show = 'online'
contact = gajim.contacts.create_contact(jid=jid, account=account, contact = gajim.contacts.create_self_contact(jid=jid,
name=account, groups=['self_contact'], show=show, account=account, show=show, status=roster.getStatus(jid + '/' + resource),
status=roster.getStatus(jid + '/' + resource), priority=roster.getPriority(jid + '/' + resource),
resource=resource, resource=resource)
priority=roster.getPriority(jid + '/' + resource))
contacts.append(contact) contacts.append(contact)
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]: if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
self.tooltip.id = row self.tooltip.id = row

View File

@ -110,9 +110,7 @@ class SearchWindow:
if jid in gajim.interface.instances[self.account]['infos']: if jid in gajim.interface.instances[self.account]['infos']:
gajim.interface.instances[self.account]['infos'][jid].window.present() gajim.interface.instances[self.account]['infos'][jid].window.present()
else: else:
contact = gajim.contacts.create_contact(jid=jid, account=self.account, name='', groups=[], contact = gajim.contacts.create_contact(jid=jid, account=self.account)
show='', status='', sub='', ask='', resource='', priority=0,
keyID='', our_chatstate=None, chatstate=None)
gajim.interface.instances[self.account]['infos'][jid] = \ gajim.interface.instances[self.account]['infos'][jid] = \
vcard.VcardWindow(contact, self.account) vcard.VcardWindow(contact, self.account)

View File

@ -203,7 +203,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
if not contact: if not contact:
# contact is not in the roster, create a fake one to display # contact is not in the roster, create a fake one to display
# notification # 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', advanced_notif_num = notify.get_advanced_notification('message_received',
self.conn.name, contact) self.conn.name, contact)