summaryrefslogtreecommitdiff
path: root/src/contact.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/contact.py')
-rw-r--r--src/contact.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/contact.py b/src/contact.py
index 1eb41f72..8341d4b8 100644
--- a/src/contact.py
+++ b/src/contact.py
@@ -15,12 +15,15 @@
# along with Poezio. If not, see <http://www.gnu.org/licenses/>.
"""
-Defines the Resource and Contact classes
+Defines the Resource and Contact classes, which are used in
+the roster
"""
-from sleekxmpp.xmlstream.stanzabase import JID
+
import logging
log = logging.getLogger(__name__)
+from sleekxmpp.xmlstream.stanzabase import JID
+
class Resource(object):
"""
Defines a roster item.
@@ -80,8 +83,7 @@ class Contact(object):
def get_highest_priority_resource(self):
"""
- There must be, at any time, at least ONE resource.
- And they always should be ordered by priority.
+ Return the resource with the highest priority
"""
ret = None
for resource in self._resources:
@@ -94,8 +96,10 @@ class Contact(object):
Called, for example, when a new resource get offline
(the first, or any subsequent one)
"""
- # TODO sort by priority
+ def f(o):
+ return o.get_priority()
self._resources.append(resource)
+ self._resources = sorted(self._resources, key=f, reverse=True)
def remove_resource(self, resource):
"""