def on_history_manager_window_delete_event(self, widget, event): if not self.AT_LEAST_ONE_DELETION_DONE: Gtk.main_quit() return def on_yes(clicked): self.cur.execute('VACUUM') self.con.commit() Gtk.main_quit() def on_no(): Gtk.main_quit() dialog = dialogs.YesNoDialog( _('Do you want to clean up the database? ' '(STRONGLY NOT RECOMMENDED IF GAJIM IS RUNNING)'), _('Normally allocated database size will not be freed, ' 'it will just become reusable. If you really want to reduce ' 'database filesize, click YES, else click NO.' '\n\nIn case you click YES, please wait…'), on_response_yes=on_yes, on_response_no=on_no) dialog.set_title(_('Database Cleanup')) button_box = dialog.get_children()[0].get_children()[1] button_box.get_children()[0].grab_focus()
def on_ed_response(response): d = dialogs.YesNoDialog( _("Turn off Classic Mode?"), _("Since there was an error starting in Classic Mode would you like to continue by turning it off?" )).run() self.started_in_classic = False d.addCallback(on_dialog_response)
def _on_reactor_start(self): log.debug("_on_reactor_start") self.mainwindow.first_show() if self.config["classic_mode"]: def on_dialog_response(response): if response != Gtk.ResponseType.YES: # The user does not want to turn Classic Mode off, so just quit self.mainwindow.quit() return # Turning off classic_mode self.config["classic_mode"] = False self.__start_non_classic() try: try: client.start_classic_mode() except deluge.error.DaemonRunningError: d = dialogs.YesNoDialog( _("Turn off Classic Mode?"), _("It appears that a Deluge daemon process (deluged) is already running.\n\n\ You will either need to stop the daemon or turn off Classic Mode to continue.") ).run() self.started_in_classic = False d.addCallback(on_dialog_response) except ImportError, e: if "No module named libtorrent" in e.message: d = dialogs.YesNoDialog( _("Enable Thin Client Mode?"), _("Thin client mode is only available because libtorrent is not installed.\n\n\ To use Deluge standalone (Classic mode) please install libtorrent.")).run() self.started_in_classic = False d.addCallback(on_dialog_response) else: raise else: component.start() return
def _on_reactor_start(self): log.debug("_on_reactor_start") self.mainwindow.first_show() if self.config["classic_mode"]: def on_dialog_response(response): if response != gtk.RESPONSE_YES: # The user does not want to turn Classic Mode off, so just quit reactor.stop() return # Turning off classic_mode self.config["classic_mode"] = False self.__start_non_classic() try: client.start_classic_mode() except deluge.error.DaemonRunningError: d = dialogs.YesNoDialog( _("Turn off Classic Mode?"), _("It appears that a Deluge daemon process (deluged) is already running.\n\n\ You will either need to stop the daemon or turn off Classic Mode to continue.") ).run() self.started_in_classic = False d.addCallback(on_dialog_response) except Exception, e: import traceback tb = sys.exc_info() ed = dialogs.ErrorDialog( _("Error Starting Core"), _("There was an error starting the core component which is required to run Deluge in Classic Mode.\n\n\ Please see the details below for more information."), details=traceback.format_exc(tb[2])).run() def on_ed_response(response): d = dialogs.YesNoDialog( _("Turn off Classic Mode?"), _("Since there was an error starting in Classic Mode would you like to continue by turning it off?" )).run() self.started_in_classic = False d.addCallback(on_dialog_response) ed.addCallback(on_ed_response) else: component.start() return
def show_hash_error(self, jid, file_props, account): def on_yes(dummy, fjid, file_props, account): # Delete old file os.remove(file_props.file_name) jid, resource = gajim.get_room_and_nick_from_fjid(fjid) if resource: contact = gajim.contacts.get_contact(account, jid, resource) else: contact = gajim.contacts.get_contact_with_highest_priority( account, jid) fjid = contact.get_full_jid() # Request the file to the sender sid = helpers.get_random_string_16() new_file_props = FilesProp.getNewFileProp(account, sid) new_file_props.file_name = file_props.file_name new_file_props.name = file_props.name new_file_props.desc = file_props.desc new_file_props.size = file_props.size new_file_props.date = file_props.date new_file_props.hash_ = file_props.hash_ new_file_props.type_ = 'r' tsid = gajim.connections[account].start_file_transfer(fjid, new_file_props, True) new_file_props.transport_sid = tsid self.add_transfer(account, contact, new_file_props) if file_props.type_ == 'r': file_name = os.path.basename(file_props.file_name) else: file_name = file_props.name dialogs.YesNoDialog(('File transfer error'), _('The file %(file)s has been received, but it seems to have ' 'been damaged along the way.\nDo you want to download it again?') % \ {'file': file_name}, on_response_yes=(on_yes, jid, file_props, account), type_=Gtk.MessageType.ERROR)
def handle_negotiation(self, form): if form.getField('accept') and not form['accept'] in ('1', 'true'): self.cancelled_negotiation() return # encrypted session states. these are described in stanza_session.py try: # bob responds if form.getType() == 'form' and 'security' in form.asDict(): # we don't support 3-message negotiation as the responder if 'dhkeys' in form.asDict(): self.fail_bad_negotiation( '3 message negotiation not supported ' 'when responding', ('dhkeys', )) return negotiated, not_acceptable, ask_user = self.verify_options_bob( form) if ask_user: def accept_nondefault_options(is_checked): self.dialog.destroy() negotiated.update(ask_user) self.respond_e2e_bob(form, negotiated, not_acceptable) def reject_nondefault_options(): self.dialog.destroy() for key in ask_user.keys(): not_acceptable.append(key) self.respond_e2e_bob(form, negotiated, not_acceptable) self.dialog = dialogs.YesNoDialog( _('Confirm these session ' 'options'), _('''The remote client wants to negotiate an session with these features: %s Are these options acceptable?''') % (negotiation.describe_features(ask_user)), on_response_yes=accept_nondefault_options, on_response_no=reject_nondefault_options) else: self.respond_e2e_bob(form, negotiated, not_acceptable) return # alice accepts elif self.status == 'requested-e2e' and form.getType() == 'submit': negotiated, not_acceptable, ask_user = self.verify_options_alice( form) if ask_user: def accept_nondefault_options(is_checked): dialog.destroy() negotiated.update(ask_user) try: self.accept_e2e_alice(form, negotiated) except exceptions.NegotiationError, details: self.fail_bad_negotiation(details) def reject_nondefault_options(): self.reject_negotiation() dialog.destroy() dialog = dialogs.YesNoDialog( _('Confirm these session options'), _('The remote client selected these options:\n\n%s\n\n' 'Continue with the session?') % (negotiation.describe_features(ask_user)), on_response_yes=accept_nondefault_options, on_response_no=reject_nondefault_options) else: try: self.accept_e2e_alice(form, negotiated) except exceptions.NegotiationError, details: self.fail_bad_negotiation(details) return
if pid_alive(): if (show_remote_gajim_roster()): print("Gajim is already running, bringing the roster to front...") sys.exit(0) pixs = [] for size in (16, 32, 48, 64, 128): pix = gtkgui_helpers.get_icon_pixmap('gajim', size) if pix: pixs.append(pix) if pixs: # set the icon to all windows Gtk.Window.set_default_icon_list(pixs) pritext = _('Gajim is already running') sectext = _('Another instance of Gajim seems to be running\nRun anyway?') dialog = dialogs.YesNoDialog(pritext, sectext) dialog.popup() if dialog.run() != Gtk.ResponseType.YES: sys.exit(3) dialog.destroy() # run anyway, delete pid and useless global vars if os.path.exists(pid_filename): os.remove(pid_filename) del pix del pritext del sectext dialog.destroy() # Create .gajim dir pid_dir = os.path.dirname(pid_filename) if not os.path.exists(pid_dir):
def handle_negotiation(self, form): if form.getField('accept') and not form['accept'] in ('1', 'true'): self.cancelled_negotiation() return # encrypted session states. these are described in stanza_session.py try: if form.getType() == 'form' and 'security' in form.asDict(): security_options = [x[1] for x in form.getField('security').\ getOptions()] if security_options == ['none']: self.respond_archiving(form) else: # bob responds # we don't support 3-message negotiation as the responder if 'dhkeys' in form.asDict(): self.fail_bad_negotiation('3 message negotiation not ' 'supported when responding', ('dhkeys',)) return negotiated, not_acceptable, ask_user = \ self.verify_options_bob(form) if ask_user: def accept_nondefault_options(is_checked): self.dialog.destroy() negotiated.update(ask_user) self.respond_e2e_bob(form, negotiated, not_acceptable) def reject_nondefault_options(): self.dialog.destroy() for key in ask_user.keys(): not_acceptable.append(key) self.respond_e2e_bob(form, negotiated, not_acceptable) self.dialog = dialogs.YesNoDialog(_('Confirm these ' 'session options'), _('The remote client wants to negotiate a session ' 'with these features:\n\n%s\n\nAre these options ' 'acceptable?''') % ( negotiation.describe_features(ask_user)), on_response_yes=accept_nondefault_options, on_response_no=reject_nondefault_options, transient_for=self.control.parent_win.window) else: self.respond_e2e_bob(form, negotiated, not_acceptable) return elif self.status == 'requested-archiving' and form.getType() == \ 'submit': try: self.archiving_accepted(form) except exceptions.NegotiationError as details: self.fail_bad_negotiation(details) return # alice accepts elif self.status == 'requested-e2e' and form.getType() == 'submit': negotiated, not_acceptable, ask_user = self.verify_options_alice( form) if ask_user: def accept_nondefault_options(is_checked): if dialog: dialog.destroy() if is_checked: allow_no_log_for = gajim.config.get_per( 'accounts', self.conn.name, 'allow_no_log_for').split() jid = str(self.jid) if jid not in allow_no_log_for: allow_no_log_for.append(jid) gajim.config.set_per('accounts', self.conn.name, 'allow_no_log_for', ' '.join(allow_no_log_for)) negotiated.update(ask_user) try: self.accept_e2e_alice(form, negotiated) except exceptions.NegotiationError as details: self.fail_bad_negotiation(details) def reject_nondefault_options(): self.reject_negotiation() dialog.destroy() allow_no_log_for = gajim.config.get_per('accounts', self.conn.name, 'allow_no_log_for').split() if str(self.jid) in allow_no_log_for: dialog = None accept_nondefault_options(False) else: dialog = dialogs.YesNoDialog(_('Confirm these session ' 'options'), _('The remote client selected these options:\n\n%s' '\n\nContinue with the session?') % ( negotiation.describe_features(ask_user)), _('Always accept for this contact'), on_response_yes = accept_nondefault_options, on_response_no = reject_nondefault_options, transient_for=self.control.parent_win.window) else: try: self.accept_e2e_alice(form, negotiated) except exceptions.NegotiationError as details: self.fail_bad_negotiation(details) return elif self.status == 'responded-archiving' and form.getType() == \ 'result': try: self.we_accept_archiving(form) except exceptions.NegotiationError as details: self.fail_bad_negotiation(details) return elif self.status == 'responded-e2e' and form.getType() == 'result': try: self.accept_e2e_bob(form) except exceptions.NegotiationError as details: self.fail_bad_negotiation(details) return elif self.status == 'identified-alice' and form.getType() == 'result': try: self.final_steps_alice(form) except exceptions.NegotiationError as details: self.fail_bad_negotiation(details) return except exceptions.Cancelled: # user cancelled the negotiation self.reject_negotiation() return if form.getField('terminate') and\ form.getField('terminate').getValue() in ('1', 'true'): self.acknowledge_termination() self.conn.delete_session(str(self.jid), self.thread_id) return # non-esession negotiation. this isn't very useful, but i'm keeping it # around to test my test suite. if form.getType() == 'form': if not self.control: jid, resource = gajim.get_room_and_nick_from_fjid(str(self.jid)) account = self.conn.name contact = gajim.contacts.get_contact(account, str(self.jid), resource) if not contact: contact = gajim.contacts.create_contact(jid=jid, account=account, resource=resource, show=self.conn.get_status()) gajim.interface.new_chat(contact, account, resource=resource, session=self) negotiation.FeatureNegotiationWindow(account, str(self.jid), self, form)
def handle_negotiation(self, form): if form.getField('accept') and not form['accept'] in ('1', 'true'): self.cancelled_negotiation() return # encrypted session states. these are described in stanza_session.py try: if form.getType() == 'form' and 'security' in form.asDict(): security_options = [x[1] for x in form.getField('security').\ getOptions()] if security_options == ['none']: self.respond_archiving(form) else: # bob responds # we don't support 3-message negotiation as the responder if 'dhkeys' in form.asDict(): self.fail_bad_negotiation( '3 message negotiation not ' 'supported when responding', ('dhkeys', )) return negotiated, not_acceptable, ask_user = \ self.verify_options_bob(form) if ask_user: def accept_nondefault_options(is_checked): self.dialog.destroy() negotiated.update(ask_user) self.respond_e2e_bob(form, negotiated, not_acceptable) def reject_nondefault_options(): self.dialog.destroy() for key in ask_user.keys(): not_acceptable.append(key) self.respond_e2e_bob(form, negotiated, not_acceptable) self.dialog = dialogs.YesNoDialog( _('Confirm these ' 'session options'), _('The remote client wants to negotiate a session ' 'with these features:\n\n%s\n\nAre these options ' 'acceptable?' '') % (negotiation.describe_features(ask_user)), on_response_yes=accept_nondefault_options, on_response_no=reject_nondefault_options, transient_for=self.control.parent_win.window) else: self.respond_e2e_bob(form, negotiated, not_acceptable) return elif self.status == 'requested-archiving' and form.getType() == \ 'submit': try: self.archiving_accepted(form) except exceptions.NegotiationError, details: self.fail_bad_negotiation(details) return # alice accepts elif self.status == 'requested-e2e' and form.getType() == 'submit': negotiated, not_acceptable, ask_user = self.verify_options_alice( form) if ask_user: def accept_nondefault_options(is_checked): if dialog: dialog.destroy() if is_checked: allow_no_log_for = gajim.config.get_per( 'accounts', self.conn.name, 'allow_no_log_for').split() jid = str(self.jid) if jid not in allow_no_log_for: allow_no_log_for.append(jid) gajim.config.set_per( 'accounts', self.conn.name, 'allow_no_log_for', ' '.join(allow_no_log_for)) negotiated.update(ask_user) try: self.accept_e2e_alice(form, negotiated) except exceptions.NegotiationError, details: self.fail_bad_negotiation(details) def reject_nondefault_options(): self.reject_negotiation() dialog.destroy() allow_no_log_for = gajim.config.get_per( 'accounts', self.conn.name, 'allow_no_log_for').split() if str(self.jid) in allow_no_log_for: dialog = None accept_nondefault_options(False) else: dialog = dialogs.YesNoDialog( _('Confirm these session ' 'options'), _('The remote client selected these options:\n\n%s' '\n\nContinue with the session?') % (negotiation.describe_features(ask_user)), _('Always accept for this contact'), on_response_yes=accept_nondefault_options, on_response_no=reject_nondefault_options, transient_for=self.control.parent_win.window)