diff src/core/sat_main.py @ 587:952322b1d490

Remove trailing whitespaces.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:34 +0100
parents 133078b82ca8
children d1b4805124a1
line wrap: on
line diff
--- a/src/core/sat_main.py	Fri Jan 18 17:55:27 2013 +0100
+++ b/src/core/sat_main.py	Fri Jan 18 17:55:34 2013 +0100
@@ -65,7 +65,7 @@
     return "sat_id_"+str(sat_id)
 
 class SAT(service.Service):
-   
+
     def get_next_id(self):
         return sat_next_id()
 
@@ -87,26 +87,26 @@
         """Save a constant"""
         if CONST.has_key(name):
             error(_('Trying to redefine a constant'))
-            raise Exception  
+            raise Exception
         CONST[name] = value
-    
+
     def __init__(self):
         #TODO: standardize callback system
-        
-        self.__general_cb_map = {}  #callback called for general reasons (key = name) 
+
+        self.__general_cb_map = {}  #callback called for general reasons (key = name)
         self.__private_data = {}  #used for internal callbacks (key = id)
         self.profiles = {}
         self.plugins = {}
         self.menus = {} #used to know which new menus are wanted by plugins
-        
+
         self.memory=Memory(self)
-        
+
         local_dir = self.memory.getConfig('', 'local_dir')
         if not os.path.exists(local_dir):
             os.makedirs(local_dir)
 
-        self.trigger = TriggerManager() #trigger are used to change SàT behaviour 
-        
+        self.trigger = TriggerManager() #trigger are used to change SàT behaviour
+
         self.bridge=DBusBridge()
         self.bridge.register("getVersion", lambda: self.get_const('client_version'))
         self.bridge.register("getProfileName", self.memory.getProfileName)
@@ -147,8 +147,8 @@
         self.bridge.register("getMenus", self.getMenus)
         self.bridge.register("getMenuHelp", self.getMenuHelp)
         self.bridge.register("callMenu", self.callMenu)
-    
-        self.memory.initialized.addCallback(self._postMemoryInit) 
+
+        self.memory.initialized.addCallback(self._postMemoryInit)
 
     def _postMemoryInit(self, ignore):
         """Method called after memory initialization is done"""
@@ -159,7 +159,7 @@
     def _import_plugins(self):
         """Import all plugins found in plugins directory"""
         import sat.plugins
-        plugins_path = os.path.dirname(sat.plugins.__file__) 
+        plugins_path = os.path.dirname(sat.plugins.__file__)
         plug_lst = [os.path.splitext(plugin)[0] for plugin in map(os.path.basename,glob(os.path.join(plugins_path,"plugin*.py")))]
         __plugins_to_import = {} #plugins we still have to import
         for plug in plug_lst:
@@ -198,11 +198,11 @@
             self.plugins[import_name].is_handler = False
         #TODO: test xmppclient presence and register handler parent
 
-    
+
     def connect(self, profile_key = '@DEFAULT@'):
         """Connect to jabber server"""
         self.asyncConnect(profile_key)
