Ejemplo n.º 1
0
 def _nec_new_acc_connected(self, obj):
     """
     Connection to server succeded, present the form to the user
     """
     # We receive events from all accounts from GED
     if obj.conn.name != self.account:
         return
     if self.update_progressbar_timeout_id is not None:
         GLib.source_remove(self.update_progressbar_timeout_id)
     self.back_button.show()
     self.forward_button.show()
     self.is_form = obj.is_form
     empty_config = True
     if obj.is_form:
         dataform = dataforms.extend_form(node=obj.config)
         self.data_form_widget = dataforms_widget.DataFormWidget()
         self.data_form_widget.selectable = True
         self.data_form_widget.set_data_form(dataform)
         empty_config = False
     else:
         self.data_form_widget = FakeDataFormWidget(obj.config)
         for field in obj.config:
             if field in ('key', 'instructions', 'x', 'registered'):
                 continue
             empty_config = False
             break
     self.data_form_widget.show_all()
     self.xml.get_object('form_vbox').pack_start(
         self.data_form_widget, True, True, 0)
     if empty_config:
         self.forward_button.set_sensitive(False)
         self.notebook.set_current_page(4)  # show form page
         return
     self.ssl_fingerprint_sha1 = obj.ssl_fingerprint_sha1
     self.ssl_fingerprint_sha256 = obj.ssl_fingerprint_sha256
     self.ssl_cert = obj.ssl_cert
     if obj.ssl_msg:
         # An SSL warning occured, show it
         hostname = app.connections[self.account].new_account_info[
             'hostname']
         self.xml.get_object('ssl_label').set_markup(_(
             '<b>Security Warning</b>'
             '\n\nThe authenticity of the %(hostname)s SSL certificate could'
             ' be invalid.\nSSL Error: %(error)s\n'
             'Do you still want to connect to this server?') % {
             'hostname': hostname, 'error': obj.ssl_msg})
         if obj.errnum in (18, 27):
             text = _(
                 'Add this certificate to the list of trusted '
                 'certificates.\nSHA-1 fingerprint of the certificate:\n'
                 '%(sha1)s\nSHA-256 fingerprint of the certificate:\n'
                 '%(sha256)s') % {'sha1': obj.ssl_fingerprint_sha1,
                                  'sha256': obj.ssl_fingerprint_sha256}
             self.xml.get_object('ssl_checkbutton').set_label(text)
         else:
             self.xml.get_object('ssl_checkbutton').set_no_show_all(True)
             self.xml.get_object('ssl_checkbutton').hide()
         self.notebook.set_current_page(3)  # show SSL page
     else:
         self.notebook.set_current_page(4)  # show form page
Ejemplo n.º 2
0
    def _nec_search_form_received(self, obj):
        if self.pulse_id:
            GLib.source_remove(self.pulse_id)
        self.progressbar.hide()
        self.label.hide()

        if obj.is_dataform:
            self.is_form = True
            self.data_form_widget = dataforms_widget.DataFormWidget()
            self.dataform = dataforms.ExtendForm(node=obj.data)
            self.data_form_widget.set_sensitive(True)
            try:
                self.data_form_widget.data_form = self.dataform
            except dataforms.Error:
                self.label.set_text(_('Error in received dataform'))
                self.label.show()
                return
            if self.data_form_widget.title:
                self.window.set_title('%s - Search - Gajim' % \
                        self.data_form_widget.title)
        else:
            self.is_form = False
            self.data_form_widget = config.FakeDataForm(obj.data)

        self.data_form_widget.show_all()
        self.search_vbox.pack_start(self.data_form_widget, True, True, 0)
        self.search_button.set_sensitive(True)
Ejemplo n.º 3
0
    def initiate(self):

        self.pulse_id = None      # to satisfy self.setup_pulsing()
        self.commandlist = None   # a list of (commandname, commanddescription)

        # command's data
        self.sessionid = None
        self.dataform = None
        self.allow_stage3_close = False

        # creating data forms widget
        if self.data_form_widget:
            self.sending_form_stage_vbox.remove(self.data_form_widget)
            self.data_form_widget.destroy()
        self.data_form_widget = dataforms_widget.DataFormWidget()
        self.data_form_widget.show()
        self.sending_form_stage_vbox.pack_start(self.data_form_widget, True, True, 0)

        if self.commandnode:
            # Execute command
            self.stage3()
        else:
            # setting initial stage
            self.stage1()

        # displaying the window
        self.window.set_title(_('Ad-hoc Commands - Gajim'))
        self.xml.connect_signals(self)
        self.window.show_all()

        self.restart_button.set_sensitive(False)
Ejemplo n.º 4
0
    def __init__(self, account, jid, session, form):
        self.account = account
        self.jid = jid
        self.form = form
        self.session = session

        self.xml = gtkgui_helpers.get_gtk_builder('data_form_window.ui',
                                                  'data_form_window')
        self.window = self.xml.get_object('data_form_window')

        config_vbox = self.xml.get_object('config_vbox')
        dataform = dataforms.ExtendForm(node=self.form)
        self.data_form_widget = dataforms_widget.DataFormWidget(dataform)
        self.data_form_widget.show()
        config_vbox.pack_start(self.data_form_widget, True, True, 0)

        self.xml.connect_signals(self)
        self.window.show_all()
