Fix for accountopt, cosmetics and fix for union definition.
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:38:14 +0000 (20:38 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:12 +0000 (17:11 -0400)
FIXES:
 - account.pxd should not link to any other .pxd that belongs to libpurple, since it can cause redundancy problems to cython.
 - Moved all accountopt code to accountopt.pxd.
 - Fixed union definition in PurpleAccountOption.
 - Small cosmetics at end of some code lines.

Signed-off-by: Bruno Abinader <bruno.abinader@indt.org.br>

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

account.pyx
libpurple/account.pxd
libpurple/accountopt.pxd [new file with mode: 0644]
libpurple/plugin.pxd
libpurple/purple.pxd

index 80b0b0e..1ae9d40 100644 (file)
@@ -86,7 +86,7 @@ cdef class Account:
     def get_protocol_options(self):
         ''' FIXME: It is just a hack, to set the XMPP's options. '''
         cdef glib.GList *iter
     def get_protocol_options(self):
         ''' FIXME: It is just a hack, to set the XMPP's options. '''
         cdef glib.GList *iter
-        cdef account.PurpleAccountOption *option
+        cdef accountopt.PurpleAccountOption *option
         cdef prefs.PurplePrefType type
         cdef const_char *label_name
         cdef const_char *str_value
         cdef prefs.PurplePrefType type
         cdef const_char *label_name
         cdef const_char *str_value
@@ -95,12 +95,12 @@ cdef class Account:
         cdef glib.gboolean bool_value
         iter = self.c_prpl_info.protocol_options
         while iter:
         cdef glib.gboolean bool_value
         iter = self.c_prpl_info.protocol_options
         while iter:
-            option = <account.PurpleAccountOption *> iter.data
-            type = account.c_purple_account_option_get_type(option)
-            label_name = account.c_purple_account_option_get_text(option)
-            setting = account.c_purple_account_option_get_setting(option)
+            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)
             if type == prefs.PURPLE_PREF_STRING:
             if type == prefs.PURPLE_PREF_STRING:
-                str_value = account.c_purple_account_option_get_default_string(option)
+                str_value = accountopt.c_purple_account_option_get_default_string(option)
 
                 # Google Talk default domain hackery!
                 if str_value == NULL and str(<char *> label_name) == "Connect server":
 
                 # Google Talk default domain hackery!
                 if str_value == NULL and str(<char *> label_name) == "Connect server":
@@ -111,21 +111,21 @@ cdef class Account:
                     account.c_purple_account_set_string(self.__account, setting, str_value );
 
             elif type == prefs.PURPLE_PREF_INT:
                     account.c_purple_account_set_string(self.__account, setting, str_value );
 
             elif type == prefs.PURPLE_PREF_INT:
-                int_value = account.c_purple_account_option_get_default_int(option)
+                int_value = accountopt.c_purple_account_option_get_default_int(option)
                 if self.__account != NULL:
                    int_value = account.c_purple_account_get_int(self.__account, setting, int_value)
                    if str(<char *> setting) == "port":
                         account.c_purple_account_set_int(self.__account, setting, 443);
 
             elif type == prefs.PURPLE_PREF_BOOLEAN:
                 if self.__account != NULL:
                    int_value = account.c_purple_account_get_int(self.__account, setting, int_value)
                    if str(<char *> setting) == "port":
                         account.c_purple_account_set_int(self.__account, setting, 443);
 
             elif type == prefs.PURPLE_PREF_BOOLEAN:
-                bool_value = account.c_purple_account_option_get_default_bool(option)
+                bool_value = accountopt.c_purple_account_option_get_default_bool(option)
                 if self.__account != NULL:
                     bool_value = account.c_purple_account_get_bool(self.__account, setting, bool_value)
                     if str(<char *> setting) == "old_ssl":
                         account.c_purple_account_set_bool(self.__account, setting, True);
 
             elif type == prefs.PURPLE_PREF_STRING_LIST:
                 if self.__account != NULL:
                     bool_value = account.c_purple_account_get_bool(self.__account, setting, bool_value)
                     if str(<char *> setting) == "old_ssl":
                         account.c_purple_account_set_bool(self.__account, setting, True);
 
             elif type == prefs.PURPLE_PREF_STRING_LIST:
-                str_value = account.c_purple_account_option_get_default_list_value(option)
+                str_value = accountopt.c_purple_account_option_get_default_list_value(option)
                 if self.__account != NULL:
                     str_value = account.c_purple_account_get_string(self.__account, setting, str_value)
 
                 if self.__account != NULL:
                     str_value = account.c_purple_account_get_string(self.__account, setting, str_value)
 
