Adding function __get_protocol_labels
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:52:57 +0000 (20:52 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:14 +0000 (17:11 -0400)
Adding function __get_protocol_labels to return the config's labels to account's protocol

Signed-off-by: Ragner Magalhaes <ragner.magalhaes@indt.org.br>

git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1365 596f6dd7-e928-0410-a184-9e12fd12cf7e

account.pyx

index b81947a..97374ea 100644 (file)
@@ -179,6 +179,33 @@ cdef class Account:
 
     protocol_options = property(_get_protocol_options)
 
 
     protocol_options = property(_get_protocol_options)
 
+    def _get_protocol_labels(self):
+        cdef glib.GList *iter
+        cdef accountopt.PurpleAccountOption *option
+        cdef const_char *label_name
+        cdef const_char *setting
+
+        if self.c_account == NULL:
+            return None
+
+        po = {}
+
+        iter = self.c_prpl_info.protocol_options
+
+        while iter:
+
+            option = <accountopt.PurpleAccountOption *> iter.data
+            label_name = accountopt.c_purple_account_option_get_text(option)
+            setting = accountopt.c_purple_account_option_get_setting(option)
+
+            sett = str(<char *> setting)
+            label = str(<char *> label_name)
+
+            po[sett] = label
+
+        return po
+
+    protocol_labels = property(_get_protocol_labels)
 
     def get_protocol_name(self):
         if self.c_account:
 
     def get_protocol_name(self):
         if self.c_account: