Skip to content
Browse files

Show notifications on connection errors. Fix bug with IMAP prefs.

We show the notification the fist time
  • Loading branch information...
1 parent a528d30 commit 6558e0ddf4e3de6ee6d3e9a220b3b33dc5f2e6c2 @chuchiperriman committed Feb 5, 2010
View
9 TODO
@@ -18,18 +18,21 @@ Milestone 0.3.0
[ ] Study and add Twitter support
[ ] Control the screensaver. If it is active don't show notifications
and show it when the user gets active again.
+[ ] Reimplement the logging
+[ ] Creating new account sometimes are not shown in the indicator (created a
+ new bug in launchpad for libindicate)
Milestone 0.2.0
===============
-[ ] Show general errors with notifications (if we can) or stderr
-[ ] Show the first connection error on an account (Not in every check).
+[X] Show general errors with notifications (if we can) or stderr
+[X] Show the first connection error on an account (Not in every check).
[X] If cloudsn is running in a session and open a new one, it tell "cloudsn is running"
[X] Option to enable/disable accounts
[ ] Add GMail tags support
[ ] Add IMAP folders support
[ ] Add Imap SSL and port configuration
[ ] Add POP3 SSL and port configuration
-[ ] Creating new account sometimes are not shown in the indicator
+[ ] Configure when notify the GReader feeds (if > 30 or if 10 new feeds...)
[X] Show e-mail suject in the notification
[X] cloudsn doesn't check the first time it starts with the session
View
1 cloudsn-preferences-local.sh
@@ -0,0 +1 @@
+PYTHONPATH=src/ python src/cloudsn/ui/preferences.py
View
8 src/cloudsn/core/account.py
@@ -19,6 +19,7 @@ def __init__ (self, properties, provider):
self.provider = provider
self.total_unread = 0
self.last_update = None
+ self.error_notified = False
if 'active' not in self.properties:
self.properties["active"] = True
@@ -38,12 +39,7 @@ def get_provider (self):
return self.provider
def get_active (self):
- val = self.properties["active"]
- if isinstance (val,bool):
- return val
- elif isinstance (val, str):
- return val.strip().lower() == 'true'
- return True
+ return utils.get_boolean(self.properties["active"])
def set_active(self, active):
self.properties["active"] = bool(active)
View
8 src/cloudsn/core/controller.py
@@ -1,5 +1,5 @@
from cloudsn.core.provider import Provider, ProviderManager
-from cloudsn.core import account, config, networkmanager, notification
+from cloudsn.core import account, config, networkmanager, notification, utils
from cloudsn.ui import preferences
from cloudsn import logger
import indicate
@@ -189,6 +189,7 @@ def run(self):
try:
logger.debug('Updating account: ' + acc.get_name())
self.am.update_account(acc)
+ acc.error_notified = False
acc.indicator.set_property_int("count", acc.get_total_unread())
if acc.get_provider().has_notifications():
nots = acc.get_new_unread_notifications()
@@ -210,6 +211,11 @@ def run(self):
logger.exception("Error trying to notify with libnotify: %s", e)
except Exception as e:
logger.exception("Error trying to update the account %s: %s", acc.get_name(), e)
+ if not acc.error_notified:
+ notification.notify (_("Error checking account %s") % (acc.get_name()),
+ str(e),
+ utils.get_error_pixbuf())
+ acc.error_notified = True
logger.debug("Ending checker")
View
14 src/cloudsn/core/utils.py
@@ -1,4 +1,5 @@
import gconf
+import gtk
import os
import subprocess
from email.header import decode_header
@@ -33,6 +34,19 @@ def mime_decode(str):
else:
return strn.decode(encoding, "replace")
+def get_boolean (value):
+ if isinstance (value,bool):
+ return value
+ elif isinstance (value, str):
+ return value.strip().lower() == 'true'
+ return False
+
+def get_error_pixbuf():
+ icons = gtk.icon_theme_get_default()
+ l = gtk.ICON_LOOKUP_USE_BUILTIN
+ return icons.load_icon(gtk.STOCK_DIALOG_ERROR, 32, l)
+
if __name__ == "__main__":
print get_default_mail_reader()
open_mail_reader()
+
View
18 src/cloudsn/providers/imapprovider.py
@@ -74,7 +74,7 @@ def edit_account_dialog(self, acc):
builder.get_object("username_entry").set_text(acc["username"])
builder.get_object("password_entry").set_text(acc["password"])
builder.get_object("port_entry").set_text(str(acc["port"]))
- builder.get_object("ssl_check").set_active(acc["ssl"])
+ builder.get_object("ssl_check").set_active(utils.get_boolean(acc["ssl"]))
account = None
if dialog.run() == 0:
acc["host"] = builder.get_object("host_entry").get_text()
@@ -105,18 +105,12 @@ def __init__(self, host, user, password,
self.mbox = None
def __connect(self):
- try:
- if not self.ssl:
- self.mbox = imaplib.IMAP4(self.host, self.port)
- else:
- self.mbox = imaplib.IMAP4_SSL(self.host, self.port)
- except Exception:
- raise ImapBoxConnectionError()
+ if not self.ssl:
+ self.mbox = imaplib.IMAP4(self.host, self.port)
+ else:
+ self.mbox = imaplib.IMAP4_SSL(self.host, self.port)
- try:
- self.mbox.login(self.user, self.password)
- except Exception, e:
- raise ImapBoxAuthError()
+ self.mbox.login(self.user, self.password)
def get_mails(self):
View
8 src/cloudsn/ui/preferences.py
@@ -137,6 +137,7 @@ def load_window(self):
self.account_name_entry = builder.get_object("account_name_entry");
self.startup_check = builder.get_object("startup_check")
for prov in self.pm.get_providers():
+ print prov
self.providers_store.append([prov.get_icon(), prov.get_name()])
for acc in self.am.get_accounts():
self.store.append([acc.get_provider().get_icon(), acc.get_name(), self.__get_account_date(acc), acc.get_active()])
@@ -168,8 +169,11 @@ def run(self):
return result
def main ():
- for prov in provider.ProviderManager.get_instance().get_providers():
- prov.register_accounts()
+ import cloudsn.cloudsn
+ import cloudsn.core.controller
+ cloudsn.cloudsn.setup_locale_and_gettext()
+ #account.AccountManager.get_instance().load_accounts()
+ cloudsn.core.controller.Controller.get_instance()
prefs = Preferences.get_instance()
prefs.dialog_only = True
prefs.run()

0 comments on commit 6558e0d

Please sign in to comment.
Something went wrong with that request. Please try again.