From 54c3652ebe4f40182214f4f37403ac13fcfeb7ff Mon Sep 17 00:00:00 2001 From: Ragner Magalhaes Date: Tue, 2 Dec 2008 20:48:20 +0000 Subject: [PATCH] Add support to new callback class Signed-off-by: Ricardo Guimaraes git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1353 596f6dd7-e928-0410-a184-9e12fd12cf7e --- callbackbase.pyx | 23 ++++++++++++++++++++--- nullclient-ecore.py | 16 ++++++++-------- purple.pyx | 3 --- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/callbackbase.pyx b/callbackbase.pyx index 5f6291e..a6ef6b7 100644 --- a/callbackbase.pyx +++ b/callbackbase.pyx @@ -1,10 +1,27 @@ -import purple -import ecore +# +# 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 . +# +# class CallBackBase: def __init__(self, dict_cbs): self.cbs = dict_cbs - + def add_callback(self, name, func): self.cbs[name] = func diff --git a/nullclient-ecore.py b/nullclient-ecore.py index fdaadd0..351e37c 100644 --- a/nullclient-ecore.py +++ b/nullclient-ecore.py @@ -13,14 +13,6 @@ request_cbs = {} def account_callback(name): print "---- account callback example: %s" % name -acc_cbs["notify_added"] = account_callback -acc_cbs["status_changed"] = account_callback -acc_cbs["request_add"] = account_callback -acc_cbs["request_authorize"] = account_callback -acc_cbs["close_account_request"] = account_callback - -cbs["account"] = acc_cbs - def blist_callback(name): print "---- blist callback example: %s" % name @@ -278,6 +270,14 @@ class NullClientPurple: global cbs cbs["blist"]["update"] = self._purple_update_blist_cb + + self.p.add_account_cb("notify_added", account_callback) + self.p.add_account_cb("status_changed", account_callback) + self.p.add_account_cb("request_add", account_callback) + self.p.add_account_cb("request_authorize", account_callback) + self.p.add_account_cb("close_account_request", account_callback) + + self.p.purple_init(cbs) self.p.accounts_init() diff --git a/purple.pyx b/purple.pyx index 889a509..d4d5383 100644 --- a/purple.pyx +++ b/purple.pyx @@ -80,7 +80,6 @@ cdef class Purple: # adds glib iteration inside ecore main loop ecore.timer_add(0.001, self.__glib_iteration_when_idle) - def destroy(self): core.c_purple_core_quit() @@ -142,14 +141,12 @@ cdef class Purple: """ Initializes libpurple """ if callbacks_dict is not None: - # global account_cbs global blist_cbs global connection_cbs global conversation_cbs global notify_cbs global request_cbs - # account_cbs = callbacks_dict["account"] blist_cbs = callbacks_dict["blist"] connection_cbs = callbacks_dict["connection"] conversation_cbs = callbacks_dict["conversation"] -- 1.7.9.5