# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+cimport glib
+
+cimport connection
+
+cdef extern from *:
+ ctypedef char const_char "const char"
+ ctypedef int size_t
+
cdef extern from "libpurple/notify.h":
+ ctypedef struct PurpleNotifyUserInfoEntry
+ ctypedef struct PurpleNotifyUserInfo
+
+ ctypedef void (*PurpleNotifyCloseCallback) (glib.gpointer user_data)
+
+ ctypedef enum PurpleNotifyType:
+ PURPLE_NOTIFY_MESSAGE = 0
+ PURPLE_NOTIFY_EMAIL
+ PURPLE_NOTIFY_EMAILS
+ PURPLE_NOTIFY_FORMATTED
+ PURPLE_NOTIFY_SEARCHRESULTS
+ PURPLE_NOTIFY_USERINFO
+ PURPLE_NOTIFY_URI
+
+ ctypedef enum PurpleNotifyMsgType:
+ PURPLE_NOTIFY_MSG_ERROR = 0
+ PURPLE_NOTIFY_MSG_WARNING
+ PURPLE_NOTIFY_MSG_INFO
+
+ ctypedef enum PurpleNotifySearchButtonType:
+ PURPLE_NOTIFY_BUTTON_LABELED = 0
+ PURPLE_NOTIFY_BUTTON_CONTINUE = 1
+ PURPLE_NOTIFY_BUTTON_ADD
+ PURPLE_NOTIFY_BUTTON_INFO
+ PURPLE_NOTIFY_BUTTON_IM
+ PURPLE_NOTIFY_BUTTON_JOIN
+ PURPLE_NOTIFY_BUTTON_INVITE
+
+ ctypedef struct PurpleNotifySearchResults:
+ glib.GList *columns
+ glib.GList *rows
+ glib.GList *buttons
+
+ ctypedef struct PurpleNotifySearchColumn:
+ char *title
+
+ ctypedef void (*PurpleNotifySearchResultsCallback) (connection.PurpleConnection *c, glib.GList *row, glib.gpointer user_data)
+
+ ctypedef struct purpleNotifySearchButton:
+ PurpleNotifySearchButtonType type
+ PurpleNotifySearchResultsCallback callback
+ char *label
+
ctypedef struct PurpleNotifyUiOps:
- pass
+ void *(*notify_message) (PurpleNotifyMsgType type, const_char *title, \
+ const_char *primary, const_char *secondary)
+ void *(*notify_email) (connection.PurpleConnection *gc, \
+ const_char *subject, const_char *_from, const_char *to, \
+ const_char *url)
+ void *(*notify_emails) (connection.PurpleConnection *gc,
+ size_t count, glib.gboolean detailed, const_char **subjects, \
+ const_char **froms, const_char **tos, const_char **urls)
+ void *(*notify_formatted) (const_char *title, const_char *primary, \
+ const_char *secondary, const_char *text)
+ void *(*notify_searchresults) (connection.PurpleConnection *gc, \
+ const_char *title, const_char *primary, \
+ const_char *secondary, PurpleNotifySearchResults *results, \
+ glib.gpointer user_data)
+ void (*notify_searchresults_new_rows) \
+ (connection.PurpleConnection *gc, \
+ PurpleNotifySearchResults *results, void *data)
+ void *(*notify_userinfo) (connection.PurpleConnection *gc, \
+ const_char *who, PurpleNotifyUserInfo *user_info)
+ void *(*notify_uri) (const_char *uri)
+ void (*close_notify) (PurpleNotifyType type, void *ui_handle)
void c_purple_notify_set_ui_ops "purple_notify_set_ui_ops" (PurpleNotifyUiOps *ops)
--- /dev/null
+#
+# 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/>.
+#
+
+cimport purple
+
+notify_cbs = {}
+
+cdef extern from *:
+ ctypedef char const_char "const char"
+ ctypedef int size_t
+
+cdef void *notify_message (notify.PurpleNotifyMsgType type, const_char *title,
+ const_char *primary, const_char *secondary):
+ debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify_message\n")
+ try:
+ (<object>notify_cbs["notify_message"])("notify_message")
+ except KeyError:
+ pass
+
+cdef void *notify_email (connection.PurpleConnection *gc, const_char *subject,
+ const_char *_from, const_char *to, const_char *url):
+ debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify_email\n")
+ try:
+ (<object>notify_cbs["notify_email"])("notify_email")
+ except KeyError:
+ pass
+
+cdef void *notify_emails (connection.PurpleConnection *gc, size_t count,
+ glib.gboolean detailed, const_char **subjects,
+ const_char **froms, const_char **tos,
+ const_char **urls):
+ debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify_emails\n")
+ try:
+ (<object>notify_cbs["notify_emails"])("notify_emails")
+ except KeyError:
+ pass
+
+cdef void *notify_formatted (const_char *title, const_char *primary,
+ const_char *secondary, const_char *text):
+ debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify_formatted\n")
+ try:
+ (<object>notify_cbs["notify_formatted"])("notify_formatted")
+ except KeyError:
+ pass
+
+cdef void *notify_searchresults (connection.PurpleConnection *gc,
+ const_char *title, const_char *primary,
+ const_char *secondary,
+ notify.PurpleNotifySearchResults *results,
+ glib.gpointer user_data):
+ debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify",
+ "notify_searchresults\n")
+ try:
+ (<object>notify_cbs["notify_searchresults"])("notify_searchresults")
+ except KeyError:
+ pass
+
+cdef void notify_searchresults_new_rows (connection.PurpleConnection *gc,
+ notify.PurpleNotifySearchResults *results,
+ void *data):
+ debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify",
+ "notify_searchresults_new_rows\n")
+ try:
+ (<object>notify_cbs["notify_searchresults_new_rows"])("notify_searchresults_new_rows")
+ except KeyError:
+ pass
+
+cdef void *notify_userinfo (connection.PurpleConnection *gc, const_char *who,
+ notify.PurpleNotifyUserInfo *user_info):
+ debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify_userinfo\n")
+ try:
+ (<object>notify_cbs["notify_userinfo"])("notify_userinfo")
+ except KeyError:
+ pass
+
+cdef void *notify_uri (const_char *uri):
+ debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "notify_uri\n")
+ try:
+ (<object>notify_cbs["notify_uri"])("notify_uri")
+ except KeyError:
+ pass
+
+cdef void close_notify (notify.PurpleNotifyType type, void *ui_handle):
+ debug.c_purple_debug(debug.PURPLE_DEBUG_INFO, "notify", "close_notify\n")
+ try:
+ (<object>notify_cbs["close_notify"])("close_notify")
+ except KeyError:
+ pass
blist_cbs = {}
conn_cbs = {}
conv_cbs = {}
+notify_cbs = {}
def account_callback(name):
print "---- account callback example: %s" % name
cbs["conversation"] = conv_cbs
+def notify_callback(name):
+ print "---- notify callback example: %s" % name
+
+notify_cbs["notify_message"] = notify_callback
+notify_cbs["notify_email"] = notify_callback
+notify_cbs["notify_emails"] = notify_callback
+notify_cbs["notify_formatted"] = notify_callback
+notify_cbs["notify_searchresults"] = notify_callback
+notify_cbs["notify_searchresults_new_rows"] = notify_callback
+notify_cbs["notify_userinfo"] = notify_callback
+notify_cbs["notify_uri"] = notify_callback
+notify_cbs["close_notify"] = notify_callback
+
+cbs["notify"] = notify_cbs
+
class NullClient:
def __init__(self):
- self.p = purple.Purple()
+ self.p = purple.Purple(debug_enabled=False)
self.account = None
def execute(self):
cdef core.PurpleCoreUiOps c_core_ui_ops
cdef eventloop.PurpleEventLoopUiOps c_eventloop_ui_ops
#cdef ft.PurpleXferUiOps c_ft_ui_ops
-#cdef notify.PurpleNotifyUiOps c_notify_ui_ops
+cdef notify.PurpleNotifyUiOps c_notify_ui_ops
#cdef request.PurpleRequestUiOps c_request_ui_ops
#cdef roomlist.PurpleRoomlistUiOps c_rlist_ui_ops
include "blist_cbs.pxd"
include "connection_cbs.pxd"
include "conversation_cbs.pxd"
+include "notify_cbs.pxd"
cdef class Purple:
""" Purple class.
connection.c_purple_connections_set_ui_ops(&c_conn_ui_ops)
blist.c_purple_blist_set_ui_ops(&c_blist_ui_ops)
conversation.c_purple_conversations_set_ui_ops(&c_conv_ui_ops)
- #notify.c_purple_notify_set_ui_ops(&c_notify_ui_ops)
+ notify.c_purple_notify_set_ui_ops(&c_notify_ui_ops)
#request.c_purple_request_set_ui_ops(&c_request_ui_ops)
#ft.c_purple_xfers_set_ui_ops(&c_ft_ui_ops)
#roomlist.c_purple_roomlist_set_ui_ops(&c_rlist_ui_ops)
blist.c_purple_blist_set_ui_ops(NULL)
conversation.c_purple_conversations_set_ui_ops(NULL)
notify.c_purple_notify_set_ui_ops(NULL)
- request.c_purple_request_set_ui_ops(NULL)
- ft.c_purple_xfers_set_ui_ops(NULL)
- roomlist.c_purple_roomlist_set_ui_ops(NULL)
+ #request.c_purple_request_set_ui_ops(NULL)
+ #ft.c_purple_xfers_set_ui_ops(NULL)
+ #roomlist.c_purple_roomlist_set_ui_ops(NULL)
if c_ui_info:
glib.g_hash_table_destroy(c_ui_info)
global blist_cbs
global connection_cbs
global conversation_cbs
+ global notify_cbs
account_cbs = callbacks_dict["account"]
blist_cbs = callbacks_dict["blist"]
connection_cbs = callbacks_dict["connection"]
conversation_cbs = callbacks_dict["conversation"]
+ notify_cbs = callbacks_dict["notify"]
c_account_ui_ops.notify_added = notify_added
c_account_ui_ops.status_changed = status_changed
c_conv_ui_ops.custom_smiley_close = custom_smiley_close
c_conv_ui_ops.send_confirm = send_confirm
+ c_notify_ui_ops.notify_message = notify_message
+ c_notify_ui_ops.notify_email = notify_email
+ c_notify_ui_ops.notify_emails = notify_emails
+ c_notify_ui_ops.notify_formatted = notify_formatted
+ c_notify_ui_ops.notify_searchresults = notify_searchresults
+ c_notify_ui_ops.notify_searchresults_new_rows = notify_searchresults_new_rows
+ c_notify_ui_ops.notify_userinfo = notify_userinfo
+ c_notify_ui_ops.notify_uri = notify_uri
+ c_notify_ui_ops.close_notify = close_notify
+
c_core_ui_ops.ui_prefs_init = <void (*)()> self.__core_ui_ops_ui_prefs_init
c_core_ui_ops.debug_ui_init = <void (*)()> self.__core_ui_ops_debug_init
c_core_ui_ops.ui_init = <void (*)()> self.__core_ui_ops_ui_init