def set_entity_time(self, obj): if obj.conn.name != self.account: return if self.xml.get_object('information_notebook').get_n_pages() < 5: return if self.gc_contact: if obj.fjid != self.contact.jid: return elif gajim.get_jid_without_resource(obj.fjid) != self.contact.jid: return i = 0 time_s = '' while i in self.time_info: if self.time_info[i]['resource'] == obj.resource: if obj.time_info: self.time_info[i]['time'] = obj.time_info else: self.time_info[i]['time'] = Q_('?Time:Unknown') else: if not self.time_info[i]['time']: self.time_info[i]['time'] = Q_('?Time:Unknown') if i > 0: time_s += '\n' time_s += self.time_info[i]['time'] i += 1 self.xml.get_object('time_label').set_text(time_s) self.entity_time_arrived = True
def set_os_info(self, obj): if obj.conn.name != self.account: return if self.xml.get_object('information_notebook').get_n_pages() < 5: return if obj.fjid != self.contact.jid and obj.fjid != self.real_jid: return i = 0 client = '' os = '' while i in self.os_info: if not self.os_info[i]['resource'] or \ self.os_info[i]['resource'] == obj.resource: self.os_info[i]['client'] = obj.client_info self.os_info[i]['os'] = obj.os_info if i > 0: client += '\n' os += '\n' client += self.os_info[i]['client'] os += self.os_info[i]['os'] i += 1 if client == '': client = Q_('?Client:Unknown') if os == '': os = Q_('?OS:Unknown') self.xml.get_object('client_name_version_label').set_text(client) self.xml.get_object('os_label').set_text(os) self.os_info_arrived = True self.test_remove_progressbar()
def set_os_info(self, resource, client_info, os_info): if self.xml.get_widget('information_notebook').get_n_pages() < 5: return i = 0 client = '' os = '' while i in self.os_info: if not self.os_info[i]['resource'] or \ self.os_info[i]['resource'] == resource: self.os_info[i]['client'] = client_info self.os_info[i]['os'] = os_info if i > 0: client += '\n' os += '\n' client += self.os_info[i]['client'] os += self.os_info[i]['os'] i += 1 if client == '': client = Q_('?Client:Unknown') if os == '': os = Q_('?OS:Unknown') self.xml.get_widget('client_name_version_label').set_text(client) self.xml.get_widget('os_label').set_text(os) self.os_info_arrived = True self.test_remove_progressbar()
def on_run(self): self.fill_treeview() #Prepare comboboxes self.print_status_combobox = self.xml.get_object('print_status_combobox') model = gtk.ListStore(str, str) self.option_list = {'': _('Default'), 'all': Q_('?print_status:All'), 'in_and_out': _('Enter and leave only'), 'none': Q_('?print_status:None')} opts = sorted(self.option_list.keys()) for opt in opts: model.append([self.option_list[opt], opt]) self.print_status_combobox.set_model(model) self.print_status_combobox.set_active(1) #Prepare import_from combobox model = gtk.ListStore(str) for account in self.accounts: model.append([account,]) for account_jid in self.plugin.config: if account_jid not in self.plugin.config_default_values and \ account_jid not in self.jids: model.append([account_jid,]) self.import_from_combo.set_model(model) #Prepare import_to combobox model = gtk.ListStore(str) for account in self.accounts: model.append([account,]) self.import_to_combo.set_model(model) self.selection = self.view.get_selection() self.selection.connect('changed', self.bookmark_selected) #Prepare input fields self.title_entry = self.xml.get_object('title_entry') self.title_entry.connect('changed', self.on_title_entry_changed) self.nick_entry = self.xml.get_object('nick_entry') self.nick_entry.connect('changed', self.on_nick_entry_changed) self.server_entry = self.xml.get_object('server_entry') self.server_entry.connect('changed', self.on_server_entry_changed) self.room_entry = self.xml.get_object('room_entry') self.room_entry_changed_id = self.room_entry.connect('changed', self.on_room_entry_changed) self.pass_entry = self.xml.get_object('pass_entry') self.pass_entry.connect('changed', self.on_pass_entry_changed) self.autojoin_checkbutton = self.xml.get_object('autojoin_checkbutton') self.minimize_checkbutton = self.xml.get_object('minimize_checkbutton') self.xml.connect_signals(self) self.connect('hide', self.on_hide) self.show_all() self.view.set_cursor((0,))
def set_os_info(self, obj): if obj.conn.name != self.account: return if self.xml.get_object('information_notebook').get_n_pages() < 5: return if self.gc_contact: if obj.fjid != self.contact.jid: return elif gajim.get_jid_without_resource(obj.fjid) != self.contact.jid: return i = 0 client = '' os = '' while i in self.os_info: if self.os_info[i]['resource'] == obj.resource: if obj.client_info: self.os_info[i]['client'] = obj.client_info else: self.os_info[i]['client'] = Q_('?Client:Unknown') if obj.os_info: self.os_info[i]['os'] = obj.os_info else: self.os_info[i]['os'] = Q_('?OS:Unknown') else: if not self.os_info[i]['client']: self.os_info[i]['client'] = Q_('?Client:Unknown') if not self.os_info[i]['os']: self.os_info[i]['os'] = Q_('?OS:Unknown') if i > 0: client += '\n' os += '\n' client += self.os_info[i]['client'] os += self.os_info[i]['os'] i += 1 self.xml.get_object('client_name_version_label').set_text(client) self.xml.get_object('os_label').set_text(os) self.os_info_arrived = True
def colorize_affiliation(affiliation): """ Color the affiliation of a MUC participant inside the tooltip by it's semantics. Color palette is the Tango. """ formatted = "<span foreground='%s'>%s</span>" color = None if affiliation.startswith(Q_("?Group Chat Contact Affiliation:None")): color = gajim.config.get('tooltip_affiliation_none_color') elif affiliation.startswith(_("Member")): color = gajim.config.get('tooltip_affiliation_member_color') elif affiliation.startswith(_("Administrator")): color = gajim.config.get('tooltip_affiliation_administrator_color') elif affiliation.startswith(_("Owner")): color = gajim.config.get('tooltip_affiliation_owner_color') if color: affiliation = formatted % (color, affiliation) return affiliation
def colorize_status(status): """ Colorize the status message inside the tooltip by it's semantics. Color palette is the Tango. """ formatted = "<span foreground='%s'>%s</span>" color = None if status.startswith(Q_("?user status:Available")): color = gajim.config.get('tooltip_status_online_color') elif status.startswith(_("Free for Chat")): color = gajim.config.get('tooltip_status_free_for_chat_color') elif status.startswith(_("Away")): color = gajim.config.get('tooltip_status_away_color') elif status.startswith(_("Busy")): color = gajim.config.get('tooltip_status_busy_color') elif status.startswith(_("Not Available")): color = gajim.config.get('tooltip_status_na_color') elif status.startswith(_("Offline")): color = gajim.config.get('tooltip_status_offline_color') if color: status = formatted % (color, status) return status
def set_entity_time(self, obj): if obj.conn.name != self.account: return if self.xml.get_object('information_notebook').get_n_pages() < 5: return if obj.fjid != self.contact.jid and obj.fjid != self.real_jid: return i = 0 time_s = '' while i in self.time_info: if not self.time_info[i]['resource'] or \ self.time_info[i]['resource'] == obj.resource: self.time_info[i]['time'] = obj.time_info if i > 0: time_s += '\n' time_s += self.time_info[i]['time'] i += 1 if time_s == '': time_s = Q_('?Time:Unknown') self.xml.get_object('time_label').set_text(time_s) self.entity_time_arrived = True self.test_remove_progressbar()
def __init__(self): self.argv_len = len(sys.argv) # define commands dict. Prototype : # { # 'command': [comment, [list of arguments] ] # } # # each argument is defined as a tuple: # (argument name, help on argument, is mandatory) # self.commands = { 'help': [ _('Shows a help on specific command'), [ #User gets help for the command, specified by this parameter (_('command'), _('show help on command'), False) ] ], 'toggle_roster_appearance': [_('Shows or hides the roster window'), []], 'show_next_pending_event': [_('Pops up a window with the next pending event'), []], 'list_contacts': [ _('Prints a list of all contacts in the roster. Each contact ' 'appears on a separate line'), [(Q_('?CLI:account'), _('show only contacts of the given account'), False)] ], 'list_accounts': [_('Prints a list of registered accounts'), []], 'change_status': [ _('Changes the status of account or accounts'), [ #offline, online, chat, away, xa, dnd, invisible should not be translated (Q_('?CLI:status'), _('one of: offline, online, chat, away, xa, dnd, invisible. If not set, use account\'s previous status' ), False), (Q_('?CLI:message'), _('status message'), False), (Q_('?CLI:account'), _('change status of account "account". ' 'If not specified, try to change status of all accounts that have ' '"sync with global status" option set'), False) ] ], 'set_priority': [ _('Changes the priority of account or accounts'), [(Q_('?CLI:priority'), _('priority you want to give to the account'), True), (Q_('?CLI:account'), _('change the priority of the given account. ' 'If not specified, change status of all accounts that have' ' "sync with global status" option set'), False)] ], 'open_chat': [ _('Shows the chat dialog so that you can send messages to a contact' ), [('jid', _('JID of the contact that you want to chat with'), True), (Q_('?CLI:account'), _('if specified, contact is taken from the ' 'contact list of this account'), False), (Q_('?CLI:message'), _('message content. The account must be specified or ""'), False)] ], 'send_chat_message': [ _('Sends new chat message to a contact in the roster. Both OpenPGP key ' 'and account are optional. If you want to set only \'account\', ' 'without \'OpenPGP key\', just set \'OpenPGP key\' to \'\'.' ), [ ('jid', _('JID of the contact that will receive the message'), True), (Q_('?CLI:message'), _('message contents'), True), (_('pgp key'), _('if specified, the message will be encrypted ' 'using this public key'), False), (Q_('?CLI:account'), _('if specified, the message will be sent ' 'using this account'), False), ] ], 'send_single_message': [ _('Sends new single message to a contact in the roster. Both OpenPGP key ' 'and account are optional. If you want to set only \'account\', ' 'without \'OpenPGP key\', just set \'OpenPGP key\' to \'\'.' ), [ ('jid', _('JID of the contact that will receive the message'), True), (_('subject'), _('message subject'), True), (Q_('?CLI:message'), _('message contents'), True), (_('pgp key'), _('if specified, the message will be encrypted ' 'using this public key'), False), (Q_('?CLI:account'), _('if specified, the message will be sent ' 'using this account'), False), ] ], 'send_groupchat_message': [ _('Sends new message to a groupchat you\'ve joined.'), [ ('room_jid', _('JID of the room that will receive the message'), True), (Q_('?CLI:message'), _('message contents'), True), (Q_('?CLI:account'), _('if specified, the message will be sent ' 'using this account'), False), ] ], 'contact_info': [ _('Gets detailed info on a contact'), [('jid', _('JID of the contact'), True)] ], 'account_info': [ _('Gets detailed info on a account'), [('account', _('Name of the account'), True)] ], 'send_file': [ _('Sends file to a contact'), [(_('file'), _('File path'), True), ('jid', _('JID of the contact'), True), (Q_('?CLI:account'), _('if specified, file will be sent using this ' 'account'), False)] ], 'prefs_list': [_('Lists all preferences and their values'), []], 'prefs_put': [ _('Sets value of \'key\' to \'value\'.'), [(_('key=value'), _('\'key\' is the name of the preference, ' '\'value\' is the value to set it to'), True)] ], 'prefs_del': [ _('Deletes a preference item'), [(_('key'), _('name of the preference to be deleted'), True)] ], 'prefs_store': [ _('Writes the current state of Gajim preferences to the .config ' 'file'), [] ], 'remove_contact': [ _('Removes contact from roster'), [('jid', _('JID of the contact'), True), (Q_('?CLI:account'), _('if specified, contact is taken from the ' 'contact list of this account'), False)] ], 'add_contact': [ _('Adds contact to roster'), [(_('jid'), _('JID of the contact'), True), (Q_('?CLI:account'), _('Adds new contact to this account'), False)] ], 'get_status': [ _('Returns current status (the global one unless account is specified)' ), [(Q_('?CLI:account'), '', False)] ], 'get_status_message': [ _('Returns current status message (the global one unless account is specified)' ), [(Q_('?CLI:account'), '', False)] ], 'get_unread_msgs_number': [_('Returns number of unread messages'), []], 'start_chat': [ _('Opens \'Start Chat\' dialog'), [(Q_('?CLI:account'), _('Starts chat, using this account'), True)] ], 'send_xml': [ _('Sends custom XML'), [('xml', _('XML to send'), True), ('account', _('Account in which the xml will be sent; ' 'if not specified, xml will be sent to all accounts'), False)] ], 'change_avatar': [ _('Change the avatar'), [('picture', _('Picture to use'), True), ('account', _('Account in which the avatar will be set; ' 'if not specified, the avatar will be set for all accounts' ), False)] ], 'handle_uri': [ _('Handle a xmpp:/ uri'), [(Q_('?CLI:uri'), _('URI to handle'), True), (Q_('?CLI:account'), _('Account in which you want to handle it'), False), (Q_('?CLI:message'), _('Message content'), False)] ], 'join_room': [ _('Join a MUC room'), [(Q_('?CLI:room'), _('Room JID'), True), (Q_('?CLI:nick'), _('Nickname to use'), False), (Q_('?CLI:password'), _('Password to enter the room'), False), (Q_('?CLI:account'), _('Account from which you want to enter the ' 'room'), False)] ], 'check_gajim_running': [_('Check if Gajim is running'), []], 'toggle_ipython': [_('Shows or hides the ipython window'), []], } self.sbus = None if self.argv_len < 2 or sys.argv[1] not in self.commands.keys(): # no args or bad args send_error(self.compose_help()) self.command = sys.argv[1] if self.command == 'help': if self.argv_len == 3: print( self.help_on_command( sys.argv[2]).encode(PREFERRED_ENCODING)) else: print(self.compose_help().encode(PREFERRED_ENCODING)) sys.exit(0) if self.command == 'handle_uri': self.handle_uri() if self.command == 'check_gajim_running': print(self.check_gajim_running()) sys.exit(0) self.init_connection() self.check_arguments() if self.command == 'contact_info': if self.argv_len < 3: send_error(_('Missing argument "contact_jid"')) try: res = self.call_remote_method() except exceptions.ServiceNotAvailable: # At this point an error message has already been displayed sys.exit(1) else: self.print_result(res)
def __init__(self): self.xml = gtkgui_helpers.get_gtk_builder('features_window.ui') self.window = self.xml.get_object('features_window') self.window.set_transient_for(gajim.interface.roster.window) treeview = self.xml.get_object('features_treeview') self.desc_label = self.xml.get_object('feature_desc_label') # {name: (available_function, unix_text, windows_text)} self.features = { _('SSL certificate validation'): (self.pyopenssl_available, _('A library used to validate server certificates to ensure a secure connection.' ), _('Requires python-pyopenssl > 0.12 and pyasn1.'), _('Requires python-pyopenssl > 0.12 and pyasn1.')), _('Bonjour / Zeroconf'): (self.zeroconf_available, _('Serverless chatting with autodetected clients in a local network.' ), _('Requires python-avahi.'), _('Requires pybonjour and bonjour SDK running (http://developer.apple.com/opensource/).' )), _('Command line'): (self.dbus_available, _('A script to control Gajim via commandline.'), _('Requires python-dbus.'), _('Feature not available under Windows.')), _('OpenPGP message encryption'): (self.gpg_available, _('Ability to encrypting chat messages with OpenPGP.'), _('Requires gpg and python-gnupg (http://code.google.com/p/python-gnupg/).' ), _('Requires gpg.exe in PATH.')), _('Network-manager'): (self.network_manager_available, _('Autodetection of network status.'), _('Requires gnome-network-manager and python-dbus.'), _('Feature not available under Windows.')), _('Password encryption'): (self.some_keyring_available, _('Passwords can be stored securely and not just in plaintext.'), _('Requires libsecret and a provider (such as GNOME Keyring and KSecretService).' ), _('On Windows the Windows Credential Vault is used.')), _('Spell Checker'): (self.speller_available, _('Spellchecking of composed messages.'), _('Requires libgtkspell.'), _('Requires libgtkspell and libenchant.')), _('Notification'): (self.notification_available, _('Passive popups notifying for new events.'), _('Requires python-notify or instead python-dbus in conjunction with notification-daemon.' ), _('Feature not available under Windows.')), _('Automatic status'): (self.idle_available, _('Ability to measure idle time, in order to set auto status.'), _('Requires libxss library.'), _('Requires python2.5.')), _('End to End message encryption'): (self.pycrypto_available, _('Encrypting chat messages.'), _('Requires python-crypto.'), _('Requires python-crypto.')), _('RST Generator'): (self.docutils_available, _('Generate XHTML output from RST code (see http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html).' ), _('Requires python-docutils.'), _('Requires python-docutils.')), _('Audio / Video'): (self.farstream_available, _('Ability to start audio and video chat.'), _('Requires gir1.2-farstream-0.2, gir1.2-gstreamer-1.0, gstreamer1.0-libav and gstreamer1.0-plugins-ugly.' ), _('Feature not available under Windows.')), _('UPnP-IGD'): (self.gupnp_igd_available, _('Ability to request your router to forward port for file transfer.' ), _('Requires python-gupnp-igd.'), _('Feature not available under Windows.')), _('UPower'): (self.upower_available, _('Ability to disconnect properly just before suspending the machine.' ), _('Requires upower and python-dbus.'), _('Feature not available under Windows.')), } # name, supported self.model = Gtk.ListStore(str, bool) treeview.set_model(self.model) col = Gtk.TreeViewColumn(Q_('?features:Available')) treeview.append_column(col) cell = Gtk.CellRendererToggle() cell.set_property('radio', True) col.pack_start(cell, True) col.add_attribute(cell, 'active', 1) col = Gtk.TreeViewColumn(_('Feature')) treeview.append_column(col) cell = Gtk.CellRendererText() col.pack_start(cell, True) col.add_attribute(cell, 'text', 0) # Fill model for feature in self.features: func = self.features[feature][0] rep = func() self.model.append([feature, rep]) self.model.set_sort_column_id(0, Gtk.SortType.ASCENDING) self.xml.connect_signals(self) self.window.show_all() self.xml.get_object('close_button').grab_focus()
def fill_jabber_page(self): self.xml.get_object('nickname_label').set_markup( '<b><span size="x-large">' + self.contact.get_shown_name() + '</span></b>') self.xml.get_object('jid_label').set_text(self.contact.jid) subscription_label = self.xml.get_object('subscription_label') ask_label = self.xml.get_object('ask_label') if self.gc_contact: self.xml.get_object('subscription_title_label').set_markup( Q_("?Role in Group Chat:<b>Role:</b>")) uf_role = helpers.get_uf_role(self.gc_contact.role) subscription_label.set_text(uf_role) self.xml.get_object('ask_title_label').set_markup( _("<b>Affiliation:</b>")) uf_affiliation = helpers.get_uf_affiliation( self.gc_contact.affiliation) ask_label.set_text(uf_affiliation) else: uf_sub = helpers.get_uf_sub(self.contact.sub) subscription_label.set_text(uf_sub) eb = self.xml.get_object('subscription_label_eventbox') if self.contact.sub == 'from': tt_text = _( "This contact is interested in your presence information, but you are not interested in their presence" ) elif self.contact.sub == 'to': tt_text = _( "You are interested in the contact's presence information, but it is not mutual" ) elif self.contact.sub == 'both': tt_text = _( "The contact and you want to exchange presence information" ) else: # None tt_text = _( "You and the contact have a mutual disinterest in each-others presence information" ) eb.set_tooltip_text(tt_text) uf_ask = helpers.get_uf_ask(self.contact.ask) ask_label.set_text(uf_ask) eb = self.xml.get_object('ask_label_eventbox') if self.contact.ask == 'subscribe': tt_text = _( "You are waiting contact's answer about your subscription request" ) else: tt_text = _("There is no pending subscription request.") eb.set_tooltip_text(tt_text) resources = '%s (%s)' % (self.contact.resource, str(self.contact.priority)) uf_resources = self.contact.resource + _(' resource with priority ')\ + str(self.contact.priority) if not self.contact.status: self.contact.status = '' # Request list time status only if contact is offline if self.contact.show == 'offline': if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) gajim.connections[self.account].request_last_status_time( j, r, self.contact.jid) else: gajim.connections[self.account].request_last_status_time( self.contact.jid, '') # do not wait for os_info if contact is not connected or has error # additional check for observer is needed, as show is offline for him if self.contact.show in ('offline', 'error')\ and not self.contact.is_observer(): self.os_info_arrived = True else: # Request os info if contact is connected if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) GLib.idle_add(gajim.connections[self.account].request_os_info, j, r, self.contact.jid) else: GLib.idle_add(gajim.connections[self.account].request_os_info, self.contact.jid, self.contact.resource) # do not wait for entity_time if contact is not connected or has error # additional check for observer is needed, as show is offline for him if self.contact.show in ('offline', 'error')\ and not self.contact.is_observer(): self.entity_time_arrived = True else: # Request entity time if contact is connected if self.gc_contact: j, r = gajim.get_room_and_nick_from_fjid(self.real_jid) GLib.idle_add(gajim.connections[self.account].\ request_entity_time, j, r, self.contact.jid) else: GLib.idle_add(gajim.connections[self.account].\ request_entity_time, self.contact.jid, self.contact.resource) self.os_info = { 0: { 'resource': self.real_resource, 'client': '', 'os': '' } } self.time_info = {0: {'resource': self.real_resource, 'time': ''}} i = 1 contact_list = gajim.contacts.get_contacts(self.account, self.contact.jid) if contact_list: for c in contact_list: if c.resource != self.contact.resource: resources += '\n%s (%s)' % (c.resource, str(c.priority)) uf_resources += '\n' + c.resource + \ _(' resource with priority ') + str(c.priority) if c.show not in ('offline', 'error'): GLib.idle_add(gajim.connections[self.account].\ request_os_info, c.jid, c.resource) GLib.idle_add(gajim.connections[self.account].\ request_entity_time, c.jid, c.resource) self.os_info[i] = { 'resource': c.resource, 'client': '', 'os': '' } self.time_info[i] = {'resource': c.resource, 'time': ''} i += 1 self.xml.get_object('resource_prio_label').set_text(resources) resource_prio_label_eventbox = self.xml.get_object( 'resource_prio_label_eventbox') resource_prio_label_eventbox.set_tooltip_text(uf_resources) self.fill_status_label() if self.gc_contact: # If we know the real jid, remove the resource from vcard request gajim.connections[self.account].request_vcard( self.real_jid_for_vcard, self.gc_contact.get_full_jid()) else: gajim.connections[self.account].request_vcard(self.contact.jid)