Moved methods for opening new messages controls from roster.py to src/gajim.py. This is not roster related. See #3643.
Sorted src/gajim.py functions, using steve-e style :p
This commit is contained in:
parent
1846cfefc6
commit
8b8f139f79
7 changed files with 540 additions and 516 deletions
|
@ -666,7 +666,7 @@ class ConversationTextview:
|
||||||
clip.set_text(text)
|
clip.set_text(text)
|
||||||
|
|
||||||
def on_start_chat_activate(self, widget, jid):
|
def on_start_chat_activate(self, widget, jid):
|
||||||
gajim.interface.roster.new_chat_from_jid(self.account, jid)
|
gajim.interface.new_chat_from_jid(self.account, jid)
|
||||||
|
|
||||||
def on_join_group_chat_menuitem_activate(self, widget, room_jid):
|
def on_join_group_chat_menuitem_activate(self, widget, room_jid):
|
||||||
if 'join_gc' in gajim.interface.instances[self.account]:
|
if 'join_gc' in gajim.interface.instances[self.account]:
|
||||||
|
|
|
@ -1574,7 +1574,7 @@ class SubscriptionRequestWindow:
|
||||||
|
|
||||||
def on_start_chat_activate(self, widget):
|
def on_start_chat_activate(self, widget):
|
||||||
'''open chat'''
|
'''open chat'''
|
||||||
gajim.interface.roster.new_chat_from_jid(self.account, self.jid)
|
gajim.interface.new_chat_from_jid(self.account, self.jid)
|
||||||
|
|
||||||
def on_deny_button_clicked(self, widget):
|
def on_deny_button_clicked(self, widget):
|
||||||
'''refuse the request'''
|
'''refuse the request'''
|
||||||
|
@ -1736,8 +1736,7 @@ class JoinGroupchatWindow:
|
||||||
|
|
||||||
if self.automatic:
|
if self.automatic:
|
||||||
gajim.automatic_rooms[self.account][room_jid] = self.automatic
|
gajim.automatic_rooms[self.account][room_jid] = self.automatic
|
||||||
gajim.interface.roster.join_gc_room(self.account, room_jid, nickname,
|
gajim.interface.join_gc_room(self.account, room_jid, nickname, password)
|
||||||
password)
|
|
||||||
|
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
||||||
|
@ -1919,7 +1918,7 @@ class NewChatDialog(InputDialog):
|
||||||
except:
|
except:
|
||||||
ErrorDialog(_('Invalid JID'), _('Unable to parse "%s".') % jid)
|
ErrorDialog(_('Invalid JID'), _('Unable to parse "%s".') % jid)
|
||||||
return
|
return
|
||||||
gajim.interface.roster.new_chat_from_jid(self.account, jid)
|
gajim.interface.new_chat_from_jid(self.account, jid)
|
||||||
|
|
||||||
class ChangePasswordDialog:
|
class ChangePasswordDialog:
|
||||||
def __init__(self, account):
|
def __init__(self, account):
|
||||||
|
@ -2921,7 +2920,7 @@ class InvitationReceivedDialog:
|
||||||
self.dialog.destroy()
|
self.dialog.destroy()
|
||||||
try:
|
try:
|
||||||
if self.is_continued:
|
if self.is_continued:
|
||||||
gajim.interface.roster.join_gc_room(self.account, self.room_jid,
|
gajim.interface.join_gc_room(self.account, self.room_jid,
|
||||||
gajim.nicks[self.account], None, is_continued=True)
|
gajim.nicks[self.account], None, is_continued=True)
|
||||||
else:
|
else:
|
||||||
JoinGroupchatWindow(self.account, self.room_jid)
|
JoinGroupchatWindow(self.account, self.room_jid)
|
||||||
|
@ -3719,7 +3718,7 @@ class TransformChatToMUC:
|
||||||
gajim.automatic_rooms[self.account][room_jid] = {}
|
gajim.automatic_rooms[self.account][room_jid] = {}
|
||||||
gajim.automatic_rooms[self.account][room_jid]['invities'] = guest_list
|
gajim.automatic_rooms[self.account][room_jid]['invities'] = guest_list
|
||||||
gajim.automatic_rooms[self.account][room_jid]['continue_tag'] = True
|
gajim.automatic_rooms[self.account][room_jid]['continue_tag'] = True
|
||||||
gajim.interface.roster.join_gc_room(self.account, room_jid,
|
gajim.interface.join_gc_room(self.account, room_jid,
|
||||||
gajim.nicks[self.account], None, is_continued=True)
|
gajim.nicks[self.account], None, is_continued=True)
|
||||||
self.window.destroy()
|
self.window.destroy()
|
||||||
|
|
||||||
|
|
882
src/gajim.py
882
src/gajim.py
|
@ -237,6 +237,9 @@ import message_control
|
||||||
import negotiation
|
import negotiation
|
||||||
|
|
||||||
from chat_control import ChatControlBase
|
from chat_control import ChatControlBase
|
||||||
|
from chat_control import ChatControl
|
||||||
|
from groupchat_control import GroupchatControl
|
||||||
|
from groupchat_control import PrivateChatControl
|
||||||
from atom_window import AtomWindow
|
from atom_window import AtomWindow
|
||||||
|
|
||||||
import common.sleepy
|
import common.sleepy
|
||||||
|
@ -432,6 +435,11 @@ class GlibIdleQueue(idlequeue.IdleQueue):
|
||||||
self.check_time_events()
|
self.check_time_events()
|
||||||
|
|
||||||
class Interface:
|
class Interface:
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
### Methods handling events from connection
|
||||||
|
################################################################################
|
||||||
|
|
||||||
def handle_event_roster(self, account, data):
|
def handle_event_roster(self, account, data):
|
||||||
#('ROSTER', account, array)
|
#('ROSTER', account, array)
|
||||||
self.roster.fill_contacts_and_groups_dicts(data, account)
|
self.roster.fill_contacts_and_groups_dicts(data, account)
|
||||||
|
@ -903,7 +911,7 @@ class Interface:
|
||||||
show = 'offline'
|
show = 'offline'
|
||||||
gc_c = gajim.contacts.create_gc_contact(room_jid = jid,
|
gc_c = gajim.contacts.create_gc_contact(room_jid = jid,
|
||||||
name = nick, show = show)
|
name = nick, show = show)
|
||||||
self.roster.new_private_chat(gc_c, account)
|
self.new_private_chat(gc_c, account)
|
||||||
ctrl = self.msg_win_mgr.get_control(full_jid_with_resource, account)
|
ctrl = self.msg_win_mgr.get_control(full_jid_with_resource, account)
|
||||||
ctrl.print_conversation('Error %s: %s' % (array[1], array[2]),
|
ctrl.print_conversation('Error %s: %s' % (array[1], array[2]),
|
||||||
'status')
|
'status')
|
||||||
|
@ -1588,119 +1596,6 @@ class Interface:
|
||||||
if self.remote_ctrl:
|
if self.remote_ctrl:
|
||||||
self.remote_ctrl.raise_signal('NewGmail', (account, array))
|
self.remote_ctrl.raise_signal('NewGmail', (account, array))
|
||||||
|
|
||||||
def save_avatar_files(self, jid, photo, puny_nick = None, local = False):
|
|
||||||
'''Saves an avatar to a separate file, and generate files for dbus notifications. An avatar can be given as a pixmap directly or as an decoded image.'''
|
|
||||||
puny_jid = helpers.sanitize_filename(jid)
|
|
||||||
path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid)
|
|
||||||
if puny_nick:
|
|
||||||
path_to_file = os.path.join(path_to_file, puny_nick)
|
|
||||||
# remove old avatars
|
|
||||||
for typ in ('jpeg', 'png'):
|
|
||||||
if local:
|
|
||||||
path_to_original_file = path_to_file + '_local'+ '.' + typ
|
|
||||||
else:
|
|
||||||
path_to_original_file = path_to_file + '.' + typ
|
|
||||||
if os.path.isfile(path_to_original_file):
|
|
||||||
os.remove(path_to_original_file)
|
|
||||||
if local and photo:
|
|
||||||
pixbuf = photo
|
|
||||||
type = 'png'
|
|
||||||
extension = '_local.png' # save local avatars as png file
|
|
||||||
else:
|
|
||||||
pixbuf, typ = gtkgui_helpers.get_pixbuf_from_data(photo, want_type = True)
|
|
||||||
if pixbuf is None:
|
|
||||||
return
|
|
||||||
extension = '.' + typ
|
|
||||||
if typ not in ('jpeg', 'png'):
|
|
||||||
gajim.log.debug('gtkpixbuf cannot save other than jpeg and png formats. saving %s\'avatar as png file (originaly %s)' % (jid, typ))
|
|
||||||
typ = 'png'
|
|
||||||
extension = '.png'
|
|
||||||
path_to_original_file = path_to_file + extension
|
|
||||||
pixbuf.save(path_to_original_file, typ)
|
|
||||||
# Generate and save the resized, color avatar
|
|
||||||
pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'notification')
|
|
||||||
if pixbuf:
|
|
||||||
path_to_normal_file = path_to_file + '_notif_size_colored' + extension
|
|
||||||
pixbuf.save(path_to_normal_file, 'png')
|
|
||||||
# Generate and save the resized, black and white avatar
|
|
||||||
bwbuf = gtkgui_helpers.get_scaled_pixbuf(
|
|
||||||
gtkgui_helpers.make_pixbuf_grayscale(pixbuf), 'notification')
|
|
||||||
if bwbuf:
|
|
||||||
path_to_bw_file = path_to_file + '_notif_size_bw' + extension
|
|
||||||
bwbuf.save(path_to_bw_file, 'png')
|
|
||||||
|
|
||||||
def remove_avatar_files(self, jid, puny_nick = None, local = False):
|
|
||||||
'''remove avatar files of a jid'''
|
|
||||||
puny_jid = helpers.sanitize_filename(jid)
|
|
||||||
path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid)
|
|
||||||
if puny_nick:
|
|
||||||
path_to_file = os.path.join(path_to_file, puny_nick)
|
|
||||||
for ext in ('.jpeg', '.png'):
|
|
||||||
if local:
|
|
||||||
ext = '_local' + ext
|
|
||||||
path_to_original_file = path_to_file + ext
|
|
||||||
if os.path.isfile(path_to_file + ext):
|
|
||||||
os.remove(path_to_file + ext)
|
|
||||||
if os.path.isfile(path_to_file + '_notif_size_colored' + ext):
|
|
||||||
os.remove(path_to_file + '_notif_size_colored' + ext)
|
|
||||||
if os.path.isfile(path_to_file + '_notif_size_bw' + ext):
|
|
||||||
os.remove(path_to_file + '_notif_size_bw' + ext)
|
|
||||||
|
|
||||||
def add_event(self, account, jid, type_, event_args):
|
|
||||||
'''add an event to the gajim.events var'''
|
|
||||||
# We add it to the gajim.events queue
|
|
||||||
# Do we have a queue?
|
|
||||||
jid = gajim.get_jid_without_resource(jid)
|
|
||||||
no_queue = len(gajim.events.get_events(account, jid)) == 0
|
|
||||||
event_type = None
|
|
||||||
# type_ can be gc-invitation file-send-error file-error file-request-error
|
|
||||||
# file-request file-completed file-stopped
|
|
||||||
# event_type can be in advancedNotificationWindow.events_list
|
|
||||||
event_types = {'file-request': 'ft_request',
|
|
||||||
'file-completed': 'ft_finished'}
|
|
||||||
if type_ in event_types:
|
|
||||||
event_type = event_types[type_]
|
|
||||||
show_in_roster = notify.get_show_in_roster(event_type, account, jid)
|
|
||||||
show_in_systray = notify.get_show_in_systray(event_type, account, jid)
|
|
||||||
event = gajim.events.create_event(type_, event_args,
|
|
||||||
show_in_roster = show_in_roster,
|
|
||||||
show_in_systray = show_in_systray)
|
|
||||||
gajim.events.add_event(account, jid, event)
|
|
||||||
|
|
||||||
self.roster.show_title()
|
|
||||||
if no_queue: # We didn't have a queue: we change icons
|
|
||||||
if not gajim.contacts.get_contact_with_highest_priority(account, jid):
|
|
||||||
if type_ == 'gc-invitation':
|
|
||||||
self.roster.add_groupchat(account, jid,
|
|
||||||
status='offline')
|
|
||||||
else:
|
|
||||||
# add contact to roster ("Not In The Roster") if he is not
|
|
||||||
self.roster.add_to_not_in_the_roster(account, jid)
|
|
||||||
self.roster.draw_contact(jid, account)
|
|
||||||
|
|
||||||
# Show contact in roster (if he is invisible for example) and select line
|
|
||||||
self.roster.show_and_select_contact_if_having_events(jid, account)
|
|
||||||
|
|
||||||
def remove_first_event(self, account, jid, type_ = None):
|
|
||||||
event = gajim.events.get_first_event(account, jid, type_)
|
|
||||||
self.remove_event(account, jid, event)
|
|
||||||
|
|
||||||
def remove_event(self, account, jid, event):
|
|
||||||
if gajim.events.remove_events(account, jid, event):
|
|
||||||
# No such event found
|
|
||||||
return
|
|
||||||
# no other event?
|
|
||||||
if not len(gajim.events.get_events(account, jid)):
|
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(account,
|
|
||||||
jid)
|
|
||||||
show_transport = gajim.config.get('show_transports_group')
|
|
||||||
if contact and (contact.show in ('error', 'offline') and \
|
|
||||||
not gajim.config.get('showoffline') or (
|
|
||||||
gajim.jid_is_transport(jid) and not show_transport)):
|
|
||||||
self.roster.remove_contact(contact.jid, account)
|
|
||||||
self.roster.show_title()
|
|
||||||
self.roster.draw_contact(jid, account)
|
|
||||||
|
|
||||||
def handle_event_file_request_error(self, account, array):
|
def handle_event_file_request_error(self, account, array):
|
||||||
# ('FILE_REQUEST_ERROR', account, (jid, file_props, error_msg))
|
# ('FILE_REQUEST_ERROR', account, (jid, file_props, error_msg))
|
||||||
jid, file_props, errmsg = array
|
jid, file_props, errmsg = array
|
||||||
|
@ -2077,7 +1972,7 @@ class Interface:
|
||||||
# non-esession negotiation. this isn't very useful, but i'm keeping it around
|
# non-esession negotiation. this isn't very useful, but i'm keeping it around
|
||||||
# to test my test suite.
|
# to test my test suite.
|
||||||
if form.getType() == 'form':
|
if form.getType() == 'form':
|
||||||
ctrl = gajim.interface.msg_win_mgr.get_control(str(jid), account)
|
ctrl = self.msg_win_mgr.get_control(str(jid), account)
|
||||||
if not ctrl:
|
if not ctrl:
|
||||||
resource = jid.getResource()
|
resource = jid.getResource()
|
||||||
contact = gajim.contacts.get_contact(account, str(jid), resource)
|
contact = gajim.contacts.get_contact(account, str(jid), resource)
|
||||||
|
@ -2085,9 +1980,9 @@ class Interface:
|
||||||
connection = gajim.connections[account]
|
connection = gajim.connections[account]
|
||||||
contact = gajim.contacts.create_contact(jid = jid.getStripped(),
|
contact = gajim.contacts.create_contact(jid = jid.getStripped(),
|
||||||
resource = resource, show = connection.get_status())
|
resource = resource, show = connection.get_status())
|
||||||
self.roster.new_chat(contact, account, resource = resource)
|
self.new_chat(contact, account, resource = resource)
|
||||||
|
|
||||||
ctrl = gajim.interface.msg_win_mgr.get_control(str(jid), account)
|
ctrl = self.msg_win_mgr.get_control(str(jid), account)
|
||||||
|
|
||||||
ctrl.set_session(session)
|
ctrl.set_session(session)
|
||||||
|
|
||||||
|
@ -2318,89 +2213,238 @@ class Interface:
|
||||||
dialogs.WarningDialog(_('PEP node was not removed'),
|
dialogs.WarningDialog(_('PEP node was not removed'),
|
||||||
_('PEP node %s was not removed: %s') % (data[1], data[2]))
|
_('PEP node %s was not removed: %s') % (data[1], data[2]))
|
||||||
|
|
||||||
def read_sleepy(self):
|
def register_handlers(self):
|
||||||
'''Check idle status and change that status if needed'''
|
self.handlers = {
|
||||||
if not self.sleeper.poll():
|
'ROSTER': self.handle_event_roster,
|
||||||
# idle detection is not supported in that OS
|
'WARNING': self.handle_event_warning,
|
||||||
return False # stop looping in vain
|
'ERROR': self.handle_event_error,
|
||||||
state = self.sleeper.getState()
|
'INFORMATION': self.handle_event_information,
|
||||||
for account in gajim.connections:
|
'ERROR_ANSWER': self.handle_event_error_answer,
|
||||||
if not gajim.sleeper_state.has_key(account) or \
|
'STATUS': self.handle_event_status,
|
||||||
not gajim.sleeper_state[account]:
|
'NOTIFY': self.handle_event_notify,
|
||||||
continue
|
'MSG': self.handle_event_msg,
|
||||||
if state == common.sleepy.STATE_AWAKE and \
|
'MSGERROR': self.handle_event_msgerror,
|
||||||
gajim.sleeper_state[account] in ('autoaway', 'autoxa'):
|
'MSGSENT': self.handle_event_msgsent,
|
||||||
# we go online
|
'MSGNOTSENT': self.handle_event_msgnotsent,
|
||||||
self.roster.send_status(account, 'online',
|
'SUBSCRIBED': self.handle_event_subscribed,
|
||||||
gajim.status_before_autoaway[account])
|
'UNSUBSCRIBED': self.handle_event_unsubscribed,
|
||||||
gajim.status_before_autoaway[account] = ''
|
'SUBSCRIBE': self.handle_event_subscribe,
|
||||||
gajim.sleeper_state[account] = 'online'
|
'AGENT_ERROR_INFO': self.handle_event_agent_info_error,
|
||||||
elif state == common.sleepy.STATE_AWAY and \
|
'AGENT_ERROR_ITEMS': self.handle_event_agent_items_error,
|
||||||
gajim.sleeper_state[account] == 'online' and \
|
'AGENT_REMOVED': self.handle_event_agent_removed,
|
||||||
gajim.config.get('autoaway'):
|
'REGISTER_AGENT_INFO': self.handle_event_register_agent_info,
|
||||||
# we save out online status
|
'AGENT_INFO_ITEMS': self.handle_event_agent_info_items,
|
||||||
gajim.status_before_autoaway[account] = \
|
'AGENT_INFO_INFO': self.handle_event_agent_info_info,
|
||||||
gajim.connections[account].status
|
'QUIT': self.handle_event_quit,
|
||||||
# we go away (no auto status) [we pass True to auto param]
|
'NEW_ACC_CONNECTED': self.handle_event_new_acc_connected,
|
||||||
auto_message = gajim.config.get('autoaway_message')
|
'NEW_ACC_NOT_CONNECTED': self.handle_event_new_acc_not_connected,
|
||||||
if not auto_message:
|
'ACC_OK': self.handle_event_acc_ok,
|
||||||
auto_message = gajim.connections[account].status
|
'ACC_NOT_OK': self.handle_event_acc_not_ok,
|
||||||
else:
|
'MYVCARD': self.handle_event_myvcard,
|
||||||
auto_message = auto_message.replace('$S','%(status)s')
|
'VCARD': self.handle_event_vcard,
|
||||||
auto_message = auto_message.replace('$T','%(time)s')
|
'LAST_STATUS_TIME': self.handle_event_last_status_time,
|
||||||
auto_message = auto_message % {
|
'OS_INFO': self.handle_event_os_info,
|
||||||
'status': gajim.status_before_autoaway[account],
|
'GC_NOTIFY': self.handle_event_gc_notify,
|
||||||
'time': gajim.config.get('autoawaytime')
|
'GC_MSG': self.handle_event_gc_msg,
|
||||||
}
|
'GC_SUBJECT': self.handle_event_gc_subject,
|
||||||
self.roster.send_status(account, 'away', auto_message, auto=True)
|
'GC_CONFIG': self.handle_event_gc_config,
|
||||||
gajim.sleeper_state[account] = 'autoaway'
|
'GC_CONFIG_CHANGE': self.handle_event_gc_config_change,
|
||||||
elif state == common.sleepy.STATE_XA and (\
|
'GC_INVITATION': self.handle_event_gc_invitation,
|
||||||
gajim.sleeper_state[account] == 'autoaway' or \
|
'GC_AFFILIATION': self.handle_event_gc_affiliation,
|
||||||
gajim.sleeper_state[account] == 'online') and \
|
'GC_PASSWORD_REQUIRED': self.handle_event_gc_password_required,
|
||||||
gajim.config.get('autoxa'):
|
'BAD_PASSPHRASE': self.handle_event_bad_passphrase,
|
||||||
# we go extended away [we pass True to auto param]
|
'ROSTER_INFO': self.handle_event_roster_info,
|
||||||
auto_message = gajim.config.get('autoxa_message')
|
'BOOKMARKS': self.handle_event_bookmarks,
|
||||||
if not auto_message:
|
'CON_TYPE': self.handle_event_con_type,
|
||||||
auto_message = gajim.connections[account].status
|
'CONNECTION_LOST': self.handle_event_connection_lost,
|
||||||
else:
|
'FILE_REQUEST': self.handle_event_file_request,
|
||||||
auto_message = auto_message.replace('$S','%(status)s')
|
'GMAIL_NOTIFY': self.handle_event_gmail_notify,
|
||||||
auto_message = auto_message.replace('$T','%(time)s')
|
'FILE_REQUEST_ERROR': self.handle_event_file_request_error,
|
||||||
auto_message = auto_message % {
|
'FILE_SEND_ERROR': self.handle_event_file_send_error,
|
||||||
'status': gajim.status_before_autoaway[account],
|
'STANZA_ARRIVED': self.handle_event_stanza_arrived,
|
||||||
'time': gajim.config.get('autoxatime')
|
'STANZA_SENT': self.handle_event_stanza_sent,
|
||||||
}
|
'HTTP_AUTH': self.handle_event_http_auth,
|
||||||
self.roster.send_status(account, 'xa', auto_message, auto=True)
|
'VCARD_PUBLISHED': self.handle_event_vcard_published,
|
||||||
gajim.sleeper_state[account] = 'autoxa'
|
'VCARD_NOT_PUBLISHED': self.handle_event_vcard_not_published,
|
||||||
return True # renew timeout (loop for ever)
|
'ASK_NEW_NICK': self.handle_event_ask_new_nick,
|
||||||
|
'SIGNED_IN': self.handle_event_signed_in,
|
||||||
|
'METACONTACTS': self.handle_event_metacontacts,
|
||||||
|
'ATOM_ENTRY': self.handle_atom_entry,
|
||||||
|
'FAILED_DECRYPT': self.handle_event_failed_decrypt,
|
||||||
|
'PRIVACY_LISTS_RECEIVED': self.handle_event_privacy_lists_received,
|
||||||
|
'PRIVACY_LIST_RECEIVED': self.handle_event_privacy_list_received,
|
||||||
|
'PRIVACY_LISTS_ACTIVE_DEFAULT': \
|
||||||
|
self.handle_event_privacy_lists_active_default,
|
||||||
|
'PRIVACY_LIST_REMOVED': self.handle_event_privacy_list_removed,
|
||||||
|
'ZC_NAME_CONFLICT': self.handle_event_zc_name_conflict,
|
||||||
|
'PING_SENT': self.handle_event_ping_sent,
|
||||||
|
'PING_REPLY': self.handle_event_ping_reply,
|
||||||
|
'PING_ERROR': self.handle_event_ping_error,
|
||||||
|
'SEARCH_FORM': self.handle_event_search_form,
|
||||||
|
'SEARCH_RESULT': self.handle_event_search_result,
|
||||||
|
'RESOURCE_CONFLICT': self.handle_event_resource_conflict,
|
||||||
|
'PEP_CONFIG': self.handle_event_pep_config,
|
||||||
|
'UNIQUE_ROOM_ID_UNSUPPORTED': \
|
||||||
|
self.handle_event_unique_room_id_unsupported,
|
||||||
|
'UNIQUE_ROOM_ID_SUPPORTED': self.handle_event_unique_room_id_supported,
|
||||||
|
'SESSION_NEG': self.handle_session_negotiation,
|
||||||
|
'GPG_PASSWORD_REQUIRED': self.handle_event_gpg_password_required,
|
||||||
|
'SSL_ERROR': self.handle_event_ssl_error,
|
||||||
|
'FINGERPRINT_ERROR': self.handle_event_fingerprint_error,
|
||||||
|
'PLAIN_CONNECTION': self.handle_event_plain_connection,
|
||||||
|
'PUBSUB_NODE_REMOVED': self.handle_event_pubsub_node_removed,
|
||||||
|
'PUBSUB_NODE_NOT_REMOVED': self.handle_event_pubsub_node_not_removed,
|
||||||
|
}
|
||||||
|
gajim.handlers = self.handlers
|
||||||
|
|
||||||
def autoconnect(self):
|
################################################################################
|
||||||
'''auto connect at startup'''
|
### Methods dealing with gajim.events
|
||||||
# dict of account that want to connect sorted by status
|
################################################################################
|
||||||
shows = {}
|
|
||||||
for a in gajim.connections:
|
def add_event(self, account, jid, type_, event_args):
|
||||||
if gajim.config.get_per('accounts', a, 'autoconnect'):
|
'''add an event to the gajim.events var'''
|
||||||
show = gajim.config.get_per('accounts', a, 'autoconnect_as')
|
# We add it to the gajim.events queue
|
||||||
if not show in gajim.SHOW_LIST:
|
# Do we have a queue?
|
||||||
continue
|
jid = gajim.get_jid_without_resource(jid)
|
||||||
if not show in shows:
|
no_queue = len(gajim.events.get_events(account, jid)) == 0
|
||||||
shows[show] = [a]
|
event_type = None
|
||||||
|
# type_ can be gc-invitation file-send-error file-error file-request-error
|
||||||
|
# file-request file-completed file-stopped
|
||||||
|
# event_type can be in advancedNotificationWindow.events_list
|
||||||
|
event_types = {'file-request': 'ft_request',
|
||||||
|
'file-completed': 'ft_finished'}
|
||||||
|
if type_ in event_types:
|
||||||
|
event_type = event_types[type_]
|
||||||
|
show_in_roster = notify.get_show_in_roster(event_type, account, jid)
|
||||||
|
show_in_systray = notify.get_show_in_systray(event_type, account, jid)
|
||||||
|
event = gajim.events.create_event(type_, event_args,
|
||||||
|
show_in_roster = show_in_roster,
|
||||||
|
show_in_systray = show_in_systray)
|
||||||
|
gajim.events.add_event(account, jid, event)
|
||||||
|
|
||||||
|
self.roster.show_title()
|
||||||
|
if no_queue: # We didn't have a queue: we change icons
|
||||||
|
if not gajim.contacts.get_contact_with_highest_priority(account, jid):
|
||||||
|
if type_ == 'gc-invitation':
|
||||||
|
self.roster.add_groupchat(account, jid,
|
||||||
|
status='offline')
|
||||||
else:
|
else:
|
||||||
shows[show].append(a)
|
# add contact to roster ("Not In The Roster") if he is not
|
||||||
for show in shows:
|
self.roster.add_to_not_in_the_roster(account, jid)
|
||||||
message = self.roster.get_status_message(show)
|
self.roster.draw_contact(jid, account)
|
||||||
if message is None:
|
|
||||||
continue
|
|
||||||
for a in shows[show]:
|
|
||||||
self.roster.send_status(a, show, message)
|
|
||||||
return False
|
|
||||||
|
|
||||||
def show_systray(self):
|
# Show contact in roster (if he is invisible for example) and select line
|
||||||
self.systray_enabled = True
|
self.roster.show_and_select_contact_if_having_events(jid, account)
|
||||||
self.systray.show_icon()
|
|
||||||
|
|
||||||
def hide_systray(self):
|
def remove_first_event(self, account, jid, type_ = None):
|
||||||
self.systray_enabled = False
|
event = gajim.events.get_first_event(account, jid, type_)
|
||||||
self.systray.hide_icon()
|
self.remove_event(account, jid, event)
|
||||||
|
|
||||||
|
def remove_event(self, account, jid, event):
|
||||||
|
if gajim.events.remove_events(account, jid, event):
|
||||||
|
# No such event found
|
||||||
|
return
|
||||||
|
# no other event?
|
||||||
|
if not len(gajim.events.get_events(account, jid)):
|
||||||
|
contact = gajim.contacts.get_contact_with_highest_priority(account,
|
||||||
|
jid)
|
||||||
|
show_transport = gajim.config.get('show_transports_group')
|
||||||
|
if contact and (contact.show in ('error', 'offline') and \
|
||||||
|
not gajim.config.get('showoffline') or (
|
||||||
|
gajim.jid_is_transport(jid) and not show_transport)):
|
||||||
|
self.roster.remove_contact(contact.jid, account)
|
||||||
|
self.roster.show_title()
|
||||||
|
self.roster.draw_contact(jid, account)
|
||||||
|
|
||||||
|
def handle_event(self, account, fjid, type_):
|
||||||
|
w = None
|
||||||
|
resource = gajim.get_resource_from_jid(fjid)
|
||||||
|
jid = gajim.get_jid_without_resource(fjid)
|
||||||
|
if type_ in ('printed_gc_msg', 'printed_marked_gc_msg', 'gc_msg'):
|
||||||
|
w = self.msg_win_mgr.get_window(jid, account)
|
||||||
|
if self.minimized_controls[account].has_key(jid):
|
||||||
|
if not w:
|
||||||
|
ctrl = self.minimized_controls[account][jid]
|
||||||
|
w = self.msg_win_mgr.create_window(ctrl.contact, \
|
||||||
|
ctrl.account, ctrl.type_id)
|
||||||
|
self.roster.on_groupchat_maximized(None, jid, account)
|
||||||
|
elif type_ in ('printed_chat', 'chat', ''):
|
||||||
|
# '' is for log in/out notifications
|
||||||
|
if self.msg_win_mgr.has_window(fjid, account):
|
||||||
|
w = self.msg_win_mgr.get_window(fjid, account)
|
||||||
|
else:
|
||||||
|
highest_contact = gajim.contacts.get_contact_with_highest_priority(
|
||||||
|
account, jid)
|
||||||
|
# jid can have a window if this resource was lower when he sent
|
||||||
|
# message and is now higher because the other one is offline
|
||||||
|
if resource and highest_contact.resource == resource and \
|
||||||
|
not self.msg_win_mgr.has_window(jid, account):
|
||||||
|
# remove resource of events too
|
||||||
|
gajim.events.change_jid(account, fjid, jid)
|
||||||
|
resource = None
|
||||||
|
fjid = jid
|
||||||
|
contact = None
|
||||||
|
if resource:
|
||||||
|
contact = gajim.contacts.get_contact(account, jid, resource)
|
||||||
|
if not contact:
|
||||||
|
contact = highest_contact
|
||||||
|
self.new_chat(contact, account, resource = resource)
|
||||||
|
w = self.msg_win_mgr.get_window(fjid, account)
|
||||||
|
gajim.last_message_time[account][jid] = 0 # long time ago
|
||||||
|
elif type_ in ('printed_pm', 'pm'):
|
||||||
|
if self.msg_win_mgr.has_window(fjid, account):
|
||||||
|
w = self.msg_win_mgr.get_window(fjid, account)
|
||||||
|
else:
|
||||||
|
room_jid = jid
|
||||||
|
nick = resource
|
||||||
|
gc_contact = gajim.contacts.get_gc_contact(account, room_jid,
|
||||||
|
nick)
|
||||||
|
if gc_contact:
|
||||||
|
show = gc_contact.show
|
||||||
|
else:
|
||||||
|
show = 'offline'
|
||||||
|
gc_contact = gajim.contacts.create_gc_contact(
|
||||||
|
room_jid = room_jid, name = nick, show = show)
|
||||||
|
self.new_private_chat(gc_contact, account)
|
||||||
|
w = self.msg_win_mgr.get_window(fjid, account)
|
||||||
|
elif type_ in ('normal', 'file-request', 'file-request-error',
|
||||||
|
'file-send-error', 'file-error', 'file-stopped', 'file-completed'):
|
||||||
|
# Get the first single message event
|
||||||
|
event = gajim.events.get_first_event(account, fjid, type_)
|
||||||
|
if not event:
|
||||||
|
# default to jid without resource
|
||||||
|
event = gajim.events.get_first_event(account, jid, type_)
|
||||||
|
if not event:
|
||||||
|
return
|
||||||
|
# Open the window
|
||||||
|
self.roster.open_event(account, jid, event)
|
||||||
|
else:
|
||||||
|
# Open the window
|
||||||
|
self.roster.open_event(account, fjid, event)
|
||||||
|
elif type_ == 'gmail':
|
||||||
|
url=gajim.connections[account].gmail_url
|
||||||
|
if url:
|
||||||
|
helpers.launch_browser_mailer('url', url)
|
||||||
|
elif type_ == 'gc-invitation':
|
||||||
|
event = gajim.events.get_first_event(account, jid, type_)
|
||||||
|
data = event.parameters
|
||||||
|
dialogs.InvitationReceivedDialog(account, data[0], jid, data[2],
|
||||||
|
data[1], data[3])
|
||||||
|
gajim.events.remove_events(account, jid, event)
|
||||||
|
self.roster.draw_contact(jid, account)
|
||||||
|
if w:
|
||||||
|
w.set_active_tab(fjid, account)
|
||||||
|
w.window.present()
|
||||||
|
w.window.window.focus()
|
||||||
|
ctrl = w.get_control(fjid, account)
|
||||||
|
# Using isinstance here because we want to catch all derived types
|
||||||
|
if isinstance(ctrl, ChatControlBase):
|
||||||
|
tv = ctrl.conv_textview
|
||||||
|
tv.scroll_to_end()
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
### Methods dealing with emoticons
|
||||||
|
################################################################################
|
||||||
|
|
||||||
def image_is_ok(self, image):
|
def image_is_ok(self, image):
|
||||||
if not os.path.exists(image):
|
if not os.path.exists(image):
|
||||||
|
@ -2517,9 +2561,6 @@ class Interface:
|
||||||
return -1
|
return -1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def on_launch_browser_mailer(self, widget, url, kind):
|
|
||||||
helpers.launch_browser_mailer(kind, url)
|
|
||||||
|
|
||||||
def popup_emoticons_under_button(self, button, parent_win):
|
def popup_emoticons_under_button(self, button, parent_win):
|
||||||
''' pops emoticons menu under button, located in parent_win'''
|
''' pops emoticons menu under button, located in parent_win'''
|
||||||
gtkgui_helpers.popup_emoticons_under_button(self.emoticons_menu,
|
gtkgui_helpers.popup_emoticons_under_button(self.emoticons_menu,
|
||||||
|
@ -2623,89 +2664,226 @@ class Interface:
|
||||||
self.emoticons_menu.destroy()
|
self.emoticons_menu.destroy()
|
||||||
self.emoticons_menu = self.prepare_emoticons_menu()
|
self.emoticons_menu = self.prepare_emoticons_menu()
|
||||||
|
|
||||||
def register_handlers(self):
|
################################################################################
|
||||||
self.handlers = {
|
### Methods for opening new messages controls
|
||||||
'ROSTER': self.handle_event_roster,
|
################################################################################
|
||||||
'WARNING': self.handle_event_warning,
|
|
||||||
'ERROR': self.handle_event_error,
|
def join_gc_room(self, account, room_jid, nick, password, minimize=False,
|
||||||
'INFORMATION': self.handle_event_information,
|
is_continued=False):
|
||||||
'ERROR_ANSWER': self.handle_event_error_answer,
|
'''joins the room immediately'''
|
||||||
'STATUS': self.handle_event_status,
|
if self.msg_win_mgr.has_window(room_jid, account) and \
|
||||||
'NOTIFY': self.handle_event_notify,
|
gajim.gc_connected[account][room_jid]:
|
||||||
'MSG': self.handle_event_msg,
|
win = self.msg_win_mgr.get_window(room_jid, account)
|
||||||
'MSGERROR': self.handle_event_msgerror,
|
win.window.present()
|
||||||
'MSGSENT': self.handle_event_msgsent,
|
win.set_active_tab(room_jid, account)
|
||||||
'MSGNOTSENT': self.handle_event_msgnotsent,
|
dialogs.ErrorDialog(_('You are already in group chat %s') % room_jid)
|
||||||
'SUBSCRIBED': self.handle_event_subscribed,
|
return
|
||||||
'UNSUBSCRIBED': self.handle_event_unsubscribed,
|
minimized_control_exists = False
|
||||||
'SUBSCRIBE': self.handle_event_subscribe,
|
if room_jid in gajim.interface.minimized_controls[account]:
|
||||||
'AGENT_ERROR_INFO': self.handle_event_agent_info_error,
|
minimized_control_exists = True
|
||||||
'AGENT_ERROR_ITEMS': self.handle_event_agent_items_error,
|
invisible_show = gajim.SHOW_LIST.index('invisible')
|
||||||
'AGENT_REMOVED': self.handle_event_agent_removed,
|
if gajim.connections[account].connected == invisible_show:
|
||||||
'REGISTER_AGENT_INFO': self.handle_event_register_agent_info,
|
dialogs.ErrorDialog(
|
||||||
'AGENT_INFO_ITEMS': self.handle_event_agent_info_items,
|
_('You cannot join a group chat while you are invisible'))
|
||||||
'AGENT_INFO_INFO': self.handle_event_agent_info_info,
|
return
|
||||||
'QUIT': self.handle_event_quit,
|
if minimize and not minimized_control_exists and \
|
||||||
'NEW_ACC_CONNECTED': self.handle_event_new_acc_connected,
|
not self.msg_win_mgr.has_window(room_jid, account):
|
||||||
'NEW_ACC_NOT_CONNECTED': self.handle_event_new_acc_not_connected,
|
contact = gajim.contacts.create_contact(jid = room_jid, name = nick)
|
||||||
'ACC_OK': self.handle_event_acc_ok,
|
gc_control = GroupchatControl(None, contact, account)
|
||||||
'ACC_NOT_OK': self.handle_event_acc_not_ok,
|
self.minimized_controls[account][room_jid] = gc_control
|
||||||
'MYVCARD': self.handle_event_myvcard,
|
gajim.connections[account].join_gc(nick, room_jid, password)
|
||||||
'VCARD': self.handle_event_vcard,
|
if password:
|
||||||
'LAST_STATUS_TIME': self.handle_event_last_status_time,
|
gajim.gc_passwords[room_jid] = password
|
||||||
'OS_INFO': self.handle_event_os_info,
|
self.roster.add_groupchat(account, room_jid)
|
||||||
'GC_NOTIFY': self.handle_event_gc_notify,
|
return
|
||||||
'GC_MSG': self.handle_event_gc_msg,
|
if not minimized_control_exists and \
|
||||||
'GC_SUBJECT': self.handle_event_gc_subject,
|
not self.msg_win_mgr.has_window(room_jid, account):
|
||||||
'GC_CONFIG': self.handle_event_gc_config,
|
self.new_room(room_jid, nick, account, is_continued=is_continued)
|
||||||
'GC_CONFIG_CHANGE': self.handle_event_gc_config_change,
|
if not minimized_control_exists:
|
||||||
'GC_INVITATION': self.handle_event_gc_invitation,
|
gc_win = self.msg_win_mgr.get_window(room_jid, account)
|
||||||
'GC_AFFILIATION': self.handle_event_gc_affiliation,
|
gc_win.set_active_tab(room_jid, account)
|
||||||
'GC_PASSWORD_REQUIRED': self.handle_event_gc_password_required,
|
gc_win.window.present()
|
||||||
'BAD_PASSPHRASE': self.handle_event_bad_passphrase,
|
gajim.connections[account].join_gc(nick, room_jid, password)
|
||||||
'ROSTER_INFO': self.handle_event_roster_info,
|
if password:
|
||||||
'BOOKMARKS': self.handle_event_bookmarks,
|
gajim.gc_passwords[room_jid] = password
|
||||||
'CON_TYPE': self.handle_event_con_type,
|
contact = gajim.contacts.get_contact_with_highest_priority(account, \
|
||||||
'CONNECTION_LOST': self.handle_event_connection_lost,
|
room_jid)
|
||||||
'FILE_REQUEST': self.handle_event_file_request,
|
if contact or minimized_control_exists:
|
||||||
'GMAIL_NOTIFY': self.handle_event_gmail_notify,
|
self.roster.add_groupchat(account, room_jid)
|
||||||
'FILE_REQUEST_ERROR': self.handle_event_file_request_error,
|
|
||||||
'FILE_SEND_ERROR': self.handle_event_file_send_error,
|
def new_room(self, room_jid, nick, account, is_continued=False):
|
||||||
'STANZA_ARRIVED': self.handle_event_stanza_arrived,
|
# Get target window, create a control, and associate it with the window
|
||||||
'STANZA_SENT': self.handle_event_stanza_sent,
|
contact = gajim.contacts.create_contact(jid = room_jid, name = nick)
|
||||||
'HTTP_AUTH': self.handle_event_http_auth,
|
mw = self.msg_win_mgr.get_window(contact.jid, account)
|
||||||
'VCARD_PUBLISHED': self.handle_event_vcard_published,
|
if not mw:
|
||||||
'VCARD_NOT_PUBLISHED': self.handle_event_vcard_not_published,
|
mw = self.msg_win_mgr.create_window(contact, account,
|
||||||
'ASK_NEW_NICK': self.handle_event_ask_new_nick,
|
GroupchatControl.TYPE_ID)
|
||||||
'SIGNED_IN': self.handle_event_signed_in,
|
gc_control = GroupchatControl(mw, contact, account,
|
||||||
'METACONTACTS': self.handle_event_metacontacts,
|
is_continued=is_continued)
|
||||||
'ATOM_ENTRY': self.handle_atom_entry,
|
mw.new_tab(gc_control)
|
||||||
'FAILED_DECRYPT': self.handle_event_failed_decrypt,
|
|
||||||
'PRIVACY_LISTS_RECEIVED': self.handle_event_privacy_lists_received,
|
def new_private_chat(self, gc_contact, account, session = None):
|
||||||
'PRIVACY_LIST_RECEIVED': self.handle_event_privacy_list_received,
|
contact = gajim.contacts.contact_from_gc_contact(gc_contact)
|
||||||
'PRIVACY_LISTS_ACTIVE_DEFAULT': \
|
type_ = message_control.TYPE_PM
|
||||||
self.handle_event_privacy_lists_active_default,
|
fjid = gc_contact.room_jid + '/' + gc_contact.name
|
||||||
'PRIVACY_LIST_REMOVED': self.handle_event_privacy_list_removed,
|
mw = self.msg_win_mgr.get_window(fjid, account)
|
||||||
'ZC_NAME_CONFLICT': self.handle_event_zc_name_conflict,
|
if not mw:
|
||||||
'PING_SENT': self.handle_event_ping_sent,
|
mw = self.msg_win_mgr.create_window(contact, account, type_)
|
||||||
'PING_REPLY': self.handle_event_ping_reply,
|
|
||||||
'PING_ERROR': self.handle_event_ping_error,
|
chat_control = \
|
||||||
'SEARCH_FORM': self.handle_event_search_form,
|
PrivateChatControl(mw, gc_contact, contact, account, session)
|
||||||
'SEARCH_RESULT': self.handle_event_search_result,
|
mw.new_tab(chat_control)
|
||||||
'RESOURCE_CONFLICT': self.handle_event_resource_conflict,
|
if len(gajim.events.get_events(account, fjid)):
|
||||||
'PEP_CONFIG': self.handle_event_pep_config,
|
# We call this here to avoid race conditions with widget validation
|
||||||
'UNIQUE_ROOM_ID_UNSUPPORTED': \
|
chat_control.read_queue()
|
||||||
self.handle_event_unique_room_id_unsupported,
|
|
||||||
'UNIQUE_ROOM_ID_SUPPORTED': self.handle_event_unique_room_id_supported,
|
def new_chat(self, contact, account, resource = None, session = None):
|
||||||
'SESSION_NEG': self.handle_session_negotiation,
|
# Get target window, create a control, and associate it with the window
|
||||||
'GPG_PASSWORD_REQUIRED': self.handle_event_gpg_password_required,
|
type_ = message_control.TYPE_CHAT
|
||||||
'SSL_ERROR': self.handle_event_ssl_error,
|
|
||||||
'FINGERPRINT_ERROR': self.handle_event_fingerprint_error,
|
fjid = contact.jid
|
||||||
'PLAIN_CONNECTION': self.handle_event_plain_connection,
|
if resource:
|
||||||
'PUBSUB_NODE_REMOVED': self.handle_event_pubsub_node_removed,
|
fjid += '/' + resource
|
||||||
'PUBSUB_NODE_NOT_REMOVED': self.handle_event_pubsub_node_not_removed,
|
|
||||||
}
|
mw = self.msg_win_mgr.get_window(fjid, account)
|
||||||
gajim.handlers = self.handlers
|
if not mw:
|
||||||
|
mw = self.msg_win_mgr.create_window(contact, account, type_)
|
||||||
|
|
||||||
|
chat_control = ChatControl(mw, contact, account, session, resource)
|
||||||
|
|
||||||
|
mw.new_tab(chat_control)
|
||||||
|
|
||||||
|
if len(gajim.events.get_events(account, fjid)):
|
||||||
|
# We call this here to avoid race conditions with widget validation
|
||||||
|
chat_control.read_queue()
|
||||||
|
|
||||||
|
def new_chat_from_jid(self, account, fjid):
|
||||||
|
jid, resource = gajim.get_room_and_nick_from_fjid(fjid)
|
||||||
|
contact = gajim.contacts.get_contact(account, jid, resource)
|
||||||
|
added_to_roster = False
|
||||||
|
if not contact:
|
||||||
|
added_to_roster = True
|
||||||
|
contact = self.roster.add_to_not_in_the_roster(account, jid,
|
||||||
|
resource = resource)
|
||||||
|
|
||||||
|
if not self.msg_win_mgr.has_window(fjid, account):
|
||||||
|
self.new_chat(contact, account, resource = resource)
|
||||||
|
mw = self.msg_win_mgr.get_window(fjid, account)
|
||||||
|
mw.set_active_tab(fjid, account)
|
||||||
|
mw.window.present()
|
||||||
|
# For JEP-0172
|
||||||
|
if added_to_roster:
|
||||||
|
mc = mw.get_control(fjid, account)
|
||||||
|
mc.user_nick = gajim.nicks[account]
|
||||||
|
|
||||||
|
def on_open_chat_window(self, contact, account, resource = None, session = None):
|
||||||
|
# Get the window containing the chat
|
||||||
|
fjid = contact.jid
|
||||||
|
if resource:
|
||||||
|
fjid += '/' + resource
|
||||||
|
win = self.msg_win_mgr.get_window(fjid, account)
|
||||||
|
if not win:
|
||||||
|
self.new_chat(contact, account, resource = resource, session = session)
|
||||||
|
win = self.msg_win_mgr.get_window(fjid, account)
|
||||||
|
ctrl = win.get_control(fjid, account)
|
||||||
|
# last message is long time ago
|
||||||
|
gajim.last_message_time[account][ctrl.get_full_jid()] = 0
|
||||||
|
win.set_active_tab(fjid, account)
|
||||||
|
if gajim.connections[account].is_zeroconf and \
|
||||||
|
gajim.connections[account].status in ('offline', 'invisible'):
|
||||||
|
win.get_control(fjid, account).got_disconnected()
|
||||||
|
win.window.present()
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
### Other Methods
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
def read_sleepy(self):
|
||||||
|
'''Check idle status and change that status if needed'''
|
||||||
|
if not self.sleeper.poll():
|
||||||
|
# idle detection is not supported in that OS
|
||||||
|
return False # stop looping in vain
|
||||||
|
state = self.sleeper.getState()
|
||||||
|
for account in gajim.connections:
|
||||||
|
if not gajim.sleeper_state.has_key(account) or \
|
||||||
|
not gajim.sleeper_state[account]:
|
||||||
|
continue
|
||||||
|
if state == common.sleepy.STATE_AWAKE and \
|
||||||
|
gajim.sleeper_state[account] in ('autoaway', 'autoxa'):
|
||||||
|
# we go online
|
||||||
|
self.roster.send_status(account, 'online',
|
||||||
|
gajim.status_before_autoaway[account])
|
||||||
|
gajim.status_before_autoaway[account] = ''
|
||||||
|
gajim.sleeper_state[account] = 'online'
|
||||||
|
elif state == common.sleepy.STATE_AWAY and \
|
||||||
|
gajim.sleeper_state[account] == 'online' and \
|
||||||
|
gajim.config.get('autoaway'):
|
||||||
|
# we save out online status
|
||||||
|
gajim.status_before_autoaway[account] = \
|
||||||
|
gajim.connections[account].status
|
||||||
|
# we go away (no auto status) [we pass True to auto param]
|
||||||
|
auto_message = gajim.config.get('autoaway_message')
|
||||||
|
if not auto_message:
|
||||||
|
auto_message = gajim.connections[account].status
|
||||||
|
else:
|
||||||
|
auto_message = auto_message.replace('$S','%(status)s')
|
||||||
|
auto_message = auto_message.replace('$T','%(time)s')
|
||||||
|
auto_message = auto_message % {
|
||||||
|
'status': gajim.status_before_autoaway[account],
|
||||||
|
'time': gajim.config.get('autoawaytime')
|
||||||
|
}
|
||||||
|
self.roster.send_status(account, 'away', auto_message, auto=True)
|
||||||
|
gajim.sleeper_state[account] = 'autoaway'
|
||||||
|
elif state == common.sleepy.STATE_XA and (\
|
||||||
|
gajim.sleeper_state[account] == 'autoaway' or \
|
||||||
|
gajim.sleeper_state[account] == 'online') and \
|
||||||
|
gajim.config.get('autoxa'):
|
||||||
|
# we go extended away [we pass True to auto param]
|
||||||
|
auto_message = gajim.config.get('autoxa_message')
|
||||||
|
if not auto_message:
|
||||||
|
auto_message = gajim.connections[account].status
|
||||||
|
else:
|
||||||
|
auto_message = auto_message.replace('$S','%(status)s')
|
||||||
|
auto_message = auto_message.replace('$T','%(time)s')
|
||||||
|
auto_message = auto_message % {
|
||||||
|
'status': gajim.status_before_autoaway[account],
|
||||||
|
'time': gajim.config.get('autoxatime')
|
||||||
|
}
|
||||||
|
self.roster.send_status(account, 'xa', auto_message, auto=True)
|
||||||
|
gajim.sleeper_state[account] = 'autoxa'
|
||||||
|
return True # renew timeout (loop for ever)
|
||||||
|
|
||||||
|
def autoconnect(self):
|
||||||
|
'''auto connect at startup'''
|
||||||
|
# dict of account that want to connect sorted by status
|
||||||
|
shows = {}
|
||||||
|
for a in gajim.connections:
|
||||||
|
if gajim.config.get_per('accounts', a, 'autoconnect'):
|
||||||
|
show = gajim.config.get_per('accounts', a, 'autoconnect_as')
|
||||||
|
if not show in gajim.SHOW_LIST:
|
||||||
|
continue
|
||||||
|
if not show in shows:
|
||||||
|
shows[show] = [a]
|
||||||
|
else:
|
||||||
|
shows[show].append(a)
|
||||||
|
for show in shows:
|
||||||
|
message = self.roster.get_status_message(show)
|
||||||
|
if message is None:
|
||||||
|
continue
|
||||||
|
for a in shows[show]:
|
||||||
|
self.roster.send_status(a, show, message)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def show_systray(self):
|
||||||
|
self.systray_enabled = True
|
||||||
|
self.systray.show_icon()
|
||||||
|
|
||||||
|
def hide_systray(self):
|
||||||
|
self.systray_enabled = False
|
||||||
|
self.systray.hide_icon()
|
||||||
|
|
||||||
|
def on_launch_browser_mailer(self, widget, url, kind):
|
||||||
|
helpers.launch_browser_mailer(kind, url)
|
||||||
|
|
||||||
def process_connections(self):
|
def process_connections(self):
|
||||||
''' called each foo (200) miliseconds. Check for idlequeue timeouts.
|
''' called each foo (200) miliseconds. Check for idlequeue timeouts.
|
||||||
|
@ -2723,91 +2901,63 @@ class Interface:
|
||||||
err_str)
|
err_str)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
def handle_event(self, account, fjid, type_):
|
def save_avatar_files(self, jid, photo, puny_nick = None, local = False):
|
||||||
w = None
|
'''Saves an avatar to a separate file, and generate files for dbus notifications. An avatar can be given as a pixmap directly or as an decoded image.'''
|
||||||
resource = gajim.get_resource_from_jid(fjid)
|
puny_jid = helpers.sanitize_filename(jid)
|
||||||
jid = gajim.get_jid_without_resource(fjid)
|
path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid)
|
||||||
if type_ in ('printed_gc_msg', 'printed_marked_gc_msg', 'gc_msg'):
|
if puny_nick:
|
||||||
w = self.msg_win_mgr.get_window(jid, account)
|
path_to_file = os.path.join(path_to_file, puny_nick)
|
||||||
if self.minimized_controls[account].has_key(jid):
|
# remove old avatars
|
||||||
if not w:
|
for typ in ('jpeg', 'png'):
|
||||||
ctrl = self.minimized_controls[account][jid]
|
if local:
|
||||||
w = self.msg_win_mgr.create_window(ctrl.contact, \
|
path_to_original_file = path_to_file + '_local'+ '.' + typ
|
||||||
ctrl.account, ctrl.type_id)
|
|
||||||
self.roster.on_groupchat_maximized(None, jid, account)
|
|
||||||
elif type_ in ('printed_chat', 'chat', ''):
|
|
||||||
# '' is for log in/out notifications
|
|
||||||
if self.msg_win_mgr.has_window(fjid, account):
|
|
||||||
w = self.msg_win_mgr.get_window(fjid, account)
|
|
||||||
else:
|
else:
|
||||||
highest_contact = gajim.contacts.get_contact_with_highest_priority(
|
path_to_original_file = path_to_file + '.' + typ
|
||||||
account, jid)
|
if os.path.isfile(path_to_original_file):
|
||||||
# jid can have a window if this resource was lower when he sent
|
os.remove(path_to_original_file)
|
||||||
# message and is now higher because the other one is offline
|
if local and photo:
|
||||||
if resource and highest_contact.resource == resource and \
|
pixbuf = photo
|
||||||
not self.msg_win_mgr.has_window(jid, account):
|
type = 'png'
|
||||||
# remove resource of events too
|
extension = '_local.png' # save local avatars as png file
|
||||||
gajim.events.change_jid(account, fjid, jid)
|
else:
|
||||||
resource = None
|
pixbuf, typ = gtkgui_helpers.get_pixbuf_from_data(photo, want_type = True)
|
||||||
fjid = jid
|
if pixbuf is None:
|
||||||
contact = None
|
return
|
||||||
if resource:
|
extension = '.' + typ
|
||||||
contact = gajim.contacts.get_contact(account, jid, resource)
|
if typ not in ('jpeg', 'png'):
|
||||||
if not contact:
|
gajim.log.debug('gtkpixbuf cannot save other than jpeg and png formats. saving %s\'avatar as png file (originaly %s)' % (jid, typ))
|
||||||
contact = highest_contact
|
typ = 'png'
|
||||||
self.roster.new_chat(contact, account, resource = resource)
|
extension = '.png'
|
||||||
w = self.msg_win_mgr.get_window(fjid, account)
|
path_to_original_file = path_to_file + extension
|
||||||
gajim.last_message_time[account][jid] = 0 # long time ago
|
pixbuf.save(path_to_original_file, typ)
|
||||||
elif type_ in ('printed_pm', 'pm'):
|
# Generate and save the resized, color avatar
|
||||||
if self.msg_win_mgr.has_window(fjid, account):
|
pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'notification')
|
||||||
w = self.msg_win_mgr.get_window(fjid, account)
|
if pixbuf:
|
||||||
else:
|
path_to_normal_file = path_to_file + '_notif_size_colored' + extension
|
||||||
room_jid = jid
|
pixbuf.save(path_to_normal_file, 'png')
|
||||||
nick = resource
|
# Generate and save the resized, black and white avatar
|
||||||
gc_contact = gajim.contacts.get_gc_contact(account, room_jid,
|
bwbuf = gtkgui_helpers.get_scaled_pixbuf(
|
||||||
nick)
|
gtkgui_helpers.make_pixbuf_grayscale(pixbuf), 'notification')
|
||||||
if gc_contact:
|
if bwbuf:
|
||||||
show = gc_contact.show
|
path_to_bw_file = path_to_file + '_notif_size_bw' + extension
|
||||||
else:
|
bwbuf.save(path_to_bw_file, 'png')
|
||||||
show = 'offline'
|
|
||||||
gc_contact = gajim.contacts.create_gc_contact(
|
def remove_avatar_files(self, jid, puny_nick = None, local = False):
|
||||||
room_jid = room_jid, name = nick, show = show)
|
'''remove avatar files of a jid'''
|
||||||
self.roster.new_private_chat(gc_contact, account)
|
puny_jid = helpers.sanitize_filename(jid)
|
||||||
w = self.msg_win_mgr.get_window(fjid, account)
|
path_to_file = os.path.join(gajim.AVATAR_PATH, puny_jid)
|
||||||
elif type_ in ('normal', 'file-request', 'file-request-error',
|
if puny_nick:
|
||||||
'file-send-error', 'file-error', 'file-stopped', 'file-completed'):
|
path_to_file = os.path.join(path_to_file, puny_nick)
|
||||||
# Get the first single message event
|
for ext in ('.jpeg', '.png'):
|
||||||
event = gajim.events.get_first_event(account, fjid, type_)
|
if local:
|
||||||
if not event:
|
ext = '_local' + ext
|
||||||
# default to jid without resource
|
path_to_original_file = path_to_file + ext
|
||||||
event = gajim.events.get_first_event(account, jid, type_)
|
if os.path.isfile(path_to_file + ext):
|
||||||
if not event:
|
os.remove(path_to_file + ext)
|
||||||
return
|
if os.path.isfile(path_to_file + '_notif_size_colored' + ext):
|
||||||
# Open the window
|
os.remove(path_to_file + '_notif_size_colored' + ext)
|
||||||
self.roster.open_event(account, jid, event)
|
if os.path.isfile(path_to_file + '_notif_size_bw' + ext):
|
||||||
else:
|
os.remove(path_to_file + '_notif_size_bw' + ext)
|
||||||
# Open the window
|
|
||||||
self.roster.open_event(account, fjid, event)
|
|
||||||
elif type_ == 'gmail':
|
|
||||||
url=gajim.connections[account].gmail_url
|
|
||||||
if url:
|
|
||||||
helpers.launch_browser_mailer('url', url)
|
|
||||||
elif type_ == 'gc-invitation':
|
|
||||||
event = gajim.events.get_first_event(account, jid, type_)
|
|
||||||
data = event.parameters
|
|
||||||
dialogs.InvitationReceivedDialog(account, data[0], jid, data[2],
|
|
||||||
data[1], data[3])
|
|
||||||
gajim.events.remove_events(account, jid, event)
|
|
||||||
self.roster.draw_contact(jid, account)
|
|
||||||
if w:
|
|
||||||
w.set_active_tab(fjid, account)
|
|
||||||
w.window.present()
|
|
||||||
w.window.window.focus()
|
|
||||||
ctrl = w.get_control(fjid, account)
|
|
||||||
# Using isinstance here because we want to catch all derived types
|
|
||||||
if isinstance(ctrl, ChatControlBase):
|
|
||||||
tv = ctrl.conv_textview
|
|
||||||
tv.scroll_to_end()
|
|
||||||
|
|
||||||
def create_ipython_window(self):
|
def create_ipython_window(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1737,7 +1737,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
|
|
||||||
place_found = False
|
place_found = False
|
||||||
index = 0
|
index = 0
|
||||||
# check for duplicate entry and espect alpha order
|
# check for duplicate entry and respect alpha order
|
||||||
for bookmark in gajim.connections[self.account].bookmarks:
|
for bookmark in gajim.connections[self.account].bookmarks:
|
||||||
if bookmark['jid'] == bm['jid']:
|
if bookmark['jid'] == bm['jid']:
|
||||||
dialogs.ErrorDialog(
|
dialogs.ErrorDialog(
|
||||||
|
@ -2045,7 +2045,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
|
|
||||||
win = gajim.interface.msg_win_mgr.get_window(nick_jid, self.account)
|
win = gajim.interface.msg_win_mgr.get_window(nick_jid, self.account)
|
||||||
if not win:
|
if not win:
|
||||||
gajim.interface.roster.new_private_chat(gc_c, self.account)
|
gajim.interface.new_private_chat(gc_c, self.account)
|
||||||
win = gajim.interface.msg_win_mgr.get_window(nick_jid, self.account)
|
win = gajim.interface.msg_win_mgr.get_window(nick_jid, self.account)
|
||||||
win.set_active_tab(nick_jid, self.account)
|
win.set_active_tab(nick_jid, self.account)
|
||||||
win.window.present()
|
win.window.present()
|
||||||
|
|
|
@ -363,7 +363,7 @@ class SignalObject(dbus.service.Object):
|
||||||
connected_account = first_connected_acct
|
connected_account = first_connected_acct
|
||||||
|
|
||||||
if connected_account:
|
if connected_account:
|
||||||
gajim.interface.roster.new_chat_from_jid(connected_account, jid)
|
gajim.interface.new_chat_from_jid(connected_account, jid)
|
||||||
# preserve the 'steal focus preservation'
|
# preserve the 'steal focus preservation'
|
||||||
win = gajim.interface.msg_win_mgr.get_window(jid,
|
win = gajim.interface.msg_win_mgr.get_window(jid,
|
||||||
connected_account).window
|
connected_account).window
|
||||||
|
@ -674,4 +674,4 @@ class SignalObject(dbus.service.Object):
|
||||||
gajim.interface.instances[account]['join_gc'] = \
|
gajim.interface.instances[account]['join_gc'] = \
|
||||||
JoinGroupchatWindow(account, room_jid, nick)
|
JoinGroupchatWindow(account, room_jid, nick)
|
||||||
else:
|
else:
|
||||||
gajim.interface.roster.join_gc_room(account, room_jid, nick, password)
|
gajim.interface.join_gc_room(account, room_jid, nick, password)
|
||||||
|
|
|
@ -52,9 +52,6 @@ from common.exceptions import GajimGeneralException
|
||||||
from common import i18n
|
from common import i18n
|
||||||
|
|
||||||
from message_window import MessageWindowMgr
|
from message_window import MessageWindowMgr
|
||||||
from chat_control import ChatControl
|
|
||||||
from groupchat_control import GroupchatControl
|
|
||||||
from groupchat_control import PrivateChatControl
|
|
||||||
|
|
||||||
from common import dbus_support
|
from common import dbus_support
|
||||||
if dbus_support.supported:
|
if dbus_support.supported:
|
||||||
|
@ -1512,7 +1509,7 @@ class RosterWindow:
|
||||||
not gajim.gc_connected[account][jid]:
|
not gajim.gc_connected[account][jid]:
|
||||||
# we are not already connected
|
# we are not already connected
|
||||||
minimize = bm['minimize'] in ('1', 'true')
|
minimize = bm['minimize'] in ('1', 'true')
|
||||||
self.join_gc_room(account, jid, bm['nick'],
|
gajim.interface.join_gc_room(account, jid, bm['nick'],
|
||||||
bm['password'], minimize = minimize)
|
bm['password'], minimize = minimize)
|
||||||
|
|
||||||
def open_event(self, account, jid, event):
|
def open_event(self, account, jid, event):
|
||||||
|
@ -1814,67 +1811,6 @@ class RosterWindow:
|
||||||
else:
|
else:
|
||||||
change(account, status)
|
change(account, status)
|
||||||
|
|
||||||
def on_open_chat_window(self, widget, contact, account, resource = None, session = None):
|
|
||||||
# Get the window containing the chat
|
|
||||||
fjid = contact.jid
|
|
||||||
if resource:
|
|
||||||
fjid += '/' + resource
|
|
||||||
win = gajim.interface.msg_win_mgr.get_window(fjid, account)
|
|
||||||
if not win:
|
|
||||||
self.new_chat(contact, account, resource = resource, session = session)
|
|
||||||
win = gajim.interface.msg_win_mgr.get_window(fjid, account)
|
|
||||||
ctrl = win.get_control(fjid, account)
|
|
||||||
# last message is long time ago
|
|
||||||
gajim.last_message_time[account][ctrl.get_full_jid()] = 0
|
|
||||||
win.set_active_tab(fjid, account)
|
|
||||||
if gajim.connections[account].is_zeroconf and \
|
|
||||||
gajim.connections[account].status in ('offline', 'invisible'):
|
|
||||||
win.get_control(fjid, account).got_disconnected()
|
|
||||||
win.window.present()
|
|
||||||
|
|
||||||
def join_gc_room(self, account, room_jid, nick, password, minimize=False,
|
|
||||||
is_continued=False):
|
|
||||||
'''joins the room immediatelly'''
|
|
||||||
if gajim.interface.msg_win_mgr.has_window(room_jid, account) and \
|
|
||||||
gajim.gc_connected[account][room_jid]:
|
|
||||||
win = gajim.interface.msg_win_mgr.get_window(room_jid, account)
|
|
||||||
win.window.present()
|
|
||||||
win.set_active_tab(room_jid, account)
|
|
||||||
dialogs.ErrorDialog(_('You are already in group chat %s') % room_jid)
|
|
||||||
return
|
|
||||||
minimized_control_exists = False
|
|
||||||
if room_jid in gajim.interface.minimized_controls[account]:
|
|
||||||
minimized_control_exists = True
|
|
||||||
invisible_show = gajim.SHOW_LIST.index('invisible')
|
|
||||||
if gajim.connections[account].connected == invisible_show:
|
|
||||||
dialogs.ErrorDialog(
|
|
||||||
_('You cannot join a group chat while you are invisible'))
|
|
||||||
return
|
|
||||||
if minimize and not minimized_control_exists and \
|
|
||||||
not gajim.interface.msg_win_mgr.has_window(room_jid, account):
|
|
||||||
contact = gajim.contacts.create_contact(jid = room_jid, name = nick)
|
|
||||||
gc_control = GroupchatControl(None, contact, account)
|
|
||||||
gajim.interface.minimized_controls[account][room_jid] = gc_control
|
|
||||||
gajim.connections[account].join_gc(nick, room_jid, password)
|
|
||||||
if password:
|
|
||||||
gajim.gc_passwords[room_jid] = password
|
|
||||||
self.add_groupchat(account, room_jid)
|
|
||||||
return
|
|
||||||
if not minimized_control_exists and \
|
|
||||||
not gajim.interface.msg_win_mgr.has_window(room_jid, account):
|
|
||||||
self.new_room(room_jid, nick, account, is_continued=is_continued)
|
|
||||||
if not minimized_control_exists:
|
|
||||||
gc_win = gajim.interface.msg_win_mgr.get_window(room_jid, account)
|
|
||||||
gc_win.set_active_tab(room_jid, account)
|
|
||||||
gc_win.window.present()
|
|
||||||
gajim.connections[account].join_gc(nick, room_jid, password)
|
|
||||||
if password:
|
|
||||||
gajim.gc_passwords[room_jid] = password
|
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(account, \
|
|
||||||
room_jid)
|
|
||||||
if contact or minimized_control_exists:
|
|
||||||
self.add_groupchat(account, room_jid)
|
|
||||||
|
|
||||||
def update_status_combobox(self):
|
def update_status_combobox(self):
|
||||||
# table to change index in connection.connected to index in combobox
|
# table to change index in connection.connected to index in combobox
|
||||||
table = {'offline':9, 'connecting':9, 'online':0, 'chat':1, 'away':2,
|
table = {'offline':9, 'connecting':9, 'online':0, 'chat':1, 'away':2,
|
||||||
|
@ -1903,70 +1839,6 @@ class RosterWindow:
|
||||||
if gajim.interface.systray_enabled:
|
if gajim.interface.systray_enabled:
|
||||||
gajim.interface.systray.change_status(show)
|
gajim.interface.systray.change_status(show)
|
||||||
|
|
||||||
def new_private_chat(self, gc_contact, account, session = None):
|
|
||||||
contact = gajim.contacts.contact_from_gc_contact(gc_contact)
|
|
||||||
type_ = message_control.TYPE_PM
|
|
||||||
fjid = gc_contact.room_jid + '/' + gc_contact.name
|
|
||||||
mw = gajim.interface.msg_win_mgr.get_window(fjid, account)
|
|
||||||
if not mw:
|
|
||||||
mw = gajim.interface.msg_win_mgr.create_window(contact, account, type_)
|
|
||||||
|
|
||||||
chat_control = PrivateChatControl(mw, gc_contact, contact, account, session)
|
|
||||||
mw.new_tab(chat_control)
|
|
||||||
if len(gajim.events.get_events(account, fjid)):
|
|
||||||
# We call this here to avoid race conditions with widget validation
|
|
||||||
chat_control.read_queue()
|
|
||||||
|
|
||||||
def new_chat(self, contact, account, resource = None, session = None):
|
|
||||||
# Get target window, create a control, and associate it with the window
|
|
||||||
type_ = message_control.TYPE_CHAT
|
|
||||||
|
|
||||||
fjid = contact.jid
|
|
||||||
if resource:
|
|
||||||
fjid += '/' + resource
|
|
||||||
|
|
||||||
mw = gajim.interface.msg_win_mgr.get_window(fjid, account)
|
|
||||||
if not mw:
|
|
||||||
mw = gajim.interface.msg_win_mgr.create_window(contact, account, type_)
|
|
||||||
|
|
||||||
chat_control = ChatControl(mw, contact, account, session, resource)
|
|
||||||
|
|
||||||
mw.new_tab(chat_control)
|
|
||||||
|
|
||||||
if len(gajim.events.get_events(account, fjid)):
|
|
||||||
# We call this here to avoid race conditions with widget validation
|
|
||||||
chat_control.read_queue()
|
|
||||||
|
|
||||||
def new_chat_from_jid(self, account, fjid):
|
|
||||||
jid, resource = gajim.get_room_and_nick_from_fjid(fjid)
|
|
||||||
contact = gajim.contacts.get_contact(account, jid, resource)
|
|
||||||
added_to_roster = False
|
|
||||||
if not contact:
|
|
||||||
added_to_roster = True
|
|
||||||
contact = self.add_to_not_in_the_roster(account, jid,
|
|
||||||
resource = resource)
|
|
||||||
|
|
||||||
if not gajim.interface.msg_win_mgr.has_window(fjid, account):
|
|
||||||
self.new_chat(contact, account, resource = resource)
|
|
||||||
mw = gajim.interface.msg_win_mgr.get_window(fjid, account)
|
|
||||||
mw.set_active_tab(fjid, account)
|
|
||||||
mw.window.present()
|
|
||||||
# For JEP-0172
|
|
||||||
if added_to_roster:
|
|
||||||
mc = mw.get_control(fjid, account)
|
|
||||||
mc.user_nick = gajim.nicks[account]
|
|
||||||
|
|
||||||
def new_room(self, room_jid, nick, account, is_continued=False):
|
|
||||||
# Get target window, create a control, and associate it with the window
|
|
||||||
contact = gajim.contacts.create_contact(jid = room_jid, name = nick)
|
|
||||||
mw = gajim.interface.msg_win_mgr.get_window(contact.jid, account)
|
|
||||||
if not mw:
|
|
||||||
mw = gajim.interface.msg_win_mgr.create_window(contact, account,
|
|
||||||
GroupchatControl.TYPE_ID)
|
|
||||||
gc_control = GroupchatControl(mw, contact, account,
|
|
||||||
is_continued=is_continued)
|
|
||||||
mw.new_tab(gc_control)
|
|
||||||
|
|
||||||
def get_show(self, lcontact):
|
def get_show(self, lcontact):
|
||||||
prio = lcontact[0].priority
|
prio = lcontact[0].priority
|
||||||
show = lcontact[0].show
|
show = lcontact[0].show
|
||||||
|
@ -2077,7 +1949,8 @@ class RosterWindow:
|
||||||
if popup:
|
if popup:
|
||||||
# FIXME: What is happening here. What does "OR he is not in the roster at all" mean
|
# FIXME: What is happening here. What does "OR he is not in the roster at all" mean
|
||||||
if not ctrl:
|
if not ctrl:
|
||||||
self.new_chat(contact, account, resource=resource_for_chat)
|
gajim.interface.new_chat(contact, account, \
|
||||||
|
resource=resource_for_chat)
|
||||||
if path and not self.dragging and gajim.config.get(
|
if path and not self.dragging and gajim.config.get(
|
||||||
'scroll_roster_to_last_message'):
|
'scroll_roster_to_last_message'):
|
||||||
# we curently see contact in our roster OR he
|
# we curently see contact in our roster OR he
|
||||||
|
@ -2222,7 +2095,7 @@ class RosterWindow:
|
||||||
self.make_menu()
|
self.make_menu()
|
||||||
|
|
||||||
def on_bookmark_menuitem_activate(self, widget, account, bookmark):
|
def on_bookmark_menuitem_activate(self, widget, account, bookmark):
|
||||||
self.join_gc_room(account, bookmark['jid'], bookmark['nick'],
|
gajim.interface.join_gc_room(account, bookmark['jid'], bookmark['nick'],
|
||||||
bookmark['password'])
|
bookmark['password'])
|
||||||
|
|
||||||
def on_send_server_message_menuitem_activate(self, widget, account):
|
def on_send_server_message_menuitem_activate(self, widget, account):
|
||||||
|
@ -3424,7 +3297,7 @@ class RosterWindow:
|
||||||
gajim.contacts.get_contact_with_highest_priority(account, jid)
|
gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||||
if jid == gajim.get_jid_from_account(account):
|
if jid == gajim.get_jid_from_account(account):
|
||||||
resource = contact.resource
|
resource = contact.resource
|
||||||
self.on_open_chat_window(widget, contact, account, \
|
gajim.interface.on_open_chat_window(contact, account, \
|
||||||
resource = resource, session = session)
|
resource = resource, session = session)
|
||||||
|
|
||||||
def on_roster_treeview_row_activated(self, widget, path, col = 0):
|
def on_roster_treeview_row_activated(self, widget, path, col = 0):
|
||||||
|
@ -4940,8 +4813,8 @@ class RosterWindow:
|
||||||
icon = state_images[icon_name]
|
icon = state_images[icon_name]
|
||||||
item.set_image(icon)
|
item.set_image(icon)
|
||||||
sub_menu.append(item)
|
sub_menu.append(item)
|
||||||
item.connect('activate', self.on_open_chat_window, c, account,
|
item.connect('activate', gajim.interface.on_open_chat_window, \
|
||||||
c.resource)
|
c, account, c.resource)
|
||||||
|
|
||||||
else: # one resource
|
else: # one resource
|
||||||
start_chat_menuitem.connect('activate',
|
start_chat_menuitem.connect('activate',
|
||||||
|
@ -5043,12 +4916,14 @@ class RosterWindow:
|
||||||
blocked = True
|
blocked = True
|
||||||
break
|
break
|
||||||
if blocked:
|
if blocked:
|
||||||
send_custom_status_menuitem.set_image(gtkgui_helpers.load_icon('offline'))
|
send_custom_status_menuitem.set_image( \
|
||||||
|
gtkgui_helpers.load_icon('offline'))
|
||||||
send_custom_status_menuitem.set_sensitive(False)
|
send_custom_status_menuitem.set_sensitive(False)
|
||||||
elif gajim.interface.status_sent_to_users.has_key(account) and \
|
elif gajim.interface.status_sent_to_users.has_key(account) and \
|
||||||
jid in gajim.interface.status_sent_to_users[account]:
|
jid in gajim.interface.status_sent_to_users[account]:
|
||||||
send_custom_status_menuitem.set_image(
|
send_custom_status_menuitem.set_image(
|
||||||
gtkgui_helpers.load_icon(gajim.interface.status_sent_to_users[account][jid]))
|
gtkgui_helpers.load_icon( \
|
||||||
|
gajim.interface.status_sent_to_users[account][jid]))
|
||||||
else:
|
else:
|
||||||
icon = gtk.image_new_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_MENU)
|
icon = gtk.image_new_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_MENU)
|
||||||
send_custom_status_menuitem.set_image(icon)
|
send_custom_status_menuitem.set_image(icon)
|
||||||
|
@ -5096,7 +4971,7 @@ class RosterWindow:
|
||||||
status_menuitems.append(status_menuitem)
|
status_menuitems.append(status_menuitem)
|
||||||
if len(contacts) > 1: # several resources
|
if len(contacts) > 1: # several resources
|
||||||
start_chat_menuitem.set_submenu(self.build_resources_submenu(contacts,
|
start_chat_menuitem.set_submenu(self.build_resources_submenu(contacts,
|
||||||
account, self.on_open_chat_window))
|
account, gajim.interface.on_open_chat_window))
|
||||||
send_file_menuitem.set_submenu(self.build_resources_submenu(contacts,
|
send_file_menuitem.set_submenu(self.build_resources_submenu(contacts,
|
||||||
account, self.on_send_file_menuitem_activate))
|
account, self.on_send_file_menuitem_activate))
|
||||||
execute_command_menuitem.set_submenu(self.build_resources_submenu(
|
execute_command_menuitem.set_submenu(self.build_resources_submenu(
|
||||||
|
@ -5104,7 +4979,7 @@ class RosterWindow:
|
||||||
|
|
||||||
else: # one resource
|
else: # one resource
|
||||||
start_chat_menuitem.connect('activate',
|
start_chat_menuitem.connect('activate',
|
||||||
self.on_open_chat_window, contact, account)
|
gajim.interface.on_open_chat_window, contact, account)
|
||||||
execute_command_menuitem.connect('activate', self.on_execute_command,
|
execute_command_menuitem.connect('activate', self.on_execute_command,
|
||||||
contact, account, contact.resource)
|
contact, account, contact.resource)
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ class Systray:
|
||||||
jid, account)
|
jid, account)
|
||||||
gajim.interface.msg_win_mgr.get_window(jid, account).window.present()
|
gajim.interface.msg_win_mgr.get_window(jid, account).window.present()
|
||||||
elif contact:
|
elif contact:
|
||||||
gajim.interface.roster.new_chat(contact, account)
|
gajim.interface.new_chat(contact, account)
|
||||||
gajim.interface.msg_win_mgr.get_window(jid, account).set_active_tab(
|
gajim.interface.msg_win_mgr.get_window(jid, account).set_active_tab(
|
||||||
jid, account)
|
jid, account)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue