Add support to new callback class
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:48:20 +0000 (20:48 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:13 +0000 (17:11 -0400)
Signed-off-by: Ricardo Guimaraes <ricardo.guimaraes@indt.org.br>

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

callbackbase.pyx
nullclient-ecore.py
purple.pyx

index 5f6291e..a6ef6b7 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
+#
+#
 
 class CallBackBase:
     def __init__(self, dict_cbs):
         self.cbs = dict_cbs
 
 class CallBackBase:
     def __init__(self, dict_cbs):
         self.cbs = dict_cbs
-    
+
     def add_callback(self, name, func):
         self.cbs[name] = func
 
     def add_callback(self, name, func):
         self.cbs[name] = func
 
index fdaadd0..351e37c 100644 (file)
@@ -13,14 +13,6 @@ request_cbs = {}
 def account_callback(name):
     print "---- account callback example: %s" % name
 
 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
 
 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
 
         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()
 
         self.p.purple_init(cbs)
         self.p.accounts_init()
 
index 889a509..d4d5383 100644 (file)
@@ -80,7 +80,6 @@ cdef class Purple:
         # adds glib iteration inside ecore main loop
         ecore.timer_add(0.001, self.__glib_iteration_when_idle)
 
         # 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()
 
     def destroy(self):
         core.c_purple_core_quit()
 
@@ -142,14 +141,12 @@ cdef class Purple:
         """ Initializes libpurple """
 
         if callbacks_dict is not None:
         """ 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
 
             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"]
             blist_cbs = callbacks_dict["blist"]
             connection_cbs = callbacks_dict["connection"]
             conversation_cbs = callbacks_dict["conversation"]