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:
Jean-Marie Traissard 2008-04-20 19:45:09 +00:00
parent aaf31fbacd
commit 47bc1d61b4
4 changed files with 61 additions and 52 deletions

View File

@ -1718,21 +1718,10 @@ class JoinGroupchatWindow:
' '.join(self.recently_groupchat))
if self.xml.get_widget('auto_join_checkbutton').get_active():
# create the bookmark-dict
# is it already bookmarked ?
room_jid_bookmarked = False
for bmdict in gajim.connections[self.account].bookmarks:
if bmdict['jid'] == room_jid:
room_jid_bookmarked = True
break
if not room_jid_bookmarked:
# Add as bookmark, with autojoin and not minimized
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()
gajim.interface.add_gc_bookmark(self.account, name, room_jid, '1', \
'0', password, nickname)
if self.automatic:
gajim.automatic_rooms[self.account][room_jid] = self.automatic

View File

@ -1545,7 +1545,7 @@ class Interface:
if gajim.connections[account].connected == invisible_show:
return
self.roster.auto_join_bookmarks(account)
self.auto_join_bookmarks(account)
def handle_event_file_send_error(self, account, array):
jid = array[0]
@ -2776,7 +2776,8 @@ class Interface:
mc = mw.get_control(fjid, 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
fjid = contact.jid
if resource:
@ -2959,6 +2960,53 @@ class Interface:
if os.path.isfile(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):
try:
from ipython_view import IPythonView

View File

@ -1726,40 +1726,12 @@ class GroupchatControl(ChatControlBase):
jid)
def _on_bookmark_room_menuitem_activate(self, widget):
bm = {
'name': self.name,
'jid': self.room_jid,
'autojoin': '0',
'minimize': '0',
'password': '',
'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.'))
'''bookmark the room, without autojoin and not minimized'''
password = ''
if gajim.gc_passwords.has_key(self.room_jid):
password = gajim.gc_passwords[self.room_jid]
gajim.interface.add_gc_bookmark(self.account, self.name, self.room_jid, \
'0', '0', password, self.nick)
def _on_drag_data_received(self, widget, context, x, y, selection,
target_type, timestamp):

View File

@ -1693,7 +1693,7 @@ class RosterWindow:
gc_control.room_jid, None)
if was_invisible and status != 'offline':
# 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):
'''When a contact changes his or her status'''