we can now invite to new room
This commit is contained in:
parent
c16d1bff63
commit
65d57253c9
|
@ -84,6 +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
|
||||||
# END __init__
|
# END __init__
|
||||||
|
|
||||||
def build_user_nick(self, user_nick):
|
def build_user_nick(self, user_nick):
|
||||||
|
|
|
@ -724,11 +724,15 @@ class ConnectionDisco:
|
||||||
qc = iq_obj.getQueryChildren()
|
qc = iq_obj.getQueryChildren()
|
||||||
if not qc:
|
if not qc:
|
||||||
qc = []
|
qc = []
|
||||||
|
is_muc = False
|
||||||
for i in qc:
|
for i in qc:
|
||||||
if i.getName() == 'identity':
|
if i.getName() == 'identity':
|
||||||
attr = {}
|
attr = {}
|
||||||
for key in i.getAttrs().keys():
|
for key in i.getAttrs().keys():
|
||||||
attr[key] = i.getAttr(key)
|
attr[key] = i.getAttr(key)
|
||||||
|
if attr.has_key('category') and attr['category'] == 'conference' \
|
||||||
|
and attr.has_key('type') and attr['type'] == 'text':
|
||||||
|
is_muc = True
|
||||||
identities.append(attr)
|
identities.append(attr)
|
||||||
elif i.getName() == 'feature':
|
elif i.getName() == 'feature':
|
||||||
features.append(i.getAttr('var'))
|
features.append(i.getAttr('var'))
|
||||||
|
@ -742,6 +746,8 @@ class ConnectionDisco:
|
||||||
if id[0] == 'p':
|
if id[0] == 'p':
|
||||||
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:
|
||||||
|
self.muc_jid = jid
|
||||||
self.dispatch('AGENT_INFO_INFO', (jid, node, identities,
|
self.dispatch('AGENT_INFO_INFO', (jid, node, identities,
|
||||||
features, data))
|
features, data))
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ encrypted_chats = {} # list of encrypted chats {acct1: [jid1, jid2], ..}
|
||||||
contacts = Contacts()
|
contacts = Contacts()
|
||||||
gc_connected = {} # tell if we are connected to the room or not {acct: {room_jid: True}}
|
gc_connected = {} # tell if we are connected to the room or not {acct: {room_jid: True}}
|
||||||
gc_passwords = {} # list of the pass required to enter a room {room_jid: password}
|
gc_passwords = {} # list of the pass required to enter a room {room_jid: password}
|
||||||
|
automatic_rooms = {} # list of rooms that must be automaticaly configured and for which we have a list of invities {account: {room_jid: {'invities': []}}}
|
||||||
|
|
||||||
groups = {} # list of groups
|
groups = {} # list of groups
|
||||||
newly_added = {} # list of contacts that has just signed in
|
newly_added = {} # list of contacts that has just signed in
|
||||||
|
|
|
@ -923,8 +923,13 @@ class SubscriptionRequestWindow:
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
||||||
class JoinGroupchatWindow:
|
class JoinGroupchatWindow:
|
||||||
def __init__(self, account, server = '', room = '', nick = ''):
|
def __init__(self, account, server = '', room = '', nick = '',
|
||||||
|
automatic = False):
|
||||||
|
'''automatic is a dict like {'invities': []}
|
||||||
|
If automatic is not empty, this means room must be automaticaly configured
|
||||||
|
and when done, invities must be automatically invited'''
|
||||||
self.account = account
|
self.account = account
|
||||||
|
self.automatic = automatic
|
||||||
if nick == '':
|
if nick == '':
|
||||||
nick = gajim.nicks[self.account]
|
nick = gajim.nicks[self.account]
|
||||||
if gajim.connections[account].connected < 2:
|
if gajim.connections[account].connected < 2:
|
||||||
|
@ -1026,10 +1031,12 @@ _('You can not join a group chat unless you are connected.'))
|
||||||
|
|
||||||
def on_join_button_clicked(self, widget):
|
def on_join_button_clicked(self, widget):
|
||||||
'''When Join button is clicked'''
|
'''When Join button is clicked'''
|
||||||
nickname = self.xml.get_widget('nickname_entry').get_text().decode('utf-8')
|
nickname = self.xml.get_widget('nickname_entry').get_text().decode(
|
||||||
|
'utf-8')
|
||||||
room = self.xml.get_widget('room_entry').get_text().decode('utf-8')
|
room = self.xml.get_widget('room_entry').get_text().decode('utf-8')
|
||||||
server = self.xml.get_widget('server_entry').get_text().decode('utf-8')
|
server = self.xml.get_widget('server_entry').get_text().decode('utf-8')
|
||||||
password = self.xml.get_widget('password_entry').get_text().decode('utf-8')
|
password = self.xml.get_widget('password_entry').get_text().decode(
|
||||||
|
'utf-8')
|
||||||
jid = '%s@%s' % (room, server)
|
jid = '%s@%s' % (room, server)
|
||||||
try:
|
try:
|
||||||
jid = helpers.parse_jid(jid)
|
jid = helpers.parse_jid(jid)
|
||||||
|
@ -1045,6 +1052,8 @@ _('You can not join a group chat unless you are connected.'))
|
||||||
self.recently_groupchat = self.recently_groupchat[0:10]
|
self.recently_groupchat = self.recently_groupchat[0:10]
|
||||||
gajim.config.set('recently_groupchat', ' '.join(self.recently_groupchat))
|
gajim.config.set('recently_groupchat', ' '.join(self.recently_groupchat))
|
||||||
|
|
||||||
|
if self.automatic:
|
||||||
|
gajim.automatic_rooms[self.account][jid] = self.automatic
|
||||||
gajim.interface.roster.join_gc_room(self.account, jid, nickname, password)
|
gajim.interface.roster.join_gc_room(self.account, jid, nickname, password)
|
||||||
|
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
17
src/gajim.py
17
src/gajim.py
|
@ -899,10 +899,18 @@ class Interface:
|
||||||
|
|
||||||
def handle_event_gc_config(self, account, array):
|
def handle_event_gc_config(self, account, array):
|
||||||
#('GC_CONFIG', account, (jid, config)) config is a dict
|
#('GC_CONFIG', account, (jid, config)) config is a dict
|
||||||
jid = array[0].split('/')[0]
|
room_jid = array[0].split('/')[0]
|
||||||
if not self.instances[account]['gc_config'].has_key(jid):
|
if room_jid in gajim.automatic_rooms[account]:
|
||||||
self.instances[account]['gc_config'][jid] = \
|
# use default configuration
|
||||||
config.GroupchatConfigWindow(account, jid, array[1])
|
gajim.connections[account].send_gc_config(room_jid, array[1])
|
||||||
|
# invite contacts
|
||||||
|
if gajim.automatic_rooms[account][room_jid].has_key('invities'):
|
||||||
|
for jid in gajim.automatic_rooms[account][room_jid]['invities']:
|
||||||
|
gajim.connections[account].send_invite(room_jid, jid)
|
||||||
|
del gajim.automatic_rooms[account][room_jid]
|
||||||
|
elif not self.instances[account]['gc_config'].has_key(room_jid):
|
||||||
|
self.instances[account]['gc_config'][room_jid] = \
|
||||||
|
config.GroupchatConfigWindow(account, room_jid, array[1])
|
||||||
|
|
||||||
def handle_event_gc_affiliation(self, account, array):
|
def handle_event_gc_affiliation(self, account, array):
|
||||||
#('GC_AFFILIATION', account, (room_jid, affiliation, list)) list is list
|
#('GC_AFFILIATION', account, (room_jid, affiliation, list)) list is list
|
||||||
|
@ -1840,6 +1848,7 @@ class Interface:
|
||||||
gajim.contacts.add_account(a)
|
gajim.contacts.add_account(a)
|
||||||
gajim.groups[a] = {}
|
gajim.groups[a] = {}
|
||||||
gajim.gc_connected[a] = {}
|
gajim.gc_connected[a] = {}
|
||||||
|
gajim.automatic_rooms[a] = {}
|
||||||
gajim.newly_added[a] = []
|
gajim.newly_added[a] = []
|
||||||
gajim.to_be_removed[a] = []
|
gajim.to_be_removed[a] = []
|
||||||
gajim.awaiting_events[a] = {}
|
gajim.awaiting_events[a] = {}
|
||||||
|
|
|
@ -1393,24 +1393,30 @@ class RosterWindow:
|
||||||
send_single_message_menuitem.connect('activate',
|
send_single_message_menuitem.connect('activate',
|
||||||
self.on_send_single_message_menuitem_activate, account, contact)
|
self.on_send_single_message_menuitem_activate, account, contact)
|
||||||
|
|
||||||
|
submenu = gtk.Menu()
|
||||||
|
invite_menuitem.set_submenu(submenu)
|
||||||
|
menuitem = gtk.ImageMenuItem(_('_New room'))
|
||||||
|
icon = gtk.image_new_from_stock(gtk.STOCK_NEW, gtk.ICON_SIZE_MENU)
|
||||||
|
menuitem.set_image(icon)
|
||||||
|
menuitem.connect('activate', self.on_invite_to_new_room, [(contact,
|
||||||
|
account)])
|
||||||
|
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(
|
||||||
message_control.TYPE_GC):
|
message_control.TYPE_GC):
|
||||||
acct = gc_control.account
|
account = 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[account].has_key(room_jid) and \
|
||||||
gajim.gc_connected[acct][room_jid]:
|
gajim.gc_connected[account][room_jid]:
|
||||||
rooms.append((room_jid, acct))
|
rooms.append((room_jid, account))
|
||||||
if len(rooms):
|
if len(rooms):
|
||||||
submenu = gtk.Menu()
|
item = gtk.SeparatorMenuItem() # separator
|
||||||
invite_menuitem.set_submenu(submenu)
|
submenu.append(item)
|
||||||
for (room_jid, acct) in rooms:
|
for (room_jid, acct) in rooms:
|
||||||
menuitem = gtk.MenuItem(room_jid.split('@')[0])
|
menuitem = gtk.MenuItem(room_jid.split('@')[0])
|
||||||
menuitem.connect('activate', self.on_invite_to_room,
|
menuitem.connect('activate', self.on_invite_to_room,
|
||||||
[(contact, account)], room_jid, acct)
|
[(contact, account)], room_jid, acct)
|
||||||
submenu.append(menuitem)
|
submenu.append(menuitem)
|
||||||
else:
|
|
||||||
invite_menuitem.set_sensitive(False)
|
|
||||||
rename_menuitem.connect('activate', self.on_rename, iter, path)
|
rename_menuitem.connect('activate', self.on_rename, iter, path)
|
||||||
remove_from_roster_menuitem.connect('activate', self.on_req_usub,
|
remove_from_roster_menuitem.connect('activate', self.on_req_usub,
|
||||||
[(contact, account)])
|
[(contact, account)])
|
||||||
|
@ -1480,8 +1486,6 @@ class RosterWindow:
|
||||||
remove_from_roster_menuitem]:
|
remove_from_roster_menuitem]:
|
||||||
widget.set_sensitive(False)
|
widget.set_sensitive(False)
|
||||||
|
|
||||||
#FIXME: create menu for sub contacts
|
|
||||||
|
|
||||||
event_button = gtkgui_helpers.get_possible_button_event(event)
|
event_button = gtkgui_helpers.get_possible_button_event(event)
|
||||||
|
|
||||||
roster_contact_context_menu.attach_to_widget(self.tree, None)
|
roster_contact_context_menu.attach_to_widget(self.tree, None)
|
||||||
|
@ -1492,10 +1496,28 @@ class RosterWindow:
|
||||||
event.time)
|
event.time)
|
||||||
|
|
||||||
def on_invite_to_new_room(self, widget, list_):
|
def on_invite_to_new_room(self, widget, list_):
|
||||||
print 'TODO: create a new room'
|
account_list = []
|
||||||
# Create room
|
jid_list = []
|
||||||
# configure room
|
for (contact, account) in list_:
|
||||||
# send invitations
|
if contact.jid not in jid_list:
|
||||||
|
jid_list.append(contact.jid)
|
||||||
|
if account not in account_list:
|
||||||
|
account_list.append(account)
|
||||||
|
for account in account_list:
|
||||||
|
if gajim.connections[account].muc_jid:
|
||||||
|
# create invities list
|
||||||
|
|
||||||
|
# create the room on this muc server
|
||||||
|
if gajim.interface.instances[account].has_key('join_gc'):
|
||||||
|
gajim.interface.instances[account]['join_gc'].window.destroy()
|
||||||
|
try:
|
||||||
|
gajim.interface.instances[account]['join_gc'] = \
|
||||||
|
dialogs.JoinGroupchatWindow(account,
|
||||||
|
server = gajim.connections[account].muc_jid,
|
||||||
|
automatic = {'invities': jid_list})
|
||||||
|
except RuntimeError:
|
||||||
|
continue
|
||||||
|
break
|
||||||
|
|
||||||
def on_invite_to_room(self, widget, list_, room_jid, account):
|
def on_invite_to_room(self, widget, list_, room_jid, account):
|
||||||
for (contact, acct) in list_:
|
for (contact, acct) in list_:
|
||||||
|
|
Loading…
Reference in New Issue