create Contact instances with the new functions

This commit is contained in:
Yann Leboulanger 2005-12-21 13:00:56 +00:00
parent f67351a263
commit 0af7e48bf1
3 changed files with 46 additions and 58 deletions

View File

@ -39,7 +39,6 @@ import gtkgui_helpers
import history_window
import tooltips
from gajim import Contact
from common import gajim
from common import helpers
from gettext import ngettext
@ -370,12 +369,9 @@ class GroupchatWindow(chat.Chat):
role_name = helpers.get_uf_role(role, plural = True)
if jid:
jids = jid.split('/', 1)
j = jids[0]
if len(jids) > 1:
resource = jids[1]
jid = jid.split('/', 1)[0]
else:
j = ''
jid = ''
name = nick
@ -387,8 +383,9 @@ class GroupchatWindow(chat.Chat):
iter = model.append(role_iter, (None, 'contact', nick, name))
if not gajim.gc_contacts[self.account][room_jid].has_key(nick):
gajim.gc_contacts[self.account][room_jid][nick] = \
Contact(jid = j, name = nick, show = show, resource = resource,
role = role, affiliation = affiliation, status = status)
gajim.contacts.create_gc_contact(room_jid = room_jid, nick = nick,
show = show, status = status, role = role,
affiliation = affiliation, jid = jid)
self.draw_contact(room_jid, nick)
if nick == self.nicks[room_jid]: # we became online
self.got_connected(room_jid)
@ -1174,9 +1171,7 @@ current room topic.') % command, room_jid)
gajim.interface.instances[self.account]['infos'][jid].window.present()
else:
# we copy contact because c.jid must contain the fakeJid for vcard
c2 = Contact(jid = jid, name = c.name, groups = c.groups,
show = c.show, status = c.status, sub = c.sub,
resource = c.resource, role = c.role, affiliation = c.affiliation)
c2 = gajim.contacts.contact_from_gc_contact(c)
gajim.interface.instances[self.account]['infos'][jid] = \
vcard.VcardWindow(c2, self.account, False)
@ -1195,10 +1190,8 @@ current room topic.') % command, room_jid)
room_jid = self.get_active_jid()
fjid = gajim.construct_fjid(room_jid, nick) # 'fake' jid
if not gajim.interface.instances[self.account]['chats'].has_key(fjid):
show = gajim.gc_contacts[self.account][room_jid][nick].show
u = Contact(jid = fjid, name = nick, groups = ['none'], show = show,
sub = 'none')
gajim.interface.roster.new_chat(u, self.account)
gc_c = gajim.gc_contacts[self.account][room_jid][nick]
gajim.interface.roster.new_chat(gc_c, self.account)
#make active here in case we need to send a message
gajim.interface.instances[self.account]['chats'][fjid].set_active_tab(fjid)
@ -1525,10 +1518,8 @@ current room topic.') % command, room_jid)
gajim.interface.systray.add_jid(fjid, self.account, 'pm')
self.show_title()
else:
show = gajim.gc_contacts[self.account][room_jid][nick].show
c = Contact(jid = fjid, name = nick, groups = ['none'], show = show,
ask = 'none')
gajim.interface.roster.new_chat(c, self.account)
gc_c = gajim.gc_contacts[self.account][room_jid][nick]
gajim.interface.roster.new_chat(gc_c, self.account)
# Scroll to line
self.list_treeview[room_jid].expand_row(path[0:1], False)
self.list_treeview[room_jid].scroll_to_cell(path)
@ -1636,10 +1627,8 @@ current room topic.') % command, room_jid)
nick = model[iter][C_NICK].decode('utf-8')
fjid = gajim.construct_fjid(room_jid, nick)
if not gajim.interface.instances[self.account]['chats'].has_key(fjid):
show = gajim.gc_contacts[self.account][room_jid][nick].show
u = Contact(jid = fjid, name = nick, groups = ['none'],
show = show, sub = 'none')
gajim.interface.roster.new_chat(u, self.account)
gc_c = gajim.gc_contacts[self.account][room_jid][nick]
gajim.interface.roster.new_chat(gc_c, self.account)
gajim.interface.instances[self.account]['chats'][fjid].set_active_tab(fjid)
gajim.interface.instances[self.account]['chats'][fjid].window.present()
return True
@ -1680,10 +1669,8 @@ current room topic.') % command, room_jid)
nick = model[iter][C_NICK].decode('utf-8')
jid = gajim.construct_fjid(room_jid, nick)
if not gajim.interface.instances[self.account]['chats'].has_key(jid):
show = gajim.gc_contacts[self.account][room_jid][nick].show
contact = Contact(jid = jid, name = nick, groups = ['none'],
show = show, sub = 'none')
gajim.interface.roster.new_chat(contact, self.account)
gc_c = gajim.gc_contacts[self.account][room_jid][nick]
gajim.interface.roster.new_chat(gc_c, self.account)
jid = contact.jid
gajim.interface.instances[self.account]['chats'][jid].set_active_tab(jid)
gajim.interface.instances[self.account]['chats'][jid].window.present()

View File

