Пример #1
0
    def update_config(self, event=None):
        # Kill all timers
        if self.popup == 1: self.destroy_popup()
        if self.init == 1: gtk.timeout_remove(self.maintimer)
        # Run the configuration dialog
        self.configWindow.show()

        # Update timeout. Convert seconds to miliseconds (SB)
        self.maintimer = gtk.timeout_add(self.options["checkinterval"] * 1000,
                                         self.mail_check)

        # Update user/pass
        self.connection = gmailatom.GmailAtom(self.options["gmailusername"],
                                              self.options["gmailpassword"],
                                              self.options['proxy'])
        self.connect()
        self.mail_check()

        # Update popup location
        self.window.resize(POPUP_WIDTH, 1)
        self.width, self.height = self.window.get_size()
        self.height += self.options["voffset"]
        self.width += self.options["hoffset"]
        self.window.move(gtk.gdk.screen_width() - self.width,
                         gtk.gdk.screen_height() - self.height)

        # Update language
        self.lang = self.configWindow.get_lang()

        # Update popup menu
        self.popup_menu = GmailPopupMenu.GmailPopupMenu(self)

        return
Пример #2
0
 def connect(self):
     # If connecting, cancel connection
     if self.dont_connect == 1:
         print "connection attemp suspended"
         return 0
     self.dont_connect = 1
     print "connecting..."
     self._tooltip.set_tip(self.tray, self.lang.get_string(13))
     while gtk.events_pending():
         gtk.main_iteration(gtk.TRUE)
     # Attemp connection
     try:
         self.connection = gmailatom.GmailAtom(
             self.options['gmailusername'], self.options['gmailpassword'],
             self.options['proxy'])
         self.connection.refreshInfo()
         print "connection successful... continuing"
         self._tooltip.set_tip(self.tray, self.lang.get_string(14))
         self.dont_connect = 0
         return 1
     except:
         print "login failed, will retry"
         self._tooltip.set_tip(self.tray, self.lang.get_string(15))
         #self.default_label = "<span size='large' ><u><i>"+self.lang.get_string(15)+"</i></u></span>\n\n"+self.lang.get_string(16)
         self.default_label = "<span size='medium'><b>" + self.lang.get_string(15) + \
           "</b></span>\n <span size='small'>" + self.lang.get_string(16)+"</span>"
         self.label.set_markup(self.default_label)
         self.show_popup()
         self.dont_connect = 0
         return 0
Пример #3
0
    def onOkay(self, widget, callback_data=None):
        """
		Callback function for OK button: 
		* assign values to the config variable,
		* check username && password options
		* write config to file
		"""
        errorString = ""

        # Apply changes to options dictionary
        for curElement in self.configElements:
            if (type(self.options[curElement[0]]) == int):
                self.options[curElement[0]] = int(curElement[2].get_text())
            else:
                self.options[curElement[0]] = curElement[2].get_text()
        iter = self.cbo_langs.get_active_iter()
        self.options["lang"] = self.cbo_langs.get_model().get_value(iter, 0)

        # Before writing, check for bad values
        if not self.offlineMode:
            try:
                tempLogin = gmailatom.GmailAtom(self.options["gmailusername"],
                                                self.options["gmailpassword"],
                                                self.options["proxy"])
                tempLogin.refreshInfo()
            except:
                print "Unexpected error:", sys.exc_info()[0]
                errorString = errorString + "Login appears to be invalid\n"

        if (len(errorString) == 0):
            # No errors, so write to config file
            for key in self.options.keys():
                self.config.set("options", key, self.options[key])

            # Obfuscate password in config file (SB)
            self.config.set("options", "gmailpassword",
                            self.pass_enc(self.options["gmailpassword"]))

            if (not self.savePassword.get_active()):
                self.config.remove_option("options", "gmailusername")
                self.config.remove_option("options", "gmailpassword")

            fd = open(self.loadedConfig, 'w')
            os.chmod(self.loadedConfig, 0600)
            self.config.write(fd)
            fd.close()
            gtk.main_quit()
            self.hide()
        else:
            dialog = gtk.MessageDialog(buttons=gtk.BUTTONS_OK,
                                       type=gtk.MESSAGE_ERROR)
            dialog.set_position(gtk.WIN_POS_CENTER)
            dialog.set_markup(errorString)
            dialog.run()
            dialog.destroy()
Пример #4
0
 def connect(self):
     # If connecting, cancel connection
     if self.dont_connect == 1:
         print "connection attemp suspended"
         return 0
     self.dont_connect = 1
     print "connecting..."
     self.tray.set_tooltip(self.lang.get_string(13))  # 13 = Connecting...
     while gtk.events_pending():
         gtk.main_iteration(gtk.TRUE)
     # Attemp connection
     try:
         self.connection = gmailatom.GmailAtom(
             self.options['gmailusername'], self.options['gmailpassword'],
             self.options['proxy'])
         self.connection.refreshInfo()
         print "connection successful... continuing"
         self.tray.set_tooltip_text(
             self.lang.get_string(14))  # 14 = Connected
         self.set_tray_state(STATE_OK)
         self.dont_connect = 0
         return 1
     except:
         print "login failed, will retry"
         self.tray.set_tooltip_text(
             self.lang.get_string(15))  # 15 = Connection failed
         self.default_label = "<span size='large' ><u><i>" + self.lang.get_string(
             15) + "</i></u></span>\n\n" + self.lang.get_string(
                 16
             )  # 16 = Connection to your Gmail inbox failed, will retry
         self.label.set_markup(self.default_label)
         self.set_tray_state(STATE_ERROR)
         self.show_popup()
         self.dont_connect = 0
         #~ #self.pixbuf = gtk.gdk.pixbuf_new_from_file( ICON3_PATH )
         #~ self.pixbuf = icon_theme.load_icon("mail-mark-important", 24, gtk.ICON_LOOKUP_FORCE_SVG)
         #~ scaled_buf = self.pixbuf.scale_simple(24,24,gtk.gdk.INTERP_BILINEAR)
         #~ self.tray.set_from_pixbuf(scaled_buf)
         return 0