Ejemplo n.º 1
0
 def on_default_msg_treemodel_row_changed(self, model, path, iter_):
     status = model[iter_][0]
     message = model[iter_][2]
     message = helpers.to_one_line(message)
     app.config.set_per('defaultstatusmsg', status, 'enabled',
                        model[iter_][3])
     app.config.set_per('defaultstatusmsg', status, 'message', message)
Ejemplo n.º 2
0
 def on_dialog_response(self, dialog, response):
     if response == Gtk.ResponseType.OK:
         beg, end = self.message_buffer.get_bounds()
         message = self.message_buffer.get_text(beg, end, True).strip()
         message = helpers.remove_invalid_xml_chars(message)
         msg = helpers.to_one_line(message)
         if self.show:
             app.config.set_per('statusmsg', '_last_' + self.show,
                                'message', msg)
             if self.show_pep:
                 app.config.set_per('statusmsg', '_last_' + self.show,
                                    'activity', self.pep_dict['activity'])
                 app.config.set_per('statusmsg', '_last_' + self.show,
                                    'subactivity',
                                    self.pep_dict['subactivity'])
                 app.config.set_per('statusmsg', '_last_' + self.show,
                                    'activity_text',
                                    self.pep_dict['activity_text'])
                 app.config.set_per('statusmsg', '_last_' + self.show,
                                    'mood', self.pep_dict['mood'])
                 app.config.set_per('statusmsg', '_last_' + self.show,
                                    'mood_text', self.pep_dict['mood_text'])
     else:
         message = None  # user pressed Cancel button or X wm button
     self.dialog.destroy()
     self.on_response(message, self.pep_dict)
Ejemplo n.º 3
0
        def on_ok(msg_name):
            msg_text = status_message_to_save_as_preset
            msg_text_1l = helpers.to_one_line(msg_text)
            if not msg_name:  # msg_name was ''
                msg_name = msg_text_1l

            def _on_ok2():
                self.preset_messages_dict[msg_name] = [
                    msg_text,
                    self.pep_dict.get('activity'),
                    self.pep_dict.get('subactivity'),
                    self.pep_dict.get('activity_text'),
                    self.pep_dict.get('mood'),
                    self.pep_dict.get('mood_text')
                ]
                app.config.set_per('statusmsg', msg_name, 'message',
                                   msg_text_1l)
                app.config.set_per('statusmsg', msg_name, 'activity',
                                   self.pep_dict.get('activity'))
                app.config.set_per('statusmsg', msg_name, 'subactivity',
                                   self.pep_dict.get('subactivity'))
                app.config.set_per('statusmsg', msg_name, 'activity_text',
                                   self.pep_dict.get('activity_text'))
                app.config.set_per('statusmsg', msg_name, 'mood',
                                   self.pep_dict.get('mood'))
                app.config.set_per('statusmsg', msg_name, 'mood_text',
                                   self.pep_dict.get('mood_text'))

            if msg_name in self.preset_messages_dict:
                NewConfirmationDialog(
                    _('Overwrite'),
                    _('Overwrite Status Message?'),
                    _('Preset name is already in use. '
                      'Do you want to overwrite this preset?'), [
                          DialogButton.make('Cancel'),
                          DialogButton.make(
                              'Remove', text=_('_Overwrite'), callback=_on_ok2)
                      ],
                    transient_for=self.dialog).show()
                return
            app.config.add_per('statusmsg', msg_name)
            _on_ok2()
            iter_ = self.message_liststore.append((msg_name, ))
            # select in combobox the one we just saved
            self.message_combobox.set_active_iter(iter_)
Ejemplo n.º 4
0
 def save_status_messages(self, model):
     for msg in app.config.get_per('statusmsg'):
         app.config.del_per('statusmsg', msg)
     iter_ = model.get_iter_first()
     while iter_:
         val = model[iter_][0]
         if model[iter_][1]:  # We have a preset message
             if not val:  # No title, use message text for title
                 val = model[iter_][1]
             app.config.add_per('statusmsg', val)
             msg = helpers.to_one_line(model[iter_][1])
             app.config.set_per('statusmsg', val, 'message', msg)
             i = 2
             # Store mood / activity
             for subname in ('activity', 'subactivity', 'activity_text',
                             'mood', 'mood_text'):
                 val2 = model[iter_][i]
                 if not val2:
                     val2 = ''
                 app.config.set_per('statusmsg', val, subname, val2)
                 i += 1
         iter_ = model.iter_next(iter_)
Ejemplo n.º 5
0
        def _on_save_preset(preset_name):
            msg_text_one_line = to_one_line(message_text)
            if not preset_name:
                preset_name = msg_text_one_line

            def _on_set_config():
                activity = ''
                subactivity = ''
                mood = ''
                if self._ui.activity_switch.get_active():
                    activity = self._pep_dict['activity']
                    subactivity = self._pep_dict['subactivity']
                if self._ui.mood_switch.get_active():
                    mood = self._pep_dict['mood']
                app.settings.set_status_preset_setting(
                    preset_name, 'message', msg_text_one_line)
                app.settings.set_status_preset_setting(
                    preset_name, 'activity', activity)
                app.settings.set_status_preset_setting(
                    preset_name, 'subactivity', subactivity)
                app.settings.set_status_preset_setting(
                    preset_name, 'mood', mood)
                self._get_presets()

            if preset_name in self._presets:
                ConfirmationDialog(
                    _('Overwrite'),
                    _('Overwrite Status Message?'),
                    _('This name is already in use. Do you want to '
                      'overwrite this preset?'),
                    [DialogButton.make('Cancel'),
                     DialogButton.make('Remove',
                                       text=_('_Overwrite'),
                                       callback=_on_set_config)],
                    transient_for=self).show()
                return

            _on_set_config()
Ejemplo n.º 6
0
    def _add_jid(self, jid, type_):
        # check if jid is conform to RFC and stringprep it
        try:
            jid = helpers.parse_jid(jid)
        except helpers.InvalidFormat as s:
            pritext = _('Invalid User ID')
            ErrorDialog(pritext, str(s))
            return

        # No resource in jid
        if jid.find('/') >= 0:
            pritext = _('Invalid User ID')
            ErrorDialog(pritext, _('The user ID must not contain a resource.'))
            return

        if jid == app.get_jid_from_account(self.account):
            pritext = _('Invalid User ID')
            ErrorDialog(pritext,
                        _('You cannot add yourself to your contact list.'))
            return

        if not app.account_is_connected(self.account):
            ErrorDialog(_('Account Offline'),
                        _('Your account must be online to add new contacts.'))
            return

        nickname = self.nickname_entry.get_text() or ''
        # get value of account combobox, if account was not specified
        if not self.account:
            model = self.account_combobox.get_model()
            index = self.account_combobox.get_active()
            self.account = model[index][1]

        # Check if jid is already in roster
        if jid in app.contacts.get_jid_list(self.account):
            c = app.contacts.get_first_contact_from_jid(self.account, jid)
            if _('Not in contact list') not in c.groups and c.sub in ('both',
                                                                      'to'):
                ErrorDialog(_('Contact Already in Contact List'),
                            _('This contact is already in your contact list.'))
                return

        if type_ == 'jabber':
            message_buffer = self.message_textview.get_buffer()
            start_iter = message_buffer.get_start_iter()
            end_iter = message_buffer.get_end_iter()
            message = message_buffer.get_text(start_iter, end_iter, True)
            if self.save_message_checkbutton.get_active():
                msg = helpers.to_one_line(message)
                app.config.set_per('accounts', self.account,
                                   'subscription_request_msg', msg)
        else:
            message = ''
        group = self.group_comboboxentry.get_child().get_text()
        groups = []
        if group:
            groups = [group]
        auto_auth = self.auto_authorize_checkbutton.get_active()
        app.interface.roster.req_sub(self,
                                     jid,
                                     message,
                                     self.account,
                                     groups=groups,
                                     nickname=nickname,
                                     auto_auth=auto_auth)
        self.destroy()