allow to invite contact only to room of the same type (jabber contact to jabber rooms, MSN contacts to MSN rooms). Fixes #2199

This commit is contained in:
Yann Leboulanger 2006-08-01 18:03:52 +00:00
parent 45e7a9a1ba
commit f3297666b7
3 changed files with 48 additions and 31 deletions

View File

@ -84,7 +84,7 @@ class Connection(ConnectionHandlers):
self.on_connect_failure = None self.on_connect_failure = None
self.retrycount = 0 self.retrycount = 0
self.jids_for_auto_auth = [] # list of jid to auto-authorize self.jids_for_auto_auth = [] # list of jid to auto-authorize
self.muc_jid = None self.muc_jid = {} # jid of muc server for each transport type
self.available_transports = {} # list of available transports on this self.available_transports = {} # list of available transports on this
# server {'icq': 'icq.server.com', } # server {'icq': 'icq.server.com', }
self.vcard_supported = True self.vcard_supported = True

View File

@ -755,7 +755,8 @@ class ConnectionDisco:
if features.__contains__(common.xmpp.NS_BYTESTREAM): if features.__contains__(common.xmpp.NS_BYTESTREAM):
gajim.proxy65_manager.resolve(jid, self.connection, self.name) gajim.proxy65_manager.resolve(jid, self.connection, self.name)
if features.__contains__(common.xmpp.NS_MUC) and is_muc: if features.__contains__(common.xmpp.NS_MUC) and is_muc:
self.muc_jid = jid type_ = transport_type or 'jabber'
self.muc_jid[type_] = jid
if transport_type: if transport_type:
self.available_transports[transport_type] = jid self.available_transports[transport_type] = jid
self.dispatch('AGENT_INFO_INFO', (jid, node, identities, self.dispatch('AGENT_INFO_INFO', (jid, node, identities,

View File

@ -1413,6 +1413,10 @@ class RosterWindow:
menuitem.set_image(icon) menuitem.set_image(icon)
menuitem.connect('activate', self.on_invite_to_new_room, [(contact, menuitem.connect('activate', self.on_invite_to_new_room, [(contact,
account)]) account)])
contact_transport = gajim.get_transport_name_from_jid(contact.jid)
t = contact_transport or 'jabber'
if not gajim.connections[account].muc_jid.has_key(t):
menuitem.set_sensitive(False)
submenu.append(menuitem) submenu.append(menuitem)
rooms = [] # a list of (room_jid, account) tuple rooms = [] # a list of (room_jid, account) tuple
for gc_control in gajim.interface.msg_win_mgr.get_controls( for gc_control in gajim.interface.msg_win_mgr.get_controls(
@ -1420,7 +1424,8 @@ class RosterWindow:
acct = gc_control.account acct = gc_control.account
room_jid = gc_control.room_jid room_jid = gc_control.room_jid
if gajim.gc_connected[acct].has_key(room_jid) and \ if gajim.gc_connected[acct].has_key(room_jid) and \
gajim.gc_connected[acct][room_jid]: gajim.gc_connected[acct][room_jid] and \
contact_transport == gajim.get_transport_name_from_jid(room_jid):
rooms.append((room_jid, acct)) rooms.append((room_jid, acct))
if len(rooms): if len(rooms):
item = gtk.SeparatorMenuItem() # separator item = gtk.SeparatorMenuItem() # separator
@ -1516,17 +1521,16 @@ class RosterWindow:
jid_list.append(contact.jid) jid_list.append(contact.jid)
if account not in account_list: if account not in account_list:
account_list.append(account) account_list.append(account)
type_ = gajim.get_transport_name_from_jid(jid_list[0]) or 'jabber'
for account in account_list: for account in account_list:
if gajim.connections[account].muc_jid: if gajim.connections[account].muc_jid[type_]:
# create invities list
# create the room on this muc server # create the room on this muc server
if gajim.interface.instances[account].has_key('join_gc'): if gajim.interface.instances[account].has_key('join_gc'):
gajim.interface.instances[account]['join_gc'].window.destroy() gajim.interface.instances[account]['join_gc'].window.destroy()
try: try:
gajim.interface.instances[account]['join_gc'] = \ gajim.interface.instances[account]['join_gc'] = \
dialogs.JoinGroupchatWindow(account, dialogs.JoinGroupchatWindow(account,
server = gajim.connections[account].muc_jid, server = gajim.connections[account].muc_jid[type_],
automatic = {'invities': jid_list}) automatic = {'invities': jid_list})
except RuntimeError: except RuntimeError:
continue continue
@ -1543,6 +1547,8 @@ class RosterWindow:
list_ = [] # list of (jid, account) tuples list_ = [] # list of (jid, account) tuples
one_account_offline = False one_account_offline = False
connected_accounts = [] connected_accounts = []
contacts_transport = -1
# -1 is at start, False when not from the same, None when jabber
for iter in iters: for iter in iters:
jid = model[iter][C_JID].decode('utf-8') jid = model[iter][C_JID].decode('utf-8')
account = model[iter][C_ACCOUNT].decode('utf-8') account = model[iter][C_ACCOUNT].decode('utf-8')
@ -1552,6 +1558,11 @@ class RosterWindow:
connected_accounts.append(account) connected_accounts.append(account)
contact = gajim.contacts.get_contact_with_highest_priority(account, contact = gajim.contacts.get_contact_with_highest_priority(account,
jid) jid)
transport = gajim.get_transport_name_from_jid(contact.jid)
if contacts_transport == -1:
contacts_transport = transport
if contacts_transport != transport:
contacts_transport = False
list_.append((contact, account)) list_.append((contact, account))
menu = gtk.Menu() menu = gtk.Menu()
@ -1565,6 +1576,10 @@ class RosterWindow:
invite_item = gtk.ImageMenuItem(_('In_vite to')) invite_item = gtk.ImageMenuItem(_('In_vite to'))
icon = gtk.image_new_from_stock(gtk.STOCK_GO_BACK, gtk.ICON_SIZE_MENU) icon = gtk.image_new_from_stock(gtk.STOCK_GO_BACK, gtk.ICON_SIZE_MENU)
invite_item.set_image(icon) invite_item.set_image(icon)
if contacts_transport == False:
# they are not all from the same transport
invite_item.set_sensitive(False)
else:
sub_menu = gtk.Menu() sub_menu = gtk.Menu()
menuitem = gtk.ImageMenuItem(_('_New room')) menuitem = gtk.ImageMenuItem(_('_New room'))
@ -1578,7 +1593,8 @@ class RosterWindow:
account = gc_control.account account = gc_control.account
room_jid = gc_control.room_jid room_jid = gc_control.room_jid
if gajim.gc_connected[account].has_key(room_jid) and \ if gajim.gc_connected[account].has_key(room_jid) and \
gajim.gc_connected[account][room_jid]: gajim.gc_connected[account][room_jid] and \
contacts_transport == gajim.get_transport_name_from_jid(room_jid):
rooms.append((room_jid, account)) rooms.append((room_jid, account))
if len(rooms): if len(rooms):
item = gtk.SeparatorMenuItem() # separator item = gtk.SeparatorMenuItem() # separator