2 # Copyright (c) 2008 INdT - Instituto Nokia de Tecnologia
4 # This file is part of python-purple.
6 # python-purple is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # python-purple is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 ctypedef char* const_char_ptr "const char *"
25 cdef extern from "time.h":
26 ctypedef long int time_t
28 cdef extern from "libpurple/core.h":
29 gboolean c_purple_core_init "purple_core_init" (const_char_ptr ui_name)
30 void c_purple_core_quit "purple_core_quit" ()
31 gboolean c_purple_core_ensure_single_instance "purple_core_ensure_single_instance" ()
33 cdef extern from "libpurple/debug.h":
34 ctypedef enum PurpleDebugLevel:
42 void c_purple_debug "purple_debug" (PurpleDebugLevel level, const_char_ptr category, const_char_ptr format)
43 void c_purple_debug_set_enabled "purple_debug_set_enabled" (gboolean debug_enabled)
45 cdef extern from "libpurple/plugin.h":
46 void c_purple_plugins_add_search_path "purple_plugins_add_search_path" (const_char_ptr path)
48 cdef extern from "libpurple/util.h":
49 void c_purple_util_set_user_dir "purple_util_set_user_dir" (char *dir)
51 cdef extern from "c_purple.h":
56 self.DEFAULT_PATH = "/home/user/MyDocs/Carman"
57 self.APP_NAME = "carman-purple-python"
59 self.debug_set_enabled(True)
60 self.util_set_user_dir(self.DEFAULT_PATH)
61 self.plugin_add_search_path(self.DEFAULT_PATH)
65 ret = self.core_init(self.APP_NAME)
67 self.debug_info("main", "Exiting because libpurple initialization failed.")
70 # check if there is another instance of libpurple running
71 if self.core_ensure_single_instance() == False:
72 self.debug_info("main", "Exiting because another instance of libpurple is already running.")
81 def core_ensure_single_instance(self):
82 return c_purple_core_ensure_single_instance()
83 # core_ensure_single_instance
85 def core_init(self, ui_name):
86 return c_purple_core_init(ui_name)
93 def debug_misc(self, category, format):
95 c_purple_debug(PURPLE_DEBUG_MISC, NULL, format)
97 c_purple_debug(PURPLE_DEBUG_MISC, category, format)
100 def debug_info(self, category, format):
102 c_purple_debug(PURPLE_DEBUG_INFO, NULL, format)
104 c_purple_debug(PURPLE_DEBUG_INFO, category, format)
107 def debug_warning(self, category, format):
109 c_purple_debug(PURPLE_DEBUG_WARNING, NULL, format)
111 c_purple_debug(PURPLE_DEBUG_WARNING, category, format)
114 def debug_error(self, category, format):
116 c_purple_debug(PURPLE_DEBUG_ERROR, NULL, format)
118 c_purple_debug(PURPLE_DEBUG_ERROR, category, format)
121 def debug_fatal(self, category, format):
123 c_purple_debug(PURPLE_DEBUG_FATAL, NULL, format)
125 c_purple_debug(PURPLE_DEBUG_FATAL, category, format)
128 def debug_set_enabled(self, debug_enabled):
129 c_purple_debug_set_enabled(debug_enabled)
132 def plugin_add_search_path(self, path):
133 c_purple_plugins_add_search_path(path)
134 # plugin_add_search_path
136 def util_set_user_dir(self, dir):
137 c_purple_util_set_user_dir(dir)
140 #include "core/account.pxd"
141 #include "core/blist.pxd"
142 #include "core/connection.pxd"
143 #include "core/core.pxd"
144 #include "core/eventloop.pxd"
145 #include "core/idle.pxd"
146 #include "core/pounce.pxd"
147 #include "core/prefs.pxd"