-    
+
     def asyncConnect(self, profile_key = '@DEFAULT@'):
         """Connect to jabber server with asynchronous reply
         @param profile_key: %(doc_profile)s
@@ -212,7 +212,7 @@
         if not profile:
             error (_('Trying to connect a non-exsitant profile'))
             raise ProfileUnknownError(profile_key)
-        
+
         if (self.isConnected(profile)):
             info(_("already connected !"))
             return defer.succeed("None")
@@ -227,12 +227,12 @@
             current = self.profiles[profile] = xmpp.SatXMPPClient(self, profile,
                 jid.JID(self.memory.getParamA("JabberID", "Connection", profile_key = profile), profile),
                 self.memory.getParamA("Password", "Connection", profile_key = profile),
-                self.memory.getParamA("Server", "Connection", profile_key = profile), 
+                self.memory.getParamA("Server", "Connection", profile_key = profile),
                 port)
 
             current.messageProt = xmpp.SatMessageProtocol(self)
             current.messageProt.setHandlerParent(current)
-            
+
             current.roster = xmpp.SatRosterProtocol(self)
             current.roster.setHandlerParent(current)
 
@@ -247,7 +247,7 @@
             current.versionHandler.setHandlerParent(current)
 
             debug (_("setting plugins parents"))
-            
+
             for plugin in self.plugins.iteritems():
                 if plugin[1].is_handler:
                     plugin[1].getHandler(profile).setHandlerParent(current)
@@ -307,7 +307,7 @@
         info("Salut à toi ô mon frère !")
         #TODO: manage autoconnect
         #self.connect()
-    
+
     def stopService(self):
         self.memory.save()
         info("Salut aussi à Rantanplan")
@@ -315,13 +315,13 @@
     def run(self):
         debug(_("running app"))
         reactor.run()
-    
+
     def stop(self):
         debug(_("stopping app"))
         reactor.stop()
-        
+
     ## Misc methods ##
-   
+
     def getJidNStream(self, profile_key):
         """Convenient method to get jid and stream from profile key
         @return: tuple (jid, xmlstream) from profile, can be None"""
@@ -347,8 +347,8 @@
         serverRegistrer = xmlstream.XmlStreamFactory(xmpp.RegisteringAuthenticator(self, server, login, password, email, next_id, profile))
         connector = reactor.connectTCP(server, port, serverRegistrer)
         serverRegistrer.clientConnectionLost = lambda conn, reason: connector.disconnect()
-        
-        return next_id 
+
+        return next_id
 
     def registerNewAccountCB(self, id, data, profile):
         user = jid.parse(self.memory.getParamA("JabberID", "Connection", profile_key=profile))[0]
@@ -363,7 +363,7 @@
 
         confirm_id = sat_next_id()
         self.__private_data[confirm_id]=(id,profile)
-    
+
         self.askConfirmation(confirm_id, "YES/NO",
             {"message":_("Are you sure to register new account [%(user)s] to server %(server)s ?") % {'user':user, 'server':server, 'profile':profile}},
             self.regisConfirmCB, profile)
@@ -393,7 +393,7 @@
         profile = self.memory.getProfileName(profile_key)
         assert(profile)
         to_jid = jid.JID(target)
-        
+
         iq = compat.IQ(self.profiles[profile].xmlstream, 'set')
         iq["to"] = target
         iq["from"] = self.profiles[profile].jid.full()
@@ -456,7 +456,7 @@
 
 
     ## jabber methods ##
-   
+
     def getWaitingConf(self, profile_key=None):
         assert(profile_key)
         client = self.getClient(profile_key)
@@ -467,22 +467,22 @@
             conf_type, data = client._waiting_conf[conf_id][:2]
             ret.append((conf_id, conf_type, data))
         return ret
-    
+
     def sendMessage(self, to, msg, subject=None, mess_type='auto', profile_key='@DEFAULT@'):
         #FIXME: check validity of recipient
         profile = self.memory.getProfileName(profile_key)
         assert(profile)
         client = self.profiles[profile]
         current_jid = client.jid
-        mess_data = { #we put data in a dict, so trigger methods can change them 
+        mess_data = { #we put data in a dict, so trigger methods can change them
                       "to": jid.JID(to),
                       "message": msg,
                       "subject": subject,
                       "type": mess_type
                     }
-        
+
         if mess_data["type"] == "auto":
-            # we try to guess the type 
+            # we try to guess the type
             if mess_data["subject"]:
                 mess_data["type"] = 'normal'
             elif not mess_data["to"].resource: #if to JID has a resource, the type is not 'groupchat'
@@ -492,7 +492,7 @@
                     #FIXME: should entity_type manage ressources ?
                 except (UnknownEntityError, KeyError):
                     entity_type = "contact"
-                
+
                 if entity_type == "chatroom":
                     mess_data["type"] = 'groupchat'
                 else:
@@ -500,10 +500,10 @@
             else:
                 mess_data["type"] == 'chat'
             mess_data["type"] == "chat" if mess_data["subject"] else "normal"
-        
+
         if not self.trigger.point("sendMessage", mess_data, profile):
             return
-        
+
         debug(_("Sending jabber message of type [%(type)s] to %(to)s...") % {"type": mess_data["type"], "to": to})
         message = domish.Element((None,'message'))
         message["to"] = mess_data["to"].full()
@@ -531,8 +531,8 @@
             del statuses['']
         self.bridge.presenceUpdate(self.profiles[profile].jid.full(),  show,
                 int(priority), statuses, profile)
-        
-    
+
+
     def subscription(self, subs_type, raw_jid, profile_key):
         """Called to manage subscription
         @param subs_type: subsciption type (cf RFC 3921)
@@ -592,31 +592,31 @@
     def serverDiscoItems(self, disco_result, disco_client, profile, initialized):
         """xep-0030 Discovery Protocol.
         @param disco_result: result of the disco item querry
-        @param disco_client: SatDiscoProtocol instance 
-        @param profile: profile of the user 
+        @param disco_client: SatDiscoProtocol instance
+        @param profile: profile of the user
         @param initialized: deferred which must be chained when everything is done"""
-        
+
         def _check_entity_cb(result, entity, profile):
             for category, type in result.identities:
                 debug (_('Identity added: (%(category)s,%(type)s) ==> %(entity)s [%(profile)s]') % {
                          'category':category, 'type':type, 'entity':entity, 'profile':profile})
-                self.memory.addServerIdentity(category, type, entity, profile) 
+                self.memory.addServerIdentity(category, type, entity, profile)
 
         def _errback(result, entity, profile):
             warning(_("Can't get information on identity [%(entity)s] for profile [%(profile)s]") % {'entity':entity, 'profile': profile})
-       
+
         defer_list = []
         for item in disco_result._items:
             if item.entity.full().count('.') == 1: #XXX: workaround for a bug on jabberfr, tmp
                 warning(_('Using jabberfr workaround, be sure your domain has at least two levels (e.g. "example.tld", not "example" alone)'))
                 continue
-            args = [item.entity, profile] 
+            args = [item.entity, profile]
             defer_list.append(disco_client.requestInfo(item.entity).addCallbacks(_check_entity_cb, _errback, args, None, args))
         defer.DeferredList(defer_list).chainDeferred(initialized)
 
-    
-    ## Generic HMI ## 
-    
+
+    ## Generic HMI ##
+
     def actionResult(self, action_id, action_type, data, profile):
         """Send the result of an action
         @param action_id: same action_id used with action