Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def join_gc_room(self, account, room_jid, nick, password):
'''joins the room immediatelly'''
if gajim.interface.msg_win_mgr.has_window(room_jid) and \
gajim.gc_connected[account][room_jid]:
dialogs.ErrorDialog(_('You are already in room %s') % room_jid
).get_response()
return
invisible_show = gajim.SHOW_LIST.index('invisible')
if gajim.connections[account].connected == invisible_show:
dialogs.ErrorDialog(_('You cannot join a room while you are invisible')
).get_response()
return
room, server = room_jid.split('@')
if not gajim.interface.msg_win_mgr.has_window(room_jid):
self.new_room(room_jid, nick, account)
gc_win = gajim.interface.msg_win_mgr.get_window(room_jid)
gc_win.set_active_tab(room_jid)
gc_win.window.present()
gajim.connections[account].join_gc(nick, room, server, password)
if password:
gajim.gc_passwords[room_jid] = password
reason = ' '.join(message_array)
gajim.connections[self.account].send_invite(self.room_jid, invitee, reason)
s = _('Invited %(contact_jid)s to %(room_jid)s.') % {
'contact_jid': invitee,
'room_jid': self.room_jid}
self.print_conversation(s, 'info')
self.clear(self.msg_textview)
else:
self.get_command_help(command)
return True
elif command == 'join':
# example: /join room@conference.example.com/nick
if len(message_array):
room_jid = message_array[0]
if room_jid.find('@') < 0:
room_jid = room_jid + '@' + gajim.get_server_from_jid(self.room_jid)
else:
room_jid = '@' + gajim.get_server_from_jid(self.room_jid)
if room_jid.find('/') >= 0:
room_jid, nick = room_jid.split('/', 1)
else:
nick = ''
# join_gc window is needed in order to provide for password entry.
if gajim.interface.instances[self.account].has_key('join_gc'):
gajim.interface.instances[self.account]['join_gc'].\
window.present()
else:
try:
gajim.interface.instances[self.account]['join_gc'] =\
dialogs.JoinGroupchatWindow(self.account,
room_jid = room_jid, nick = nick)
except GajimGeneralException:
gajim.connections[gajim.ZEROCONF_ACC_NAME].disable_account()
del gajim.connections[gajim.ZEROCONF_ACC_NAME]
gajim.interface.save_config()
del gajim.interface.instances[gajim.ZEROCONF_ACC_NAME]
del gajim.interface.minimized_controls[gajim.ZEROCONF_ACC_NAME]
del gajim.nicks[gajim.ZEROCONF_ACC_NAME]
del gajim.block_signed_in_notifications[gajim.ZEROCONF_ACC_NAME]
del gajim.groups[gajim.ZEROCONF_ACC_NAME]
gajim.contacts.remove_account(gajim.ZEROCONF_ACC_NAME)
del gajim.gc_connected[gajim.ZEROCONF_ACC_NAME]
del gajim.automatic_rooms[gajim.ZEROCONF_ACC_NAME]
del gajim.to_be_removed[gajim.ZEROCONF_ACC_NAME]
del gajim.newly_added[gajim.ZEROCONF_ACC_NAME]
del gajim.sleeper_state[gajim.ZEROCONF_ACC_NAME]
del gajim.encrypted_chats[gajim.ZEROCONF_ACC_NAME]
del gajim.last_message_time[gajim.ZEROCONF_ACC_NAME]
del gajim.status_before_autoaway[gajim.ZEROCONF_ACC_NAME]
del gajim.transport_avatar[gajim.ZEROCONF_ACC_NAME]
del gajim.gajim_optional_features[gajim.ZEROCONF_ACC_NAME]
del gajim.caps_hash[gajim.ZEROCONF_ACC_NAME]
if len(gajim.connections) >= 2:
# Do not merge accounts if only one exists
gajim.interface.roster.regroup = gajim.config.get('mergeaccounts')
else:
gajim.interface.roster.regroup = False
gajim.interface.roster.setup_and_draw_roster()
gajim.interface.roster.set_actions_menu_needs_rebuild()
elif not gajim.config.get('enable_zeroconf') and widget.get_active():
self.xml.get_widget('zeroconf_notebook').set_sensitive(True)
# enable (will create new account if not present)
gajim.connections[gajim.ZEROCONF_ACC_NAME] = common.zeroconf.\
gajim.config.get_per('accounts', account, 'hostname')
#for chat_with
item = gtk.MenuItem(_('as ') + our_jid)
account_menu_for_chat_with.append(item)
group_menu = self.make_groups_submenus_for_chat_with(account)
item.set_submenu(group_menu)
#for new_message
item = gtk.MenuItem(_('as ') + our_jid)
item.connect('activate',\
self.on_new_message_menuitem_activate, account)
account_menu_for_new_message.append(item)
elif len(gajim.connections) == 1: # one account
#one account, no need to show 'as jid
#for chat_with
account = gajim.connections.keys()[0]
group_menu = self.make_groups_submenus_for_chat_with(account)
chat_with_menuitem.set_submenu(group_menu)
#for new message
self.new_message_handler_id = new_message_menuitem.connect(\
'activate', self.on_new_message_menuitem_activate, account)
self.systray_context_menu.popup(None, None, None, event.button, event.time)
self.systray_context_menu.show_all()
self.systray_context_menu.reposition()
def add_caps(self, p):
''' advertise our capabilities in presence stanza (xep-0115)'''
c = p.setTag('c', namespace = common.xmpp.NS_CAPS)
c.setAttr('hash', 'sha-1')
c.setAttr('node', 'http://gajim.org')
c.setAttr('ver', gajim.caps_hash[self.name])
return p
'''Check what type of notifications we want, depending on basic
and the advanced configuration of notifications and do these notifications;
advanced_notif_num holds the number of the first (top most) advanced
notification'''
# First, find what notifications we want
do_popup = False
do_sound = False
do_cmd = False
if event == 'status_change':
new_show = parameters[0]
status_message = parameters[1]
# Default: No popup for status change
elif event == 'contact_connected':
status_message = parameters
j = gajim.get_jid_without_resource(jid)
server = gajim.get_server_from_jid(j)
account_server = account + '/' + server
block_transport = False
if account_server in gajim.block_signed_in_notifications and \
gajim.block_signed_in_notifications[account_server]:
block_transport = True
if helpers.allow_showing_notification(account, 'notify_on_signin') and \
not gajim.block_signed_in_notifications[account] and not block_transport:
do_popup = True
if gajim.config.get_per('soundevents', 'contact_connected',
'enabled') and not gajim.block_signed_in_notifications[account] and \
not block_transport:
do_sound = True
elif event == 'contact_disconnected':
status_message = parameters
if helpers.allow_showing_notification(account, 'notify_on_signout'):
do_popup = True
def load_icos(self):
'''load .ico files and return them to a dic of SHOW --> img_obj'''
iconset = gajim.config.get('iconset')
imgs = {}
path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16', 'icos')
# icon folder for missing icons
path_dcraven_iconset = os.path.join(gajim.DATA_DIR, 'iconsets', 'dcraven',
'16x16', 'icos')
states_list = gajim.SHOW_LIST
# trayicon apart from show holds message state too
states_list.append('message')
for state in states_list:
path_to_ico = os.path.join(path, state + '.ico')
if not os.path.isfile(path_to_ico): # fallback to dcraven iconset
path_to_ico = os.path.join(path_dcraven_iconset, state + '.ico')
if os.path.exists(path_to_ico):
hinst = win32gui.GetModuleHandle(None)
img_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE
try:
def generate(self):
msg_type = self.base_event.stanza.attrs.get('type', None)
if msg_type == u'chat':
self.stanza = self.base_event.stanza
self.conn = self.base_event.conn
self.from_jid = helpers.get_full_jid_from_iq(self.stanza)
self.from_jid_without_resource = gajim.get_jid_without_resource(
self.from_jid)
self.account = self.conn.name
self.from_nickname = gajim.get_contact_name_from_jid( self.account,
self.from_jid_without_resource)
self.msg_text = ''.join(self.stanza.kids[0].data)
return True
return False
pix = self.avatar_image.get_pixbuf()
pix = gtkgui_helpers.get_scaled_pixbuf(pix, 'tooltip')
self.avatar_image.set_from_pixbuf(pix)
table_size = 4
else:
self.avatar_image.set_from_pixbuf(None)
vcard_table = gtk.Table(table_size, 1)
vcard_table.set_property('column-spacing', 2)
vcard_table.set_homogeneous(False)
vcard_current_row = 1
properties = []
name_markup = u'<span>' + \
gobject.markup_escape_text(prim_contact.get_shown_name())\
+ '</span>'
if self.account and prim_contact.jid in gajim.connections[
self.account].blocked_contacts:
name_markup += _(' [blocked]')
if self.account and \
gajim.interface.minimized_controls.has_key(self.account) and \
prim_contact.jid in gajim.interface.minimized_controls[self.account]:
name_markup += _(' [minimized]')
properties.append((name_markup, None))
num_resources = 0
# put contacts in dict, where key is priority
contacts_dict = {}
for contact in contacts:
if contact.resource:
num_resources += 1
if contact.priority in contacts_dict:
contacts_dict[contact.priority].append(contact)
import tooltips
import gtkgui_helpers
from gajim import Contact
from common import gajim
from common import helpers
from common import i18n
try:
import egg.trayicon as trayicon # gnomepythonextras trayicon
except:
try:
import trayicon # our trayicon
except:
gajim.log.debug('No trayicon module available')
pass
_ = i18n._
APP = i18n.APP
gtk.glade.bindtextdomain(APP, i18n.DIR)
gtk.glade.textdomain(APP)
GTKGUI_GLADE = 'gtkgui.glade'
class Systray:
'''Class for icon in the notification area
This class is both base class (for systraywin32.py) and normal class
for trayicon in GNU/Linux'''
def __init__(self):
self.jids = [] # Contain things like [account, jid, type_of_msg]