index d656b2e..20b8440 100644 (file)
@@ -18,7 +18,6 @@
 #
 
 cimport glib
 #
 
 cimport glib
-cimport prefs
 
 cdef extern from *:
     ctypedef char const_char "const char"
 
 cdef extern from *:
     ctypedef char const_char "const char"
@@ -43,52 +42,30 @@ cdef extern from "libpurple/status.h":
     ctypedef struct PurplePresence:
         pass
 
     ctypedef struct PurplePresence:
         pass
 
-cdef extern from "libpurple/accountopt.h":
-    ctypedef struct PurpleAccountOption:
-        prefs.PurplePrefType type
-        char *text
-        char *pref_name
-        #union
-        #{
-        #    gboolean boolean
-        #    int integer
-        #    char *string
-        #    GList *list
-        #} default_value;
-        glib.gboolean masked
-
-    prefs.PurplePrefType c_purple_account_option_get_type "purple_account_option_get_type" (PurpleAccountOption *option)
-    char *c_purple_account_option_get_setting "purple_account_option_get_setting" (PurpleAccountOption *option)
-    char *c_purple_account_option_get_default_string "purple_account_option_get_default_string" (PurpleAccountOption *option)
-    int c_purple_account_option_get_default_int "purple_account_option_get_default_int" (PurpleAccountOption *option)
-    glib.gboolean c_purple_account_option_get_default_bool "purple_account_option_get_default_bool" (PurpleAccountOption *option)
-    const_char *c_purple_account_option_get_default_list_value "purple_account_option_get_default_list_value" (PurpleAccountOption *option)
-    const_char *c_purple_account_option_get_text "purple_account_option_get_text" (PurpleAccountOption *option)
-
 cdef extern from "libpurple/account.h":
     ctypedef struct PurpleAccountUiOps
     ctypedef struct PurpleAccount
 
     ctypedef glib.gboolean (*PurpleFilterAccountFunc) (PurpleAccount *account)
     ctypedef void (*PurpleAccountRequestAuthorizationCb) (void *)
 cdef extern from "libpurple/account.h":
     ctypedef struct PurpleAccountUiOps
     ctypedef struct PurpleAccount
 
     ctypedef glib.gboolean (*PurpleFilterAccountFunc) (PurpleAccount *account)
     ctypedef void (*PurpleAccountRequestAuthorizationCb) (void *)
-    ctypedef void (*PurpleAccountRegistrationCb) (PurpleAccount *account,\
+    ctypedef void (*PurpleAccountRegistrationCb) (PurpleAccount *account, \
             glib.gboolean succeeded, void *user_data)
             glib.gboolean succeeded, void *user_data)
-    ctypedef void (*PurpleAccountUnregistrationCb) (PurpleAccount *account,\
+    ctypedef void (*PurpleAccountUnregistrationCb) (PurpleAccount *account, \
             glib.gboolean succeeded, void *user_data)
 
     ctypedef enum PurpleAccountRequestType:
         PURPLE_ACCOUNT_REQUEST_AUTHORIZATION = 0
 
     ctypedef struct PurpleAccountUiOps:
             glib.gboolean succeeded, void *user_data)
 
     ctypedef enum PurpleAccountRequestType:
         PURPLE_ACCOUNT_REQUEST_AUTHORIZATION = 0
 
     ctypedef struct PurpleAccountUiOps:
-        void (*notify_added) (PurpleAccount *account, const_char *remote_user,\
+        void (*notify_added) (PurpleAccount *account, const_char *remote_user, \
                 const_char *id, const_char *alias, const_char *message)
         void (*status_changed) (PurpleAccount *account, PurpleStatus *status)
                 const_char *id, const_char *alias, const_char *message)
         void (*status_changed) (PurpleAccount *account, PurpleStatus *status)
-        void (*request_add) (PurpleAccount *account, const_char *remote_user,\
+        void (*request_add) (PurpleAccount *account, const_char *remote_user, \
                 const_char *id, const_char *alias, const_char *message)
                 const_char *id, const_char *alias, const_char *message)
