From a63ce1528885689b88ef3be9926acfd574a088db Mon Sep 17 00:00:00 2001 From: Ragner Magalhaes Date: Tue, 2 Dec 2008 20:33:34 +0000 Subject: [PATCH] Adding Classes Plugin and PluginInfo 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 Signed-off-by: Anderson Briglia 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 | 25 +++++++++++++++++++- libpurple/prpl.pxd | 17 +++++--------- plugin.pyx | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 12 deletions(-) create mode 100644 plugin.pyx diff --git a/libpurple/plugin.pxd b/libpurple/plugin.pxd index 5e5343e..ef6f81c 100644 --- a/libpurple/plugin.pxd +++ b/libpurple/plugin.pxd @@ -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) + + diff --git a/libpurple/prpl.pxd b/libpurple/prpl.pxd index 58cfafb..ed184f5 100644 --- a/libpurple/prpl.pxd +++ b/libpurple/prpl.pxd @@ -17,19 +17,14 @@ # along with this program. If not, see . # -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 index 0000000..020fde1 --- /dev/null +++ b/plugin.pyx @@ -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 . +# + +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 = 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 -- 1.7.9.5