void set_displaying_userinfo(PurplePlugin *plugin, PyObject *func) { static PyObject *displaying_userinfo_cb = 0; Py_XINCREF(func); Py_XDECREF(displaying_userinfo_cb); displaying_userinfo_cb = func; purple_signal_connect(purple_notify_get_handle(), "displaying-userinfo", plugin, PURPLE_CALLBACK(displaying_userinfo), displaying_userinfo_cb); }
void * purple_notify_emails(void *handle, size_t count, gboolean detailed, const char **subjects, const char **froms, const char **tos, const char **urls, PurpleNotifyCloseCallback cb, gpointer user_data) { PurpleNotifyUiOps *ops; if (count == 1) { return purple_notify_email(handle, (subjects == NULL ? NULL : *subjects), (froms == NULL ? NULL : *froms), (tos == NULL ? NULL : *tos), (urls == NULL ? NULL : *urls), cb, user_data); } ops = purple_notify_get_ui_ops(); if (ops != NULL && ops->notify_emails != NULL) { void *ui_handle; purple_signal_emit(purple_notify_get_handle(), "displaying-emails-notification", subjects, froms, tos, urls, count); ui_handle = ops->notify_emails(handle, count, detailed, subjects, froms, tos, urls); if (ui_handle != NULL) { PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1); info->type = PURPLE_NOTIFY_EMAILS; info->handle = handle; info->ui_handle = ui_handle; info->cb = cb; info->cb_user_data = user_data; handles = g_list_append(handles, info); return info->ui_handle; } } if (cb != NULL) cb(user_data); return NULL; }
void * purple_notify_userinfo(PurpleConnection *gc, const char *who, PurpleNotifyUserInfo *user_info, PurpleNotifyCloseCallback cb, gpointer user_data) { PurpleNotifyUiOps *ops; g_return_val_if_fail(who != NULL, NULL); ops = purple_notify_get_ui_ops(); if (ops != NULL && ops->notify_userinfo != NULL) { void *ui_handle; purple_signal_emit(purple_notify_get_handle(), "displaying-userinfo", purple_connection_get_account(gc), who, user_info); ui_handle = ops->notify_userinfo(gc, who, user_info); if (ui_handle != NULL) { PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1); info->type = PURPLE_NOTIFY_USERINFO; info->handle = gc; info->ui_handle = ui_handle; info->cb = cb; info->cb_user_data = user_data; handles = g_list_append(handles, info); return info->ui_handle; } } if (cb != NULL) cb(user_data); return NULL; }
void purple_notify_init(void) { gpointer handle = purple_notify_get_handle(); purple_signal_register(handle, "displaying-email-notification", purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER, G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); purple_signal_register(handle, "displaying-emails-notification", purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT, G_TYPE_NONE, 5, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_UINT); purple_signal_register(handle, "displaying-emails-clear", purple_marshal_VOID, G_TYPE_NONE, 0); purple_signal_register(handle, "displaying-userinfo", purple_marshal_VOID__POINTER_POINTER_POINTER, G_TYPE_NONE, 3, PURPLE_TYPE_ACCOUNT, G_TYPE_STRING, PURPLE_TYPE_NOTIFY_USER_INFO); }
void * purple_notify_email(void *handle, const char *subject, const char *from, const char *to, const char *url, PurpleNotifyCloseCallback cb, gpointer user_data) { PurpleNotifyUiOps *ops; ops = purple_notify_get_ui_ops(); if (ops != NULL && ops->notify_email != NULL) { void *ui_handle; purple_signal_emit(purple_notify_get_handle(), "displaying-email-notification", subject, from, to, url); ui_handle = ops->notify_email(handle, subject, from, to, url); if (ui_handle != NULL) { PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1); info->type = PURPLE_NOTIFY_EMAIL; info->handle = handle; info->ui_handle = ui_handle; info->cb = cb; info->cb_user_data = user_data; handles = g_list_append(handles, info); return info->ui_handle; } } if (cb != NULL) cb(user_data); return NULL; }
void purple_notify_uninit(void) { purple_signals_unregister_by_instance(purple_notify_get_handle()); }
/************************************************************************** * Plugin stuff **************************************************************************/ static gboolean plugin_load(PurplePlugin *plugin) { void *core_handle = purple_get_core(); void *acc_handle = purple_accounts_get_handle(); void *blist_handle = purple_blist_get_handle(); void *conn_handle = purple_connections_get_handle(); void *conv_handle = purple_conversations_get_handle(); void *ft_handle = purple_xfers_get_handle(); void *notify_handle = purple_notify_get_handle(); //gntp_register(NULL); connected = 0; registered = 0; connect_to_dll(); _getcwd(DefaultIcon, _MAX_PATH); strcat(DefaultIcon, "/pixmaps/pidgin/growl_icon.png"); if(!registered) { if(growl_register) { growl_register(SERVER_IP, PLUGIN_NAME, (const char **const)notifications, 12, 0, DefaultIcon); registered = 1; } } /* Account subsystem signals */ purple_signal_connect(acc_handle, "account-status-changed", plugin, PURPLE_CALLBACK(account_status_changed_cb), NULL); /* Buddy List subsystem signals */ purple_signal_connect(blist_handle, "buddy-status-changed", plugin, PURPLE_CALLBACK(buddy_status_changed_cb), NULL); purple_signal_connect(blist_handle, "buddy-signed-on", plugin, PURPLE_CALLBACK(buddy_signed_on_cb), NULL); purple_signal_connect(blist_handle, "buddy-signed-off", plugin, PURPLE_CALLBACK(buddy_signed_off_cb), NULL); purple_signal_connect(blist_handle, "buddy-icon-changed", plugin, PURPLE_CALLBACK(buddy_icon_changed_cb), NULL); /* Connection subsystem signals */ purple_signal_connect(conn_handle, "signed-on", plugin, PURPLE_CALLBACK(signed_on_cb), NULL); purple_signal_connect(conn_handle, "signed-off", plugin, PURPLE_CALLBACK(signed_off_cb), NULL); purple_signal_connect(conn_handle, "connection-error", plugin, PURPLE_CALLBACK(connection_error_cb), NULL); /* Conversations subsystem signals */ purple_signal_connect(conv_handle, "wrote-im-msg", plugin, PURPLE_CALLBACK(wrote_im_msg_cb), NULL); purple_signal_connect(conv_handle, "sent-im-msg", plugin, PURPLE_CALLBACK(sent_im_msg_cb), NULL); purple_signal_connect(conv_handle, "received-im-msg", plugin, PURPLE_CALLBACK(received_im_msg_cb), NULL); purple_signal_connect(conv_handle, "wrote-chat-msg", plugin, PURPLE_CALLBACK(wrote_chat_msg_cb), NULL); purple_signal_connect(conv_handle, "sent-chat-msg", plugin, PURPLE_CALLBACK(sent_chat_msg_cb), NULL); purple_signal_connect(conv_handle, "received-chat-msg", plugin, PURPLE_CALLBACK(received_chat_msg_cb), NULL); purple_signal_connect(conv_handle, "conversation-created", plugin, PURPLE_CALLBACK(conversation_created_cb), NULL); purple_signal_connect(conv_handle, "chat-buddy-joined", plugin, PURPLE_CALLBACK(chat_buddy_joined_cb), NULL); purple_signal_connect(conv_handle, "chat-buddy-flags", plugin, PURPLE_CALLBACK(chat_buddy_flags_cb), NULL); purple_signal_connect(conv_handle, "chat-buddy-left", plugin, PURPLE_CALLBACK(chat_buddy_left_cb), NULL); purple_signal_connect(conv_handle, "chat-invited-user", plugin, PURPLE_CALLBACK(chat_invited_user_cb), NULL); purple_signal_connect(conv_handle, "chat-invited", plugin, PURPLE_CALLBACK(chat_invited_cb), NULL); purple_signal_connect(conv_handle, "chat-joined", plugin, PURPLE_CALLBACK(chat_joined_cb), NULL); purple_signal_connect(conv_handle, "chat-left", plugin, PURPLE_CALLBACK(chat_left_cb), NULL); purple_signal_connect(conv_handle, "chat-topic-changed", plugin, PURPLE_CALLBACK(chat_topic_changed_cb), NULL); /* Core signals */ purple_signal_connect(core_handle, "quitting", plugin, PURPLE_CALLBACK(quitting_cb), NULL); /* File transfer signals */ purple_signal_connect(ft_handle, "file-recv-accept", plugin, PURPLE_CALLBACK(ft_recv_accept_cb), NULL); purple_signal_connect(ft_handle, "file-recv-start", plugin, PURPLE_CALLBACK(ft_recv_start_cb), NULL); purple_signal_connect(ft_handle, "file-recv-cancel", plugin, PURPLE_CALLBACK(ft_recv_cancel_cb), NULL); purple_signal_connect(ft_handle, "file-recv-complete", plugin, PURPLE_CALLBACK(ft_recv_complete_cb), NULL); purple_signal_connect(ft_handle, "file-send-accept", plugin, PURPLE_CALLBACK(ft_send_accept_cb), NULL); purple_signal_connect(ft_handle, "file-send-start", plugin, PURPLE_CALLBACK(ft_send_start_cb), NULL); purple_signal_connect(ft_handle, "file-send-cancel", plugin, PURPLE_CALLBACK(ft_send_cancel_cb), NULL); purple_signal_connect(ft_handle, "file-send-complete", plugin, PURPLE_CALLBACK(ft_send_complete_cb), NULL); /* Notify signals */ purple_signal_connect(notify_handle, "displaying-email-notification", plugin, PURPLE_CALLBACK(notify_email_cb), NULL); purple_signal_connect(notify_handle, "displaying-emails-notification", plugin, PURPLE_CALLBACK(notify_emails_cb), NULL); return TRUE; }