Make it explicit whether an ordinary Contact, a Self Contact or a Not-In-Roster Contact is created.
This commit is contained in:
		
							parent
							
								
									a87693c735
								
							
						
					
					
						commit
						17af7902e4
					
				
					 6 changed files with 35 additions and 23 deletions
				
			
		| 
						 | 
				
			
			@ -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,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue