Removed ecore necessity from python-purple.
authorBruno Abinader <bruno.abinader@openbossa.org>
Mon, 2 Mar 2009 14:53:47 +0000 (10:53 -0400)
committerBruno Abinader <bruno.abinader@openbossa.org>
Mon, 1 Jun 2009 23:23:21 +0000 (19:23 -0400)
FIXES:
 - Removed ecore necessity from python-purple. Clients which should use
   it can now have their own main loop which doesn't need to be ecore.
   This patch was initially sent by Luca Bigliardi.

Signed-off-by: Luca Bigliardi <shammash@artha.org>
Signed-off-by: Bruno Abinader <bruno.abinader@openbossa.org>

nullclient-ecore.py
nullclient.py
purple.pyx

index fff3d59..571df91 100644 (file)
@@ -265,6 +265,7 @@ class NullClient(object):
         # Sets initial parameters
         self.core = purple.Purple(__NAME__, __VERSION__, __WEBSITE__, \
                 __DEV_WEBSITE__, debug_enabled=True, default_path='/tmp')
         # Sets initial parameters
         self.core = purple.Purple(__NAME__, __VERSION__, __WEBSITE__, \
                 __DEV_WEBSITE__, debug_enabled=True, default_path='/tmp')
+        ecore.Timer(0.01, self.core.iterate_main_loop)
         self.account = None
         self.buddies = {}
         self.conversations = {}
         self.account = None
         self.buddies = {}
         self.conversations = {}
index 0438951..8c7cb6b 100644 (file)
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import ecore
 import getpass
 import purple
 import sys
 import getpass
 import purple
 import sys
+import time
 
 # The information below is needed by libpurple
 __NAME__ = "nullclient"
 
 # The information below is needed by libpurple
 __NAME__ = "nullclient"
@@ -60,5 +60,6 @@ if __name__ == '__main__':
     # Enable account (connects automatically)
     account.set_enabled(True)
 
     # Enable account (connects automatically)
     account.set_enabled(True)
 
-    # Initializes ecore mainloop
-    ecore.main_loop_begin()
+    while True:
+        core.iterate_main_loop()
+        time.sleep(0.01)
index 17411e7..9c7691d 100644 (file)
@@ -22,7 +22,6 @@ cimport purple
 cdef extern from "c_purple.h":
     glib.guint glib_input_add(glib.gint fd, eventloop.PurpleInputCondition condition, eventloop.PurpleInputFunction function, glib.gpointer data)
 
 cdef extern from "c_purple.h":
     glib.guint glib_input_add(glib.gint fd, eventloop.PurpleInputCondition condition, eventloop.PurpleInputFunction function, glib.gpointer data)
 
-import ecore
 import signal
 
 cdef glib.GHashTable *c_ui_info
 import signal
 
 cdef glib.GHashTable *c_ui_info
@@ -91,9 +90,6 @@ cdef class Purple:
         if default_path:
             util.purple_util_set_user_dir(default_path)
 
         if default_path:
             util.purple_util_set_user_dir(default_path)
 
-        # adds glib iteration inside ecore main loop
-        ecore.timer_add(0.001, self.__glib_iteration_when_idle)
-
         # libpurple's built-in DNS resolution forks processes to perform
         # blocking lookups without blocking the main process.  It does not
         # handle SIGCHLD itself, so if the UI does not you quickly get an army
         # libpurple's built-in DNS resolution forks processes to perform
         # blocking lookups without blocking the main process.  It does not
         # handle SIGCHLD itself, so if the UI does not you quickly get an army
@@ -169,10 +165,6 @@ cdef class Purple:
             glib.g_hash_table_insert(c_ui_info, "dev_website", c_ui_dev_website)
         return c_ui_info
 
             glib.g_hash_table_insert(c_ui_info, "dev_website", c_ui_dev_website)
         return c_ui_info
 
-    def __glib_iteration_when_idle(self):
-        glib.g_main_context_iteration(NULL, False)
-        return True
-
     def purple_init(self):
         '''Initializes the purple.
 
     def purple_init(self):
         '''Initializes the purple.
 
@@ -418,6 +410,10 @@ cdef class Purple:
 
         return account_list
 
 
         return account_list
 
+    def iterate_main_loop(self):
+        glib.g_main_context_iteration(NULL, False)
+        return True
+
     def protocols_get_all(self):
         '''Returns a list of all protocols.
 
     def protocols_get_all(self):
         '''Returns a list of all protocols.