def notify_process():
    global notifications, notifying, last_notify

    if len(notifications) == 0:
        return


#    if notifying == True:
#        #See Bug #622021 on gnome
#        diff = datetime.now() - last_notify
#        if diff.seconds > 30:
#            logger.debug("30 seconds from the last notification, reactivating")
#            notifying = False
#        else:
#            return

    if not Notify.is_initted():
        logger.warn('The notification library has not been initialized yet')
        return

    while len(notifications) > 0:
        n = notifications.pop(0)
        #n.connect("closed", notify_closed_cb)
        n.show()

    notifying = True
    last_notify = datetime.now()
    #TODO Do it better and configuable
    sound = Sound()
    sound.play(config.add_data_prefix("drip.ogg"))
Esempio n. 2
0
    def __init__(self):
        if Controller.__default:
           raise Controller.__default

        #Prevent various instances
        import os, fcntl, sys, tempfile, getpass
        self.lockfile = os.path.normpath(tempfile.gettempdir() + '/cloudsn-'+getpass.getuser()+'.lock')
        self.fp = open(self.lockfile, 'w')
        try:
            fcntl.lockf(self.fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
        except IOError:
            message = _("Another instance is already running, close it first.")
            logger.warn (message)
            print message
            sys.exit(-1)

        gobject.GObject.__init__(self)
        self.started = False
        self.config = config.SettingsController.get_instance()
        self.config.connect("value-changed", self._settings_changed)
        self.prov_manager = ProviderManager.get_instance()
        self.im = indicator.IndicatorManager.get_instance()
        self.am = account.AccountManager.get_instance()
        self.am.connect("account-added", self._account_added_cb)
        self.am.connect("account-deleted", self._account_deleted_cb)
        self.am.connect("account-changed", self._account_changed_cb)
        self.am.connect("account-active-changed", self._account_active_cb)
        self.am.load_accounts()
        self.accounts_checking = []
        self.nm = networkmanager.NetworkManager()
def notify_process ():
    global notifications, notifying, last_notify

    if len(notifications) == 0:
        return;

#    if notifying == True:
#        #See Bug #622021 on gnome
#        diff = datetime.now() - last_notify
#        if diff.seconds > 30:
#            logger.debug("30 seconds from the last notification, reactivating")
#            notifying = False
#        else:
#            return

    if not Notify.is_initted():
        logger.warn('The notification library has not been initialized yet')
        return

    while len(notifications) > 0:
        n = notifications.pop(0)
        #n.connect("closed", notify_closed_cb)
        n.show()

    notifying= True
    last_notify = datetime.now()
    #TODO Do it better and configuable
    sound = Sound()
    sound.play(config.add_data_prefix("drip.ogg"))
 def activate (self):
     if "activate_command" in self.properties and self.properties["activate_command"] != "":
         logger.debug ("Executing the activate command")
         utils.execute_command (self, self.properties["activate_command"])
     elif "activate_url" in self.properties :
         utils.show_url (self.properties["activate_url"])
     else:
         logger.warn('This account type has not an activate action')
Esempio n. 5
0
 def activate(self):
     if "activate_command" in self.properties and self.properties[
             "activate_command"] != "":
         logger.debug("Executing the activate command")
         utils.execute_command(self, self.properties["activate_command"])
     elif "activate_url" in self.properties:
         utils.show_url(self.properties["activate_url"])
     else:
         logger.warn('This account type has not an activate action')
Esempio n. 6
0
    def __real_update_account(self, acc):
        if acc in self.accounts_checking:
            logger.warn("The account %s is being checked" % (acc.get_name()))
            return

        logger.debug("Starting checker")
        if not acc.get_active():
            logger.debug("The account %s is not active, it will not be updated" % (acc.get_name()))
            return

        self.accounts_checking.append(acc)
        max_notifications = int(float(self.config.get_prefs()["max_notifications"]))
        try:
            logger.debug('Updating account: ' + acc.get_name())

            #Process events to show the main icon
            while gtk.events_pending():
                gtk.main_iteration(False)

            self.am.update_account(acc)

            acc.error_notified = False

            if hasattr(acc, "indicator"):
                self.im.get_indicator().update_account(acc)


            #Process events to show the indicator menu
            while gtk.events_pending():
                gtk.main_iteration(False)

            if acc.get_provider().has_notifications() and \
                    acc.get_show_notifications():
                nots = acc.get_new_unread_notifications()
                message = None
                if len(nots) > max_notifications:
                    notification.notify(acc.get_name(),
                        _("New messages: ") + str(len(nots)),
                        acc.get_icon())

                if len(nots) > 0 and len(nots) <= max_notifications:
                    for n in nots:
                        if n.icon:
                            icon = n.icon
                        else:
                            icon = acc.get_icon()
                        notification.notify(acc.get_name() + ": " + n.sender,
                            n.message,
                            icon)

            self.emit("account-checked", acc)
        except notification.NotificationError, ne:
            logger.exception("Error trying to notify with libnotify: %s", e)
Esempio n. 7
0
    def update_account(self, acc):
        if not self.get_active():
            return
        """acc=None will check all accounts"""
        if self.nm.offline():
            logger.warn ("The network is not connected, the account cannot be updated")
            return

        #TODO Check if the updater is running
        if acc is None:
            for acc in self.am.get_accounts():
                thread.start_new_thread(self.__real_update_account, (acc,))
        else:
            thread.start_new_thread(self.__real_update_account, (acc,))
from cloudsn import logger
from cloudsn.core import config, utils

#TODO If we import the modules but the sound is disabled, we load
#arround 1,5mb of memory

enabled = False
try:
    #TODO Disabled because I need study how to do it with gtk-3
    raise Exception("Sound is unsuported by the moment")
    import pygst
    pygst.require("0.10")
    import gst
    enabled = True
except Exception, e:
    logger.warn("Cloudsn cannot play sounds because pygst >= 0.10 is not installed")

class Sound:
    def __init__(self):
        self.player = None
        self.playing = False

    def play(self, uri):
        global enabled
        if not enabled:
            return

        if not utils.get_boolean(config.SettingsController.get_instance().get_prefs()["enable_sounds"]):
            return

        if uri and self.playing == False:
 def activate (self):
     if "activate_url" in self.properties:
         utils.show_url (self.properties["activate_url"])
     else:
         logger.warn('This account type has not an activate action')