Adding Classes Plugin and PluginInfo
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:33:34 +0000 (20:33 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:11 +0000 (17:11 -0400)
Adding Classes Plugin and PluginInfo to let us get the protocol's info

Note: This patch depends of the previous patch "[CARMAN][PATCH 1/1] Adding struct PurplePluginProtocolInfo"

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

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

libpurple/plugin.pxd
libpurple/prpl.pxd
plugin.pyx [new file with mode: 0644]

index 5e5343e..ef6f81c 100644 (file)
@@ -18,6 +18,7 @@
 #
 
 cimport glib
+cimport prpl
 
 cdef extern from "libpurple/plugin.h":
     ctypedef struct PurplePluginInfo:
@@ -25,7 +26,29 @@ cdef extern from "libpurple/plugin.h":
         char *name
 
     ctypedef struct PurplePlugin:
+        glib.gboolean native_plugin
+        glib.gboolean loaded
+        void *handle
+        char *path
         PurplePluginInfo *info
+        char *error
+        void *ipc_data
+        void *extra
+        glib.gboolean unloadable
+        glib.GList *dependent_plugins
 
-    void c_purple_plugins_add_search_path "purple_plugins_add_search_path" (char *path)
+    prpl.PurplePluginProtocolInfo *c_PURPLE_PLUGIN_PROTOCOL_INFO     \
+                "PURPLE_PLUGIN_PROTOCOL_INFO" (PurplePlugin *plugin)
+    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" ()
+
+    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" \
+            (char *id)
+
+
index 58cfafb..ed184f5 100644 (file)
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-cimport blist
-cimport conversation
-cimport ft
-#cimport imgstore
-cimport notify
-cimport proxy
-cimport plugin
-cimport roomlist
-cimport status
-#cimport whiteboard
 cimport glib
 
+cdef extern from "libpurple/plugin.h":
+    ctypedef struct PurplePlugin:
+        pass
+
 cdef extern from "libpurple/prpl.h":
     ctypedef struct PurplePluginProtocolInfo:
         glib.GList *protocol_options
-    plugin.PurplePlugin *c_purple_find_prpl "purple_find_prpl" (char *id)
+
+    PurplePlugin *c_purple_find_prpl "purple_find_prpl" (char *id)
diff --git a/plugin.pyx b/plugin.pyx
new file mode 100644 (file)
index 0000000..020fde1
--- /dev/null
@@ -0,0 +1,62 @@
+#
+#  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 prpl
+cimport purple
+
+
+cdef class Plugin:
+    cdef plugin.PurplePlugin *c_plugin
+    cdef prpl.PurplePluginProtocolInfo *c_prpl_info
+    cdef plugin.PurplePluginInfo *c_plugin_info
+
+    def __init__(self, id):
+        self.c_plugin = plugin.c_purple_plugins_find_with_id(id)
+        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_id(self):
+        return self.c_plugin.info.id
+
+
+cdef class Plugins:
+
+    cdef protocols
+
+    def __init__(self):
+        self.protocols = None
+
+    def get_protocols(self):
+        if self.protocols:
+            return self.protocols
+        cdef glib.GList *iter
+        cdef plugin.PurplePlugin *pp
+        protocols = []
+        iter = plugin.c_purple_plugins_get_protocols()
+        while iter:
+            pp = <plugin.PurplePlugin*> iter.data
+            if pp.info and pp.info.name:
+                p = Plugin(pp.info.id)
+                if p:
+                    protocols += [p]
+            iter = iter.next
+        self.protocols = protocols
+        return protocols