Ejemplo n.º 5
0
    def __init__(self, account, room_jid, form=None):
        self.account = account
        self.room_jid = room_jid
        self.form = form
        self.remove_button = {}
        self.affiliation_treeview = {}
        self.start_users_dict = {} # list at the beginning
        self.affiliation_labels = {'outcast': _('Ban List'),
            'member': _('Member List'), 'owner': _('Owner List'),
            'admin':_('Administrator List')}

        self.xml = gtkgui_helpers.get_gtk_builder('data_form_window.ui',
            'data_form_window')
        self.window = self.xml.get_object('data_form_window')
        self.window.set_transient_for(app.interface.roster.window)

        if self.form:
            config_vbox = self.xml.get_object('config_vbox')
            self.data_form_widget = dataforms_widget.DataFormWidget(self.form)
            # hide scrollbar of this data_form_widget, we already have in this
            # widget
            sw = self.data_form_widget.xml.get_object(
                'single_form_scrolledwindow')
            sw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER)
            if self.form.title:
                self.xml.get_object('title_label').set_text(self.form.title)
            else:
                self.xml.get_object('title_hseparator').set_no_show_all(True)
                self.xml.get_object('title_hseparator').hide()

            self.data_form_widget.show()
            config_vbox.pack_start(self.data_form_widget, True, True, 0)
        else:
            self.xml.get_object('title_label').set_no_show_all(True)
            self.xml.get_object('title_label').hide()
            self.xml.get_object('title_hseparator').set_no_show_all(True)
            self.xml.get_object('title_hseparator').hide()
            self.xml.get_object('config_hseparator').set_no_show_all(True)
            self.xml.get_object('config_hseparator').hide()

        # Draw the edit affiliation list things
        add_on_vbox = self.xml.get_object('add_on_vbox')

        for affiliation in self.affiliation_labels.keys():
            self.start_users_dict[affiliation] = {}
            hbox = Gtk.HBox(spacing=5)
            add_on_vbox.pack_start(hbox, False, True, 0)

            label = Gtk.Label(label=self.affiliation_labels[affiliation])
            hbox.pack_start(label, False, True, 0)

            bb = Gtk.HButtonBox()
            bb.set_layout(Gtk.ButtonBoxStyle.END)
            bb.set_spacing(5)
            hbox.pack_start(bb, True, True, 0)
            add_button = Gtk.Button(stock=Gtk.STOCK_ADD)
            add_button.connect('clicked', self.on_add_button_clicked,
                affiliation)
            bb.pack_start(add_button, True, True, 0)
            self.remove_button[affiliation] = Gtk.Button(stock=Gtk.STOCK_REMOVE)
            self.remove_button[affiliation].set_sensitive(False)
            self.remove_button[affiliation].connect('clicked',
                    self.on_remove_button_clicked, affiliation)
            bb.pack_start(self.remove_button[affiliation], True, True, 0)

            # jid, reason, nick, role
            liststore = Gtk.ListStore(str, str, str, str)
            self.affiliation_treeview[affiliation] = Gtk.TreeView(liststore)
            self.affiliation_treeview[affiliation].get_selection().set_mode(
                Gtk.SelectionMode.MULTIPLE)
            self.affiliation_treeview[affiliation].connect('cursor-changed',
                self.on_affiliation_treeview_cursor_changed, affiliation)
            renderer = Gtk.CellRendererText()
            col = Gtk.TreeViewColumn(_('JID'), renderer)
            col.add_attribute(renderer, 'text', 0)
            col.set_resizable(True)
            col.set_sort_column_id(0)
            self.affiliation_treeview[affiliation].append_column(col)

            if affiliation == 'outcast':
                renderer = Gtk.CellRendererText()
                renderer.set_property('editable', True)
                renderer.connect('edited', self.on_cell_edited)
                col = Gtk.TreeViewColumn(_('Reason'), renderer)
                col.add_attribute(renderer, 'text', 1)
                col.set_resizable(True)
                col.set_sort_column_id(1)
                self.affiliation_treeview[affiliation].append_column(col)
            elif affiliation == 'member':
                renderer = Gtk.CellRendererText()
                col = Gtk.TreeViewColumn(_('Nick'), renderer)
                col.add_attribute(renderer, 'text', 2)
                col.set_resizable(True)
                col.set_sort_column_id(2)
                self.affiliation_treeview[affiliation].append_column(col)
                renderer = Gtk.CellRendererText()
                col = Gtk.TreeViewColumn(_('Role'), renderer)
                col.add_attribute(renderer, 'text', 3)
                col.set_resizable(True)
                col.set_sort_column_id(3)
                self.affiliation_treeview[affiliation].append_column(col)

            sw = Gtk.ScrolledWindow()
            sw.add(self.affiliation_treeview[affiliation])
            add_on_vbox.pack_start(sw, True, True, 0)
            con = app.connections[self.account]
            con.get_module('MUC').get_affiliation(self.room_jid, affiliation)

        self.xml.connect_signals(self)
        self.window.connect('delete-event', self.on_cancel_button_clicked)
        self.window.show_all()