Updated nullclient.py
[python-purple] / plugin.pyx
index f9b05d6..c5b5f93 100644 (file)
@@ -24,9 +24,14 @@ cdef class Plugin:
     cdef prpl.PurplePluginProtocolInfo *c_prpl_info
     cdef plugin.PurplePluginInfo *c_plugin_info
 
     cdef prpl.PurplePluginProtocolInfo *c_prpl_info
     cdef plugin.PurplePluginInfo *c_plugin_info
 
+    def __init__(self):
+        pass
+
+    '''
     def __init__(self, id):
     def __init__(self, id):
-        self.c_plugin = plugin.c_purple_plugins_find_with_id(id)
+        self.c_plugin = plugin.purple_plugins_find_with_id(id)
         self.c_prpl_info = plugin.c_PURPLE_PLUGIN_PROTOCOL_INFO(self.c_plugin)
         self.c_prpl_info = plugin.c_PURPLE_PLUGIN_PROTOCOL_INFO(self.c_plugin)
+    '''
 
     def get_name(self):
         return self.c_plugin.info.name
 
     def get_name(self):
         return self.c_plugin.info.name
@@ -42,7 +47,7 @@ cdef class Plugin:
 
         protocols = []
 
 
         protocols = []
 
-        iter = plugin.c_purple_plugins_get_protocols()
+        iter = plugin.purple_plugins_get_protocols()
         while iter:
             pp = <plugin.PurplePlugin*> iter.data
             if pp.info and pp.info.name:
         while iter:
             pp = <plugin.PurplePlugin*> iter.data
             if pp.info and pp.info.name:
@@ -71,12 +76,9 @@ cdef class Plugin:
         c_account = NULL
 
         if username:
         c_account = NULL
 
         if username:
-            c_account = account.c_purple_accounts_find(username, id)
-            if c_account == NULL:
-                # FIXME: Message error or call a error handler
-                return None
+            c_account = account.purple_accounts_find(username, id)
 
 
-        c_plugin = plugin.c_purple_plugins_find_with_id(id)
+        c_plugin = plugin.purple_plugins_find_with_id(id)
         c_prpl_info = plugin.c_PURPLE_PLUGIN_PROTOCOL_INFO(c_plugin)
 
         po = {}
         c_prpl_info = plugin.c_PURPLE_PLUGIN_PROTOCOL_INFO(c_plugin)
 
         po = {}
@@ -86,43 +88,38 @@ cdef class Plugin:
         while iter:
 
             option = <accountopt.PurpleAccountOption *> iter.data
         while iter:
 
             option = <accountopt.PurpleAccountOption *> iter.data
-            type = accountopt.c_purple_account_option_get_type(option)
-            label_name = accountopt.c_purple_account_option_get_text(option)
-            setting = accountopt.c_purple_account_option_get_setting(option)
+            type = accountopt.purple_account_option_get_type(option)
+            label_name = accountopt.purple_account_option_get_text(option)
+            setting = accountopt.purple_account_option_get_setting(option)
 
             sett = str(<char *> setting)
 
             sett = str(<char *> setting)
-            label = str(<char *> lanel_name)
+            label = str(<char *> label_name)
 
             if type == prefs.PURPLE_PREF_STRING:
 
             if type == prefs.PURPLE_PREF_STRING:
-                str_value = accountopt.c_purple_account_option_get_default_string(option)
-                # Google Talk default domain hackery!
-                if str_value == NULL and label == "Connect server":
-                    str_value = "talk.google.com"
+                str_value = accountopt.purple_account_option_get_default_string(option)
                 if c_account != NULL:
                 if c_account != NULL:
-                    str_value = account.c_purple_account_get_string(c_account, setting, str_value)
+                    str_value = account.purple_account_get_string(c_account, setting, str_value)
 
                 val = str(<char *> str_value)
 
             elif type == prefs.PURPLE_PREF_INT:
 
                 val = str(<char *> str_value)
 
             elif type == prefs.PURPLE_PREF_INT:
-                int_value = accountopt.c_purple_account_option_get_default_int(option)
-                if sett == "port":
-                        int_value = int(443)
+                int_value = accountopt.purple_account_option_get_default_int(option)
                 if c_account != NULL:
                 if c_account != NULL:
-                    int_value = account.c_purple_account_get_int(c_account, setting, int_value)
+                    int_value = account.purple_account_get_int(c_account, setting, int_value)
 
                 val = int(int_value)
 
             elif type == prefs.PURPLE_PREF_BOOLEAN:
 
                 val = int(int_value)
 
             elif type == prefs.PURPLE_PREF_BOOLEAN:
-                bool_value = accountopt.c_purple_account_option_get_default_bool(option)
+                bool_value = accountopt.purple_account_option_get_default_bool(option)
                 if c_account != NULL:
                 if c_account != NULL:
-                    bool_value = account.c_purple_account_get_bool(c_account, setting, bool_value)
+                    bool_value = account.purple_account_get_bool(c_account, setting, bool_value)
 
                 val = bool(bool_value)
 
             elif type == prefs.PURPLE_PREF_STRING_LIST:
 
                 val = bool(bool_value)
 
             elif type == prefs.PURPLE_PREF_STRING_LIST:
-                str_value = accountopt.c_purple_account_option_get_default_list_value(option)
+                str_value = accountopt.purple_account_option_get_default_list_value(option)
                 if c_account != NULL:
                 if c_account != NULL:
-                    str_value = account.c_purple_account_get_string(c_account, setting, str_value)
+                    str_value = account.purple_account_get_string(c_account, setting, str_value)
 
                 val = str(<char *> str_value)
 
 
                 val = str(<char *> str_value)
 
@@ -132,7 +129,8 @@ cdef class Plugin:
 
         return po
 
 
         return po
 
-    def set_options(self, id, username, po):
+    def set_options(self, acc, po):
+        #FIXME: account
         ''' @param id The protocol's id '''
         ''' @param username The account's username '''
         ''' @param po Dictionary {'setting type': str|int|bool value, ...} '''
         ''' @param id The protocol's id '''
         ''' @param username The account's username '''
         ''' @param po Dictionary {'setting type': str|int|bool value, ...} '''
@@ -151,12 +149,12 @@ cdef class Plugin:
 
         c_account = NULL
 
 
         c_account = NULL
 
-        c_account = account.c_purple_accounts_find(username, id)
+        c_account = account.purple_accounts_find(acc[0], acc[1])
         if c_account == NULL:
             # FIXME: Message error or call a error handler
             return False
 
         if c_account == NULL:
             # FIXME: Message error or call a error handler
             return False
 
-        c_plugin = plugin.c_purple_plugins_find_with_id(id)
+        c_plugin = plugin.purple_plugins_find_with_id(acc[1])
         c_prpl_info = plugin.c_PURPLE_PLUGIN_PROTOCOL_INFO(c_plugin)
 
         iter = c_prpl_info.protocol_options
         c_prpl_info = plugin.c_PURPLE_PLUGIN_PROTOCOL_INFO(c_plugin)
 
         iter = c_prpl_info.protocol_options
@@ -164,35 +162,35 @@ cdef class Plugin:
         while iter:
 
             option = <accountopt.PurpleAccountOption *> iter.data
         while iter:
 
             option = <accountopt.PurpleAccountOption *> iter.data
-            type = accountopt.c_purple_account_option_get_type(option)
-            setting = accountopt.c_purple_account_option_get_setting(option)
+            type = accountopt.purple_account_option_get_type(option)
+            setting = accountopt.purple_account_option_get_setting(option)
 
             sett = str(<char *> setting)
 
             iter = iter.next
 
 
             sett = str(<char *> setting)
 
             iter = iter.next
 
-            if not po.has_key(sett):
+            if not po.has_key(sett) or not po[sett]:
                 continue
 
             if type == prefs.PURPLE_PREF_STRING:
 
                 str_value = <char *> po[sett]
                 continue
 
             if type == prefs.PURPLE_PREF_STRING:
 
                 str_value = <char *> po[sett]
-                account.c_purple_account_set_string(c_account, setting, str_value)
+                account.purple_account_set_string(c_account, setting, str_value)
 
             elif type == prefs.PURPLE_PREF_INT:
 
                 int_value = int(po[sett])
 
             elif type == prefs.PURPLE_PREF_INT:
 
                 int_value = int(po[sett])
-                account.c_purple_account_set_int(c_account, setting, int_value)
+                account.purple_account_set_int(c_account, setting, int_value)
 
             elif type == prefs.PURPLE_PREF_BOOLEAN:
 
                 bool_value = bool(po[sett])
 
             elif type == prefs.PURPLE_PREF_BOOLEAN:
 
                 bool_value = bool(po[sett])
-                account.c_purple_account_set_bool(c_account, setting, bool_value)
+                account.purple_account_set_bool(c_account, setting, bool_value)
 
             elif type == prefs.PURPLE_PREF_STRING_LIST:
 
                 str_value = <char *> po[sett]
 
             elif type == prefs.PURPLE_PREF_STRING_LIST:
 
                 str_value = <char *> po[sett]
-                account.c_purple_account_set_string(c_account, setting, str_value)
+                account.purple_account_set_string(c_account, setting, str_value)
 
         return True
 
 
         return True
 
@@ -210,7 +208,7 @@ cdef class Plugins:
         cdef glib.GList *iter
         cdef plugin.PurplePlugin *pp
         protocols = []
         cdef glib.GList *iter
         cdef plugin.PurplePlugin *pp
         protocols = []
-        iter = plugin.c_purple_plugins_get_protocols()
+        iter = plugin.purple_plugins_get_protocols()
         while iter:
             pp = <plugin.PurplePlugin*> iter.data
             if pp.info and pp.info.name:
         while iter:
             pp = <plugin.PurplePlugin*> iter.data
             if pp.info and pp.info.name: