# HG changeset patch
# User Goffi <goffi@goffi.org>
# Date 1362945329 -3600
# Node ID d722778b152c6f465ed920a54e7b6f4df5fd67a1
# Parent  c8c07c920e30d1a04712df5e7009a84be384ce4c
core: added Priority management

diff -r c8c07c920e30 -r d722778b152c src/core/xmpp.py
--- a/src/core/xmpp.py	Sun Mar 10 20:54:45 2013 +0100
+++ b/src/core/xmpp.py	Sun Mar 10 20:55:29 2013 +0100
@@ -295,7 +295,13 @@
         # now it's time to notify frontends
         self.host.bridge.presenceUpdate(entity.full(), "unavailable", 0, statuses, self.parent.profile)
 
-    def available(self, entity=None, show=None, statuses=None, priority=0):
+    def available(self, entity=None, show=None, statuses=None, priority=None):
+        if priority is None:
+            try:
+                priority = int(self.host.memory.getParamA("Priority", "Connection", profile_key=self.parent.profile))
+            except ValueError:
+                priority = 0
+
         if not statuses:
             statuses = {}
             # default for us is None for wokkel
diff -r c8c07c920e30 -r d722778b152c src/memory/memory.py
--- a/src/memory/memory.py	Sun Mar 10 20:54:45 2013 +0100
+++ b/src/memory/memory.py	Sun Mar 10 20:55:29 2013 +0100
@@ -40,6 +40,8 @@
     ### TODO: add desciption in params
 
     #TODO: move Watched in a plugin
+    #TODO: when priority is changed, a new presence stanza must be emitted
+    #TODO: int type (Priority should be int instead of string)
     default_xml = u"""
     <params>
     <general>
@@ -48,6 +50,7 @@
         <category name="Connection" label="%(category_connection)s">
             <param name="JabberID" value="name@example.org/SàT" type="string" />
             <param name="Password" value="" type="password" />
+            <param name="Priority" value="50" type="string" />
             <param name="Server" value="example.org" type="string" />
             <param name="Port" value="5222" type="string" />
             <param name="NewAccount" value="%(label_NewAccount)s" type="button" callback_id="registerNewAccount"/>