Skip to content
Browse files

Exampre 41: A rather complicated piece of code for converting jabber …

…ids into buddy list item roster information.

It's rather ugly but it returns a simple dictionary. You might want to print said dictionary if you don't believe me.
  • Loading branch information...
1 parent 542977c commit b7f0400253f511af562f301e45022769480e3bb2 @buchuki committed Jul 9, 2013
Showing with 19 additions and 0 deletions.
  1. +19 −0 orkiv/__main__.py
View
19 orkiv/__main__.py
@@ -77,6 +77,25 @@ def __init__(self):
self.app = Orkiv.get_running_app()
self.list_view.adapter.data = sorted(self.app.xmpp.client_roster.keys())
+ def roster_converter(self, index, jabberid):
+ result = {
+ "jabberid": jabberid,
+ "full_name": self.app.xmpp.client_roster[jabberid]['name']
+ }
+
+ presence = sorted(
+ self.app.xmpp.client_roster.presence(jabberid).values(),
+ key=lambda p: p.get("priority", 100), reverse=True)
+ if presence:
+ result['status_message'] = presence[0].get('status', '')
+ show = presence[0].get('show')
+ result['online_status'] = show if show else "available"
+ else:
+ result['status_message'] = ""
+ result['online_status'] = "offline"
+
+ return result
+
class OrkivRoot(BoxLayout):
def show_buddy_list(self):

0 comments on commit b7f0400

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