-        void *(*request_authorize) (PurpleAccount *account,\
-                const_char *remote_user, const_char *id, const_char *alias,\
-                const_char *message, glib.gboolean on_list,\
-                PurpleAccountRequestAuthorizationCb authorize_cb,\
+        void *(*request_authorize) (PurpleAccount *account, \
+                const_char *remote_user, const_char *id, const_char *alias, \
+                const_char *message, glib.gboolean on_list, \
+                PurpleAccountRequestAuthorizationCb authorize_cb, \
                 PurpleAccountRequestAuthorizationCb deny_cb, void *user_data)
         void (*close_account_request) (void *ui_handle)
 
                 PurpleAccountRequestAuthorizationCb deny_cb, void *user_data)
         void (*close_account_request) (void *ui_handle)
 
@@ -115,38 +92,38 @@ cdef extern from "libpurple/account.h":
         void *registration_cb_user_data
         glib.gpointer priv
 
         void *registration_cb_user_data
         glib.gpointer priv
 
-    PurpleAccount *c_purple_account_new "purple_account_new"\
+    PurpleAccount *c_purple_account_new "purple_account_new" \
             (char *username, char *protocol_id)
             (char *username, char *protocol_id)
-    void c_purple_account_set_password "purple_account_set_password"\
+    void c_purple_account_set_password "purple_account_set_password" \
             (PurpleAccount *account, char *password)
             (PurpleAccount *account, char *password)
-    char *c_purple_account_get_password "purple_account_get_password"\
+    char *c_purple_account_get_password "purple_account_get_password" \
             (PurpleAccount *account)
             (PurpleAccount *account)
-    void c_purple_account_set_enabled "purple_account_set_enabled"\
+    void c_purple_account_set_enabled "purple_account_set_enabled" \
             (PurpleAccount *account, char *ui, glib.gboolean value)
             (PurpleAccount *account, char *ui, glib.gboolean value)
-    char *c_purple_account_get_username "purple_account_get_username"\
+    char *c_purple_account_get_username "purple_account_get_username" \
             (PurpleAccount *account)
             (PurpleAccount *account)
-    glib.GList *c_purple_accounts_get_all_active\
+    glib.GList *c_purple_accounts_get_all_active \
             "purple_accounts_get_all_active" ()
             "purple_accounts_get_all_active" ()
-    void c_purple_accounts_set_ui_ops "purple_accounts_set_ui_ops"\
+    void c_purple_accounts_set_ui_ops "purple_accounts_set_ui_ops" \
             (PurpleAccountUiOps *ops)
             (PurpleAccountUiOps *ops)
-    glib.gboolean c_purple_account_is_connected "purple_account_is_connected"\
+    glib.gboolean c_purple_account_is_connected "purple_account_is_connected" \
             (PurpleAccount *account)
             (PurpleAccount *account)
-    PurpleProxyInfo *c_purple_account_get_proxy_info\
+    PurpleProxyInfo *c_purple_account_get_proxy_info \
             "purple_account_get_proxy_info" (PurpleAccount *account)
             "purple_account_get_proxy_info" (PurpleAccount *account)
-    void c_purple_account_set_proxy_info "purple_account_set_proxy_info"\
+    void c_purple_account_set_proxy_info "purple_account_set_proxy_info" \
             (PurpleAccount *account, PurpleProxyInfo *info)
             (PurpleAccount *account, PurpleProxyInfo *info)
-    char *c_purple_account_get_string "purple_account_get_string"\
+    char *c_purple_account_get_string "purple_account_get_string" \
             (PurpleAccount *account, char *name, char *default_value)
             (PurpleAccount *account, char *name, char *default_value)
-    int c_purple_account_get_int "purple_account_get_int"\
+    int c_purple_account_get_int "purple_account_get_int" \
             (PurpleAccount *account, char *name, int default_value)
             (PurpleAccount *account, char *name, int default_value)
-    glib.gboolean c_purple_account_get_bool "purple_account_get_bool"\
+    glib.gboolean c_purple_account_get_bool "purple_account_get_bool" \
             (PurpleAccount *account, char *name, glib.gboolean default_value)
             (PurpleAccount *account, char *name, glib.gboolean default_value)
-    void c_purple_account_clear_settings "purple_account_clear_settings"\
+    void c_purple_account_clear_settings "purple_account_clear_settings" \
             (PurpleAccount *account)
             (PurpleAccount *account)
-    void c_purple_account_set_int "purple_account_set_int"\
+    void c_purple_account_set_int "purple_account_set_int" \
             (PurpleAccount *account, char *name, int value)
             (PurpleAccount *account, char *name, int value)
