+ def add_callback(self, type, name, callback):
+ '''Adds a callback with given name inside callback's type.
+
+ @param type Callback type (e.g. "account")
+ @param name Callback name (e.g. "notify-added")
+ @param callback Callback to be called
+ '''
+
+ global account_cbs
+ global blist_cbs
+ global connection_cbs
+ global conversation_cbs
+ global notify_cbs
+ global request_cbs
+
+ { "account": account_cbs,
+ "blist": blist_cbs,
+ "connection": connection_cbs,
+ "conversation": conversation_cbs,
+ "notify": notify_cbs,
+ "request": request_cbs }[type][name] = callback
+
+ def signal_connect(self, name=None, cb=None):
+ '''Connects a signal handler to a signal for a particular object.
+ Take care not to register a handler function twice. Purple will
+ not correct any mistakes for you in this area.
+
+ @param name Name of the signal to connect.
+ @param cb Callback function.
+ '''
+
+ cdef int handle
+ cdef plugin.PurplePlugin *jabber
+
+ if name is None:
+ return
+
+ jabber = prpl.purple_find_prpl("prpl-jabber")
+ if jabber == NULL:
+ return
+
+ global signal_cbs
+ signal_cbs[name] = cb
+
+ if name == "signed-on":
+ signals.purple_signal_connect(
+ connection.purple_connections_get_handle(),
+ "signed-on", &handle,
+ <signals.PurpleCallback> signal_signed_on_cb, NULL)
+ elif name == "signed-off":
+ signals.purple_signal_connect(
+ connection.purple_connections_get_handle(),
+ "signed-off", &handle,
+ <signals.PurpleCallback> signal_signed_off_cb, NULL)
+ elif name == "connection-error":
+ signals.purple_signal_connect(
+ connection.purple_connections_get_handle(),
+ "connection-error", &handle,
+ <signals.PurpleCallback> signal_connection_error_cb, NULL)
+ elif name == "buddy-signed-on":
+ signals.purple_signal_connect(
+ blist.purple_blist_get_handle(),
+ "buddy-signed-on", &handle,
+ <signals.PurpleCallback> signal_buddy_signed_on_cb, NULL)
+ elif name == "buddy-signed-off":
+ signals.purple_signal_connect(
+ blist.purple_blist_get_handle(),
+ "buddy-signed-off", &handle,
+ <signals.PurpleCallback> signal_buddy_signed_off_cb, NULL)
+ elif name == "receiving-im-msg":
+ signals.purple_signal_connect(
+ conversation.purple_conversations_get_handle(),
+ "receiving-im-msg", &handle,
+ <signals.PurpleCallback> signal_receiving_im_msg_cb, NULL)
+ elif name == "jabber-receiving-xmlnode":
+ signals.purple_signal_connect(
+ jabber, "jabber-receiving-xmlnode", &handle,
+ <signals.PurpleCallback> jabber_receiving_xmlnode_cb, NULL)
+
+ def accounts_get_all(self):
+ '''Returns a list of all accounts.
+
+ @return A list of all accounts.
+ '''
+