Added one unique function to src/gajim.py to add a GC bookmark.
Moved newly created auto_join_bookmarks() to good source file. Fix : -when using bookmark auto from join dialog : Action rebuild now done; Add GC sorted in list -when using gc_control->bookmark : Store password if any.
This commit is contained in:
parent
aaf31fbacd
commit
47bc1d61b4
|
@ -1718,21 +1718,10 @@ class JoinGroupchatWindow:
|
||||||
' '.join(self.recently_groupchat))
|
' '.join(self.recently_groupchat))
|
||||||
|
|
||||||
if self.xml.get_widget('auto_join_checkbutton').get_active():
|
if self.xml.get_widget('auto_join_checkbutton').get_active():
|
||||||
# create the bookmark-dict
|
# Add as bookmark, with autojoin and not minimized
|
||||||
# is it already bookmarked ?
|
name = gajim.get_nick_from_jid(room_jid)
|
||||||
room_jid_bookmarked = False
|
gajim.interface.add_gc_bookmark(self.account, name, room_jid, '1', \
|
||||||
for bmdict in gajim.connections[self.account].bookmarks:
|
'0', password, nickname)
|
||||||
if bmdict['jid'] == room_jid:
|
|
||||||
room_jid_bookmarked = True
|
|
||||||
break
|
|
||||||
if not room_jid_bookmarked:
|
|
||||||
name = gajim.get_nick_from_jid(room_jid)
|
|
||||||
bmdict = { 'name': name, 'jid': room_jid, 'autojoin': u'1',
|
|
||||||
'minimize': '0', 'password': password, 'nick': nickname,
|
|
||||||
'print_status': gajim.config.get('print_status_in_muc')}
|
|
||||||
|
|
||||||
gajim.connections[self.account].bookmarks.append(bmdict)
|
|
||||||
gajim.connections[self.account].store_bookmarks()
|
|
||||||
|
|
||||||
if self.automatic:
|
if self.automatic:
|
||||||
gajim.automatic_rooms[self.account][room_jid] = self.automatic
|
gajim.automatic_rooms[self.account][room_jid] = self.automatic
|
||||||
|
|
52
src/gajim.py
52
src/gajim.py
|
@ -1545,7 +1545,7 @@ class Interface:
|
||||||
if gajim.connections[account].connected == invisible_show:
|
if gajim.connections[account].connected == invisible_show:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.roster.auto_join_bookmarks(account)
|
self.auto_join_bookmarks(account)
|
||||||
|
|
||||||
def handle_event_file_send_error(self, account, array):
|
def handle_event_file_send_error(self, account, array):
|
||||||
jid = array[0]
|
jid = array[0]
|
||||||
|
@ -2776,7 +2776,8 @@ class Interface:
|
||||||
mc = mw.get_control(fjid, account)
|
mc = mw.get_control(fjid, account)
|
||||||
mc.user_nick = gajim.nicks[account]
|
mc.user_nick = gajim.nicks[account]
|
||||||
|
|
||||||
def on_open_chat_window(self, contact, account, resource = None, session = None):
|
def on_open_chat_window(self, contact, account, resource = None,
|
||||||
|
session = None):
|
||||||
# Get the window containing the chat
|
# Get the window containing the chat
|
||||||
fjid = contact.jid
|
fjid = contact.jid
|
||||||
if resource:
|
if resource:
|
||||||
|
@ -2959,6 +2960,53 @@ class Interface:
|
||||||
if os.path.isfile(path_to_file + '_notif_size_bw' + ext):
|
if os.path.isfile(path_to_file + '_notif_size_bw' + ext):
|
||||||
os.remove(path_to_file + '_notif_size_bw' + ext)
|
os.remove(path_to_file + '_notif_size_bw' + ext)
|
||||||
|
|
||||||
|
def auto_join_bookmarks(self, account):
|
||||||
|
'''autojoin bookmarked GCs that have 'auto join' on for this account'''
|
||||||
|
for bm in gajim.connections[account].bookmarks:
|
||||||
|
if bm['autojoin'] in ('1', 'true'):
|
||||||
|
jid = bm['jid']
|
||||||
|
if not gajim.gc_connected[account].has_key(jid) or\
|
||||||
|
not gajim.gc_connected[account][jid]:
|
||||||
|
# we are not already connected
|
||||||
|
minimize = bm['minimize'] in ('1', 'true')
|
||||||
|
gajim.interface.join_gc_room(account, jid, bm['nick'],
|
||||||
|
bm['password'], minimize = minimize)
|
||||||
|
|
||||||
|
def add_gc_bookmark(self, account, name, jid, autojoin, minimize, password,
|
||||||
|
nick):
|
||||||
|
'''add a bookmark for this account, sorted in bookmark list'''
|
||||||
|
bm = {
|
||||||
|
'name': name,
|
||||||
|
'jid': jid,
|
||||||
|
'autojoin': autojoin,
|
||||||
|
'minimize': minimize,
|
||||||
|
'password': password,
|
||||||
|
'nick': nick
|
||||||
|
}
|
||||||
|
place_found = False
|
||||||
|
index = 0
|
||||||
|
# check for duplicate entry and respect alpha order
|
||||||
|
for bookmark in gajim.connections[account].bookmarks:
|
||||||
|
if bookmark['jid'] == bm['jid']:
|
||||||
|
dialogs.ErrorDialog(
|
||||||
|
_('Bookmark already set'),
|
||||||
|
_('Group Chat "%s" is already in your bookmarks.') % bm['jid'])
|
||||||
|
return
|
||||||
|
if bookmark['name'] > bm['name']:
|
||||||
|
place_found = True
|
||||||
|
break
|
||||||
|
index += 1
|
||||||
|
if place_found:
|
||||||
|
gajim.connections[account].bookmarks.insert(index, bm)
|
||||||
|
else:
|
||||||
|
gajim.connections[account].bookmarks.append(bm)
|
||||||
|
gajim.connections[account].store_bookmarks()
|
||||||
|
self.roster.set_actions_menu_needs_rebuild()
|
||||||
|
dialogs.InformationDialog(
|
||||||
|
_('Bookmark has been added successfully'),
|
||||||
|
_('You can manage your bookmarks via Actions menu in your roster.'))
|
||||||
|
|
||||||
|
|
||||||
def create_ipython_window(self):
|
def create_ipython_window(self):
|
||||||
try:
|
try:
|
||||||
from ipython_view import IPythonView
|
from ipython_view import IPythonView
|
||||||
|
|
|
@ -1726,40 +1726,12 @@ class GroupchatControl(ChatControlBase):
|
||||||
jid)
|
jid)
|
||||||
|
|
||||||
def _on_bookmark_room_menuitem_activate(self, widget):
|
def _on_bookmark_room_menuitem_activate(self, widget):
|
||||||
bm = {
|
'''bookmark the room, without autojoin and not minimized'''
|
||||||
'name': self.name,
|
password = ''
|
||||||
'jid': self.room_jid,
|
if gajim.gc_passwords.has_key(self.room_jid):
|
||||||
'autojoin': '0',
|
password = gajim.gc_passwords[self.room_jid]
|
||||||
'minimize': '0',
|
gajim.interface.add_gc_bookmark(self.account, self.name, self.room_jid, \
|
||||||
'password': '',
|
'0', '0', password, self.nick)
|
||||||
'nick': self.nick
|
|
||||||
}
|
|
||||||
|
|
||||||
place_found = False
|
|
||||||
index = 0
|
|
||||||
# check for duplicate entry and respect alpha order
|
|
||||||
for bookmark in gajim.connections[self.account].bookmarks:
|
|
||||||
if bookmark['jid'] == bm['jid']:
|
|
||||||
dialogs.ErrorDialog(
|
|
||||||
_('Bookmark already set'),
|
|
||||||
_('Group Chat "%s" is already in your bookmarks.') % bm['jid'])
|
|
||||||
return
|
|
||||||
if bookmark['name'] > bm['name']:
|
|
||||||
place_found = True
|
|
||||||
break
|
|
||||||
index += 1
|
|
||||||
|
|
||||||
if place_found:
|
|
||||||
gajim.connections[self.account].bookmarks.insert(index, bm)
|
|
||||||
else:
|
|
||||||
gajim.connections[self.account].bookmarks.append(bm)
|
|
||||||
|
|
||||||
gajim.connections[self.account].store_bookmarks()
|
|
||||||
gajim.interface.roster.set_actions_menu_needs_rebuild()
|
|
||||||
|
|
||||||
dialogs.InformationDialog(
|
|
||||||
_('Bookmark has been added successfully'),
|
|
||||||
_('You can manage your bookmarks via Actions menu in your roster.'))
|
|
||||||
|
|
||||||
def _on_drag_data_received(self, widget, context, x, y, selection,
|
def _on_drag_data_received(self, widget, context, x, y, selection,
|
||||||
target_type, timestamp):
|
target_type, timestamp):
|
||||||
|
|
|
@ -1693,7 +1693,7 @@ class RosterWindow:
|
||||||
gc_control.room_jid, None)
|
gc_control.room_jid, None)
|
||||||
if was_invisible and status != 'offline':
|
if was_invisible and status != 'offline':
|
||||||
# We come back from invisible, join bookmarks
|
# We come back from invisible, join bookmarks
|
||||||
self.auto_join_bookmarks(account)
|
gajim.interface.auto_join_bookmarks(account)
|
||||||
|
|
||||||
def chg_contact_status(self, contact, show, status, account):
|
def chg_contact_status(self, contact, show, status, account):
|
||||||
'''When a contact changes his or her status'''
|
'''When a contact changes his or her status'''
|
||||||
|
|
Loading…
Reference in New Issue