@ -42,7 +42,6 @@ import gtkgui_helpers
import cell_renderer_image
import tooltips
from gajim import Contact
from common import gajim
from common import helpers
from common import i18n
@ -204,10 +203,10 @@ class RosterWindow:
self.draw_avatar(jid, account)
def add_transport_to_roster(self, account, transport):
user1 = Contact(jid = transport, name = transport,
c = gajim.contacts.create_contact(jid = transport, name = transport,
groups = [_('Transports')], show = 'offline', status = 'offline',
sub = 'from')
gajim.contacts[account][transport] = [user1]
gajim.contacts[account][transport] = [c]
gajim.interface.roster.add_contact_to_roster(transport, account)
def really_remove_contact(self, user, account):
@ -668,9 +667,10 @@ class RosterWindow:
'attached_gpg_keys').split()
if jid in attached_keys:
keyID = attached_keys[attached_keys.index(jid) + 1]
contact1 = Contact(jid = ji, name = name, groups = array[jid]['groups'],
show = show, status = status, sub = array[jid]['subscription'],
ask = array[jid]['ask'], resource = resource, keyID = keyID)
contact1 = gajim.contacts.create_contact(jid = ji, name = name,
groups = array[jid]['groups'], show = show, status = status,
sub = array[jid]['subscription'], ask = array[jid]['ask'],
resource = resource, keyID = keyID)
# when we draw the roster, we avoid having the same contact
# more than once (f.e. we avoid showing it twice when 2 resources)
@ -790,9 +790,8 @@ class RosterWindow:
contacts = []
connection = gajim.connections[account]
# get our current contact info
contact = Contact(jid = jid, name = account,
show = connection.get_status(),
sub = 'both',
contact = gajim.contacts.create_contact(jid = jid, name = account,
show = connection.get_status(), sub = 'both',
status = connection.status,
resource = gajim.config.get_per('accounts', connection.name,
'resource'),
@ -811,10 +810,11 @@ class RosterWindow:
show = roster.getShow(jid+'/'+resource)
if not show:
show = 'online'
contact = Contact(jid=jid, name=account,
show=show,
status=roster.getStatus(jid+'/'+resource), resource=resource,
priority=roster.getPriority(jid+'/'+resource))
contact = gajim.contacts.create_contact(jid = jid,
name = account, show = show,
status = roster.getStatus(jid+'/'+resource),
resource = resource,
priority = roster.getPriority(jid+'/'+resource))
contacts.append(contact)
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
self.tooltip.id = row
@ -1248,19 +1248,19 @@ class RosterWindow:
'attached_gpg_keys').split()
if jid in attached_keys:
keyID = attached_keys[attached_keys.index(jid) + 1]
user1 = Contact(jid = jid, name = pseudo, groups = [group],
show = 'requested', status = '', ask = 'none',
c = gajim.contacts.create_contact(jid = jid, name = pseudo,
groups = [group], show = 'requested', status = '', ask = 'none',
sub = 'subscribe', keyID = keyID)
gajim.contacts[account][jid] = [user1]
gajim.contacts[account][jid] = [c]
else:
user1 = gajim.get_contact_instance_with_highest_priority(account, jid)
if not _('not in the roster') in user1.groups:
c = gajim.get_contact_instance_with_highest_priority(account, jid)
if not _('not in the roster') in c.groups:
dialogs.InformationDialog(_('Subscription request has been sent'),
_('If "%s" accepts this request you will know his or her status.') %jid)
return
user1.groups = [group]
user1.name = pseudo
self.remove_contact(user1, account)
c.groups = [group]
c.name = pseudo
self.remove_contact(c, account)
self.add_contact_to_roster(jid, account)
def revoke_auth(self, widget, jid, account):
@ -1425,10 +1425,10 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
self.remove_contact(u, account)
del gajim.contacts[account][u.jid]
if user.jid in gajim.interface.instances[account]['chats']:
user1 = Contact(jid = user.jid, name = user.name,
c = gajim.contacts.create_contact(jid = user.jid, name = user.name,
groups = [_('not in the roster')], show = 'not in the roster',
status = '', ask = 'none', keyID = user.keyID)
gajim.contacts[account][user.jid] = [user1]
gajim.contacts[account][user.jid] = [c]
self.add_contact_to_roster(user.jid, account)
def forget_gpg_passphrase(self, keyid):
@ -1674,9 +1674,10 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
'attached_gpg_keys').split()
if jid in attached_keys:
keyID = attached_keys[attached_keys.index(jid) + 1]
contact = Contact(jid = jid, name = jid.split('@')[0],
groups = [_('not in the roster')], show = 'not in the roster',
status = '', sub = 'none', keyID = keyID)
contact = gajim.contacts.create_contact(jid = jid,
name = jid.split('@')[0], groups = [_('not in the roster')],
show = 'not in the roster', status = '', sub = 'none',
keyID = keyID)
gajim.contacts[account][jid] = [contact]
self.add_contact_to_roster(contact.jid, account)
@ -1707,10 +1708,11 @@ _('If "%s" accepts this request you will know his or her status.') %jid)
'attached_gpg_keys').split()
if jid in attached_keys:
keyID = attached_keys[attached_keys.index(jid) + 1]
user1 = Contact(jid = jid, name = jid.split('@')[0],
groups = [_('not in the roster')], show = 'not in the roster',
status = '', ask = 'none', keyID = keyID, resource = resource)
gajim.contacts[account][jid] = [user1]
c = gajim.contacts.create_contact(jid = jid,
name = jid.split('@')[0], groups = [_('not in the roster')],
show = 'not in the roster', status = '', ask = 'none',
keyID = keyID, resource = resource)
gajim.contacts[account][jid] = [c]
self.add_contact_to_roster(jid, account)
iters = self.get_contact_iter(jid, account)

View File

@ -33,7 +33,6 @@ import os
import tooltips
import gtkgui_helpers
from gajim import Contact
from common import gajim
from common import helpers
from common import i18n