Move method close to data.
gajim.contacts.contact_from_gc_contact(gc_contact) is now gc_contact.as_contact()
This commit is contained in:
parent
dec25246df
commit
89b1c6a7df
4 changed files with 19 additions and 20 deletions
|
@ -2750,7 +2750,7 @@ class ChatControl(ChatControlBase):
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(
|
contact = gajim.contacts.get_contact_with_highest_priority(
|
||||||
self.account, self.contact.jid)
|
self.account, self.contact.jid)
|
||||||
if isinstance(contact, GC_Contact):
|
if isinstance(contact, GC_Contact):
|
||||||
contact = gajim.contacts.contact_from_gc_contact(contact)
|
contact = contact.as_contact()
|
||||||
if contact:
|
if contact:
|
||||||
self.contact = contact
|
self.contact = contact
|
||||||
self.draw_banner()
|
self.draw_banner()
|
||||||
|
|
|
@ -208,6 +208,12 @@ class GC_Contact(CommonContact):
|
||||||
def get_shown_name(self):
|
def get_shown_name(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def as_contact(self):
|
||||||
|
'''Create a Contact instance from this GC_Contact instance'''
|
||||||
|
return Contact(jid=self.get_full_jid(), account=self.account,
|
||||||
|
resource=self.resource, name=self.name, groups=[], show=self.show,
|
||||||
|
status=self.status, sub='none', client_caps=self.client_caps)
|
||||||
|
|
||||||
|
|
||||||
class Contacts:
|
class Contacts:
|
||||||
'''Information concerning all contacts and groupchat contacts'''
|
'''Information concerning all contacts and groupchat contacts'''
|
||||||
|
@ -629,13 +635,6 @@ class Contacts:
|
||||||
def get_jid_list(self, account):
|
def get_jid_list(self, account):
|
||||||
return self._contacts[account].keys()
|
return self._contacts[account].keys()
|
||||||
|
|
||||||
def contact_from_gc_contact(self, gc_contact):
|
|
||||||
'''Create a Contact instance from a GC_Contact instance'''
|
|
||||||
jid = gc_contact.get_full_jid()
|
|
||||||
return Contact(jid=jid, account=gc_contact.account, resource=gc_contact.resource,
|
|
||||||
name=gc_contact.name, groups=[], show=gc_contact.show,
|
|
||||||
status=gc_contact.status, sub='none', client_caps=gc_contact.client_caps)
|
|
||||||
|
|
||||||
def create_gc_contact(self, room_jid, account, name='', show='', status='',
|
def create_gc_contact(self, room_jid, account, name='', show='', status='',
|
||||||
role='', affiliation='', jid='', resource=''):
|
role='', affiliation='', jid='', resource=''):
|
||||||
return GC_Contact(room_jid, name, show, status, role, affiliation, jid,
|
return GC_Contact(room_jid, name, show, status, role, affiliation, jid,
|
||||||
|
|
|
@ -176,7 +176,7 @@ class PrivateChatControl(ChatControl):
|
||||||
ChatControl.update_ui(self)
|
ChatControl.update_ui(self)
|
||||||
|
|
||||||
def update_contact(self):
|
def update_contact(self):
|
||||||
self.contact = gajim.contacts.contact_from_gc_contact(self.gc_contact)
|
self.contact = self.gc_contact.as_contact()
|
||||||
|
|
||||||
def begin_e2e_negotiation(self):
|
def begin_e2e_negotiation(self):
|
||||||
self.no_autonegotiation = True
|
self.no_autonegotiation = True
|
||||||
|
@ -2254,14 +2254,14 @@ class GroupchatControl(ChatControlBase):
|
||||||
|
|
||||||
def on_info(self, widget, nick):
|
def on_info(self, widget, nick):
|
||||||
'''Call vcard_information_window class to display user's information'''
|
'''Call vcard_information_window class to display user's information'''
|
||||||
c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
|
gc_contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
|
||||||
c2 = gajim.contacts.contact_from_gc_contact(c)
|
contact = gc_contact.as_contact()
|
||||||
if c2.jid in gajim.interface.instances[self.account]['infos']:
|
if contact.jid in gajim.interface.instances[self.account]['infos']:
|
||||||
gajim.interface.instances[self.account]['infos'][c2.jid].window.\
|
gajim.interface.instances[self.account]['infos'][contact.jid].window.\
|
||||||
present()
|
present()
|
||||||
else:
|
else:
|
||||||
gajim.interface.instances[self.account]['infos'][c2.jid] = \
|
gajim.interface.instances[self.account]['infos'][contact.jid] = \
|
||||||
vcard.VcardWindow(c2, self.account, c)
|
vcard.VcardWindow(contact, self.account, gc_contact)
|
||||||
|
|
||||||
def on_history(self, widget, nick):
|
def on_history(self, widget, nick):
|
||||||
jid = gajim.construct_fjid(self.room_jid, nick)
|
jid = gajim.construct_fjid(self.room_jid, nick)
|
||||||
|
|
|
@ -533,8 +533,8 @@ class Interface:
|
||||||
show = model[iter_][3]
|
show = model[iter_][3]
|
||||||
else:
|
else:
|
||||||
show = 'offline'
|
show = 'offline'
|
||||||
gc_c = gajim.contacts.create_gc_contact(room_jid = jid,
|
gc_c = gajim.contacts.create_gc_contact(room_jid=jid, account=account,
|
||||||
name = nick, show = show)
|
name=nick, show=show)
|
||||||
ctrl = self.new_private_chat(gc_c, account, session)
|
ctrl = self.new_private_chat(gc_c, account, session)
|
||||||
|
|
||||||
ctrl.print_conversation(_('Error %(code)s: %(msg)s') % {
|
ctrl.print_conversation(_('Error %(code)s: %(msg)s') % {
|
||||||
|
@ -890,7 +890,7 @@ class Interface:
|
||||||
ctrl.print_conversation(_('%(nick)s is now known as %(new_nick)s') \
|
ctrl.print_conversation(_('%(nick)s is now known as %(new_nick)s') \
|
||||||
% {'nick': nick, 'new_nick': new_nick}, 'status')
|
% {'nick': nick, 'new_nick': new_nick}, 'status')
|
||||||
gc_c = gajim.contacts.get_gc_contact(account, room_jid, new_nick)
|
gc_c = gajim.contacts.get_gc_contact(account, room_jid, new_nick)
|
||||||
c = gajim.contacts.contact_from_gc_contact(gc_c)
|
c = gc_c.as_contact()
|
||||||
ctrl.gc_contact = gc_c
|
ctrl.gc_contact = gc_c
|
||||||
ctrl.contact = c
|
ctrl.contact = c
|
||||||
if ctrl.session:
|
if ctrl.session:
|
||||||
|
@ -2223,7 +2223,7 @@ class Interface:
|
||||||
else:
|
else:
|
||||||
show = 'offline'
|
show = 'offline'
|
||||||
gc_contact = gajim.contacts.create_gc_contact(
|
gc_contact = gajim.contacts.create_gc_contact(
|
||||||
room_jid = room_jid, name = nick, show = show)
|
room_jid=room_jid, account=account, name=nick, show=show)
|
||||||
|
|
||||||
if not session:
|
if not session:
|
||||||
session = gajim.connections[account].make_new_session(
|
session = gajim.connections[account].make_new_session(
|
||||||
|
@ -2600,7 +2600,7 @@ class Interface:
|
||||||
mw.new_tab(gc_control)
|
mw.new_tab(gc_control)
|
||||||
|
|
||||||
def new_private_chat(self, gc_contact, account, session=None):
|
def new_private_chat(self, gc_contact, account, session=None):
|
||||||
contact = gajim.contacts.contact_from_gc_contact(gc_contact)
|
contact = gc_contact.as_contact()
|
||||||
type_ = message_control.TYPE_PM
|
type_ = message_control.TYPE_PM
|
||||||
fjid = gc_contact.room_jid + '/' + gc_contact.name
|
fjid = gc_contact.room_jid + '/' + gc_contact.name
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue