Removed unused files, mixed C-only code with Cython code.
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:07:51 +0000 (20:07 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:09 +0000 (17:11 -0400)
FIXES:
- Moved calls from debug, plugin, util and c_purple.pxd directly into purple.pyx
- Changed Core class name to Purple.

Signed-off-by: Bruno Abinader <bruno.abinader@indt.org.br>

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

c_purple.c
c_purple.h
c_purple.pxd [deleted file]
core/debug.pxd [deleted file]
core/plugin.pxd [deleted file]
core/util.pxd [deleted file]
purple.pyx

index e5d5fa0..b77d659 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * 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/>.
+ *
+ */
+
 #include <purple.h>
 
 #include <glib.h>
@@ -17,11 +37,6 @@ typedef struct _PurpleGLibIOClosure {
        gpointer data;
 } PurpleGLibIOClosure;
 
-static void purple_glib_io_destroy(gpointer data)
-{
-       g_free(data);
-}
-
 static gboolean purple_glib_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
 {
        PurpleGLibIOClosure *closure = data;
@@ -55,7 +70,7 @@ static guint glib_input_add(gint fd, PurpleInputCondition condition, PurpleInput
 
        channel = g_io_channel_unix_new(fd);
        closure->result = g_io_add_watch_full(channel, 0, cond,
-                       purple_glib_io_invoke, closure, purple_glib_io_destroy);
+                       purple_glib_io_invoke, closure, g_free);
 
        g_io_channel_unref(channel);
        return closure->result;
@@ -106,7 +121,7 @@ static PurpleConversationUiOps conv_uiops =
        NULL,                      /* destroy_conversation */
        NULL,                      /* write_chat           */
        NULL,                      /* write_im             */
-       write_conv,           /* write_conv           */
+       write_conv,                /* write_conv           */
        NULL,                      /* chat_add_users       */
        NULL,                      /* chat_rename_user     */
        NULL,                      /* chat_remove_users    */
@@ -148,27 +163,19 @@ static PurpleCoreUiOps core_uiops =
        NULL
 };
 
-void init_libpurple(void)
+void init_libpurple(const char *ui_id)
 {
-       /* Set a custom user directory (optional) */
-       /* FIXME: Put a valid carman directory here*/
-       purple_util_set_user_dir(CUSTOM_USER_DIRECTORY);
-
-       /* We do not want any debugging for now to keep the noise to a minimum. */
-       purple_debug_set_enabled(FALSE);
-
        purple_core_set_ui_ops(&core_uiops);
 
        purple_eventloop_set_ui_ops(&glib_eventloops);
 
-       purple_plugins_add_search_path(CUSTOM_PLUGIN_PATH);
-
-       if (!purple_core_init(UI_ID)) {
+       if (!purple_core_init(ui_id)) {
                /* Initializing the core failed. Terminate. */
                fprintf(stderr,
                                "libpurple initialization failed. Dumping core.\n"
                                "Please report this!\n");
                abort();
        }
+
        printf("libpurple initialized");
 }
index 62dfe40..b8aa5b6 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * 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/>.
+ *
+ */
+
 #include <glib.h>
 
 #define CUSTOM_USER_DIRECTORY  "/dev/null"
@@ -6,4 +26,4 @@
 #define PLUGIN_SAVE_PREF       "/purple/nullclient/plugins/saved"
 #define UI_ID                  "carman-purple-client"
 
-void init_libpurple(void);
+void init_libpurple(const char *ui_id);
diff --git a/c_purple.pxd b/c_purple.pxd
deleted file mode 100644 (file)
index e23697f..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-cdef extern from *:
-    ctypedef char* const_char_ptr "const char *"
-
-cdef extern from "c_purple.h":
-     void init_libpurple()
diff --git a/core/debug.pxd b/core/debug.pxd
deleted file mode 100644 (file)
index 183733e..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-#  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/>.
-#
-
-cdef extern from "libpurple/debug.h":
-    void c_purple_debug_set_enabled "purple_debug_set_enabled" (gboolean debug_enabled)
-
-class Debug(object):
-    """ Debug class """
-
-    def __init__(self):
-        pass
-
-    def purple_debug_set_enabled(self, debug_enabled):
-        c_purple_debug_set_enabled(debug_enabled)
diff --git a/core/plugin.pxd b/core/plugin.pxd
deleted file mode 100644 (file)
index 0a9af58..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-#  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/>.
-#
-
-cdef extern from "libpurple/plugin.h":
-    ctypedef struct PurplePlugin:
-        pass
-
-    void c_purple_plugins_add_search_path "purple_plugins_add_search_path" (const_char_ptr path)
-    void c_purple_plugins_load_saved "purple_plugins_load_saved" (const_char_ptr key)
-    gboolean c_purple_plugin_register "purple_plugin_register" (PurplePlugin *plugin)
-
-class Plugin(object):
-    """ Plugin class """
-
-    def __init__(self):
-        purple_plugin = None
-
-    def purple_plugins_add_search_path(path):
-        c_purple_plugins_add_search_path(path)
-
-    def purple_plugins_load_saved(key):
-        c_purple_plugins_load_saved(key)
-
-    # FIXME
-    """
-    def purple_plugin_register(plugin):
-        return c_purple_plugin_register(plugin)
-    """
diff --git a/core/util.pxd b/core/util.pxd
deleted file mode 100644 (file)
index b960fd1..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-#  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/>.
-#
-
-cdef extern from "libpurple/util.h":
-    void c_purple_util_set_user_dir "purple_util_set_user_dir" (char *dir)
-
-class Utils(object):
-    """ Utils class """
-
-    def __init__(self):
-        pass
-
-    def purple_util_set_user_dir(self, dir):
-        c_purple_util_set_user_dir(dir)
index ec21c97..c45858f 100644 (file)
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+include "glib.pxd"
+
 cdef extern from *:
     ctypedef char* const_char_ptr "const char *"
 
 cdef extern from "time.h":
     ctypedef long int time_t
 
-class Core(object):
-    def init(self):
-        init_libpurple()
+cdef extern from "libpurple/debug.h":
+    void c_purple_debug_set_enabled "purple_debug_set_enabled" (gboolean debug_enabled)
+
+cdef extern from "libpurple/plugin.h":
+    void c_purple_plugins_add_search_path "purple_plugins_add_search_path" (const_char_ptr path)
+
+cdef extern from "libpurple/util.h":
+    void c_purple_util_set_user_dir "purple_util_set_user_dir" (char *dir)
+
+cdef extern from "c_purple.h":
+     void init_libpurple(const_char_ptr ui_id)
+
+class Purple(object):
+    def __init__(self):
+        self.DEFAULT_PATH = "/home/user/MyDocs/Carman"
+        self.APP_NAME = "carman-purple-python"
+
+        self.debug_set_enabled(True)
+        self.util_set_user_dir(self.DEFAULT_PATH)
+        self.plugin_add_search_path(self.DEFAULT_PATH)
+
+        init_libpurple(self.APP_NAME)
+    # __init__
+
+    def debug_set_enabled(self, debug_enabled):
+        c_purple_debug_set_enabled(debug_enabled)
+    # debug_set_enabled
+
+    def plugin_add_search_path(self, path):
+        c_purple_plugins_add_search_path(path)
+    # plugin_add_search_path
+
+    def util_set_user_dir(self, dir):
+        c_purple_util_set_user_dir(dir)
+    # util_set_user_dir
 
-include "c_purple.pxd"
-#include "glib.pxd"
 #include "core/account.pxd"
 #include "core/blist.pxd"
 #include "core/connection.pxd"
 #include "core/core.pxd"
-#include "core/debug.pxd"
 #include "core/eventloop.pxd"
 #include "core/idle.pxd"
-#include "core/plugin.pxd"
 #include "core/pounce.pxd"
 #include "core/prefs.pxd"
-#include "core/util.pxd"