-    void c_purple_account_set_string "purple_account_set_string"\
+    void c_purple_account_set_string "purple_account_set_string" \
             (PurpleAccount *account, char *name, char *value)
             (PurpleAccount *account, char *name, char *value)
-    void c_purple_account_set_bool "purple_account_set_bool"\
+    void c_purple_account_set_bool "purple_account_set_bool" \
             (PurpleAccount *account, char *name, glib.gboolean value)
 
             (PurpleAccount *account, char *name, glib.gboolean value)
 
diff --git a/libpurple/accountopt.pxd b/libpurple/accountopt.pxd
new file mode 100644 (file)
index 0000000..1de76fc
--- /dev/null
@@ -0,0 +1,48 @@
+#
+#  Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia
+#
+#  This file is part of python-purple.
+#
+#  python-purple is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  python-purple is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+cimport glib
+
+cimport prefs
+
+cdef extern from *:
+    ctypedef char const_char "const char"
+
+cdef extern from "libpurple/accountopt.h":
+
+    ctypedef struct UnionType:
+        glib.gboolean boolean
+        int integer
+        char *string
+        glib.GList *list
+
+    ctypedef struct PurpleAccountOption:
+        prefs.PurplePrefType type
+        char *text
+        char *pref_name
+        UnionType default_value
+        glib.gboolean masked
+
+    prefs.PurplePrefType c_purple_account_option_get_type "purple_account_option_get_type" (PurpleAccountOption *option)
+    char *c_purple_account_option_get_setting "purple_account_option_get_setting" (PurpleAccountOption *option)
+    char *c_purple_account_option_get_default_string "purple_account_option_get_default_string" (PurpleAccountOption *option)
+    int c_purple_account_option_get_default_int "purple_account_option_get_default_int" (PurpleAccountOption *option)
+    glib.gboolean c_purple_account_option_get_default_bool "purple_account_option_get_default_bool" (PurpleAccountOption *option)
+    const_char *c_purple_account_option_get_default_list_value "purple_account_option_get_default_list_value" (PurpleAccountOption *option)
+    const_char *c_purple_account_option_get_text "purple_account_option_get_text" (PurpleAccountOption *option)
index ef6f81c..101fe26 100644 (file)
@@ -18,6 +18,7 @@
 #
 
 cimport glib
 #
 
 cimport glib
+
 cimport prpl
 
 cdef extern from "libpurple/plugin.h":
 cimport prpl
 
 cdef extern from "libpurple/plugin.h":
@@ -37,15 +38,14 @@ cdef extern from "libpurple/plugin.h":
         glib.gboolean unloadable
         glib.GList *dependent_plugins
 
         glib.gboolean unloadable
         glib.GList *dependent_plugins
 
-    prpl.PurplePluginProtocolInfo *c_PURPLE_PLUGIN_PROTOCOL_INFO     \
+    prpl.PurplePluginProtocolInfo *c_PURPLE_PLUGIN_PROTOCOL_INFO \
                 "PURPLE_PLUGIN_PROTOCOL_INFO" (PurplePlugin *plugin)
                 "PURPLE_PLUGIN_PROTOCOL_INFO" (PurplePlugin *plugin)
-    PurplePlugin *c_purple_plugin_new  "purple_plugin_new"      \
+    PurplePlugin *c_purple_plugin_new  "purple_plugin_new" \
             (glib.gboolean native, char* path)
 
     void c_purple_plugins_add_search_path "purple_plugins_add_search_path" \
             (char *path)
     glib.GList *c_purple_plugins_get_protocols "purple_plugins_get_protocols" ()
             (glib.gboolean native, char* path)
 
     void c_purple_plugins_add_search_path "purple_plugins_add_search_path" \
             (char *path)
     glib.GList *c_purple_plugins_get_protocols "purple_plugins_get_protocols" ()
-
     PurplePlugin *c_purple_plugins_find_with_name "purple_plugins_find_with_name" \
             (char *name)
     PurplePlugin *c_purple_plugins_find_with_id "purple_plugins_find_with_id" \
     PurplePlugin *c_purple_plugins_find_with_name "purple_plugins_find_with_name" \
             (char *name)
     PurplePlugin *c_purple_plugins_find_with_id "purple_plugins_find_with_id" \
index 8099eda..4c4d9df 100644 (file)
@@ -20,6 +20,7 @@
 cimport glib
 
 cimport account
 cimport glib
 
 cimport account
+cimport accountopt
 cimport buddyicon
 cimport blist
 cimport connection
 cimport buddyicon
 cimport blist
 cimport connection