pidgin: 148bd4c3: Add purple_prpl_got_attention_in_chat, t...
qulogic at pidgin.im
qulogic at pidgin.im
Fri Jul 18 23:30:49 EDT 2008
-----------------------------------------------------------------
Revision: 148bd4c3ab2963d35af3a588de256c61851d7401
Ancestor: 12a47a486209652090154b7c125cd51a39f50c64
Author: qulogic at pidgin.im
Date: 2008-07-19T03:03:17
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/148bd4c3ab2963d35af3a588de256c61851d7401
Modified files:
libpurple/prpl.c libpurple/prpl.h libpurple/server.c
libpurple/server.h
ChangeLog:
Add purple_prpl_got_attention_in_chat, then deprecate
serv_{send,got}_attention, and add purple_prpl_{send,got}_attention
instead.
References #4542.
-------------- next part --------------
============================================================
--- libpurple/prpl.c 20e29dbf2ce48b137596ce894cb6887f667a1383
+++ libpurple/prpl.c a2f9ed66262e0720f017a353b705a132e4e7825e
@@ -389,7 +389,111 @@ purple_prpl_get_statuses(PurpleAccount *
return statuses;
}
+void
+purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code)
+{
+ PurpleAttentionType *attn;
+ PurpleMessageFlags flags;
+ PurplePlugin *prpl;
+ PurpleConversation *conv;
+ gboolean (*send_attention)(PurpleConnection *, const char *, guint);
+ PurpleBuddy *buddy;
+ const char *alias;
+ gchar *description;
+ time_t mtime;
+ g_return_if_fail(gc != NULL);
+ g_return_if_fail(who != NULL);
+
+ prpl = purple_find_prpl(purple_account_get_protocol_id(gc->account));
+ send_attention = PURPLE_PLUGIN_PROTOCOL_INFO(prpl)->send_attention;
+ g_return_if_fail(send_attention != NULL);
+
+ mtime = time(NULL);
+
+ attn = purple_get_attention_type_from_code(gc->account, type_code);
+
+ if ((buddy = purple_find_buddy(purple_connection_get_account(gc), who)) != NULL)
+ alias = purple_buddy_get_contact_alias(buddy);
+ else
+ alias = who;
+
+ if (attn && purple_attention_type_get_outgoing_desc(attn)) {
+ description = g_strdup_printf(purple_attention_type_get_outgoing_desc(attn), alias);
+ } else {
+ description = g_strdup_printf(_("Requesting %s's attention..."), alias);
+ }
+
+ flags = PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_SYSTEM;
+
+ purple_debug_info("server", "serv_send_attention: sending '%s' to %s\n",
+ description, who);
+
+ if (!send_attention(gc, who, type_code))
+ return;
+
+ conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, gc->account, who);
+ purple_conv_im_write(PURPLE_CONV_IM(conv), NULL, description, flags, mtime);
+
+ g_free(description);
+}
+
+static void
+got_attention(PurpleConnection *gc, int id, const char *who, guint type_code)
+{
+ PurpleMessageFlags flags;
+ PurpleAttentionType *attn;
+ PurpleBuddy *buddy;
+ const char *alias;
+ gchar *description;
+ time_t mtime;
+
+ mtime = time(NULL);
+
+ attn = purple_get_attention_type_from_code(gc->account, type_code);
+
+ /* PURPLE_MESSAGE_NOTIFY is for attention messages. */
+ flags = PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_RECV;
+
+ /* TODO: if (attn->icon_name) is non-null, use it to lookup an emoticon and display
+ * it next to the attention command. And if it is null, display a generic icon. */
+
+ if ((buddy = purple_find_buddy(purple_connection_get_account(gc), who)) != NULL)
+ alias = purple_buddy_get_contact_alias(buddy);
+ else
+ alias = who;
+
+ if (attn && purple_attention_type_get_incoming_desc(attn)) {
+ description = g_strdup_printf(purple_attention_type_get_incoming_desc(attn), alias);
+ } else {
+ description = g_strdup_printf(_("%s has requested your attention!"), alias);
+ }
+
+ purple_debug_info("server", "got_attention: got '%s' from %s\n",
+ description, who);
+
+ if (id == -1)
+ serv_got_im(gc, who, description, flags, mtime);
+ else
+ serv_got_chat_in(gc, id, who, flags, description, mtime);
+
+ /* TODO: sounds (depending on PurpleAttentionType), shaking, etc. */
+
+ g_free(description);
+}
+
+void
+purple_prpl_got_attention(PurpleConnection *gc, const char *who, guint type_code)
+{
+ got_attention(gc, -1, who, type_code);
+}
+
+void
+purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code)
+{
+ got_attention(gc, id, who, type_code);
+}
+
/**************************************************************************
* Protocol Plugin Subsystem API
**************************************************************************/
============================================================
--- libpurple/prpl.h 482ba99c34f8e42cfe275bf5b4ab5863b28a51ee
+++ libpurple/prpl.h 81ee17b22edfda143962a23bf3d045afdfb699c5
@@ -693,6 +693,41 @@ GList *purple_prpl_get_statuses(PurpleAc
*/
GList *purple_prpl_get_statuses(PurpleAccount *account, PurplePresence *presence);
+/** Send an attention request message.
+ *
+ * @param gc The connection to send the message on.
+ * @param who Whose attention to request.
+ * @param type_code An index into the prpl's attention_types list determining the type
+ * of the attention request command to send. 0 if prpl only defines one
+ * (for example, Yahoo and MSN), but some protocols define more (MySpaceIM).
+ *
+ * Note that you can't send arbitrary PurpleAttentionType's, because there is
+ * only a fixed set of attention commands.
+ * @since 2.5.0
+ */
+void purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code);
+
+/** Process an incoming attention message.
+ *
+ * @param gc The connection that received the attention message.
+ * @param who Who requested your attention.
+ * @param type_code An index into the prpl's attention_types list determining the type
+ * of the attention request command to send.
+ * @since 2.5.0
+ */
+void purple_prpl_got_attention(PurpleConnection *gc, const char *who, guint type_code);
+
+/** Process an incoming attention message in a chat.
+ *
+ * @param gc The connection that received the attention message.
+ * @param id The chat id.
+ * @param who Who requested your attention.
+ * @param type_code An index into the prpl's attention_types list determining the type
+ * of the attention request command to send.
+ * @since 2.5.0
+ */
+void purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code);
+
/*@}*/
/**************************************************************************/
============================================================
--- libpurple/server.c 73a18b2e00e11235eb9484d5bd5a9c33c1dcb248
+++ libpurple/server.c e74048f20bb650c37a28302ca336d26c6514c34e
@@ -323,91 +323,13 @@ serv_send_attention(PurpleConnection *gc
void
serv_send_attention(PurpleConnection *gc, const char *who, guint type_code)
{
- PurpleAttentionType *attn;
- PurpleMessageFlags flags;
- PurplePlugin *prpl;
- PurpleConversation *conv;
- gboolean (*send_attention)(PurpleConnection *, const char *, guint);
- PurpleBuddy *buddy;
- const char *alias;
- gchar *description;
- time_t mtime;
-
- g_return_if_fail(gc != NULL);
- g_return_if_fail(who != NULL);
-
- prpl = purple_find_prpl(purple_account_get_protocol_id(gc->account));
- send_attention = PURPLE_PLUGIN_PROTOCOL_INFO(prpl)->send_attention;
- g_return_if_fail(send_attention != NULL);
-
- mtime = time(NULL);
-
- attn = purple_get_attention_type_from_code(gc->account, type_code);
-
- if ((buddy = purple_find_buddy(purple_connection_get_account(gc), who)) != NULL)
- alias = purple_buddy_get_contact_alias(buddy);
- else
- alias = who;
-
- if (attn && purple_attention_type_get_outgoing_desc(attn)) {
- description = g_strdup_printf(purple_attention_type_get_outgoing_desc(attn), alias);
- } else {
- description = g_strdup_printf(_("Requesting %s's attention..."), alias);
- }
-
- flags = PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_SYSTEM;
-
- purple_debug_info("server", "serv_send_attention: sending '%s' to %s\n",
- description, who);
-
- if (!send_attention(gc, who, type_code))
- return;
-
- conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, gc->account, who);
- purple_conv_im_write(PURPLE_CONV_IM(conv), NULL, description, flags, mtime);
-
- g_free(description);
+ purple_prpl_send_attention(gc, who, type_code);
}
void
serv_got_attention(PurpleConnection *gc, const char *who, guint type_code)
{
- PurpleMessageFlags flags;
- PurpleAttentionType *attn;
- PurpleBuddy *buddy;
- const char *alias;
- gchar *description;
- time_t mtime;
-
- mtime = time(NULL);
-
- attn = purple_get_attention_type_from_code(gc->account, type_code);
-
- /* PURPLE_MESSAGE_NOTIFY is for attention messages. */
- flags = PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_RECV;
-
- /* TODO: if (attn->icon_name) is non-null, use it to lookup an emoticon and display
- * it next to the attention command. And if it is null, display a generic icon. */
-
- if ((buddy = purple_find_buddy(purple_connection_get_account(gc), who)) != NULL)
- alias = purple_buddy_get_contact_alias(buddy);
- else
- alias = who;
-
- if (attn && purple_attention_type_get_incoming_desc(attn)) {
- description = g_strdup_printf(purple_attention_type_get_incoming_desc(attn), alias);
- } else {
- description = g_strdup_printf(_("%s has requested your attention!"), alias);
- }
-
- purple_debug_info("server", "serv_got_attention: got '%s' from %s\n",
- description, who);
-
- serv_got_im(gc, who, description, flags, mtime);
-
- /* TODO: sounds (depending on PurpleAttentionType), shaking, etc. */
-
- g_free(description);
+ purple_prpl_got_attention(gc, who, type_code);
}
============================================================
--- libpurple/server.h 2d4f6944539b1304ae6435e480f1a460ca986f25
+++ libpurple/server.h 594cdf94d66f7f6af6439a1ad6c4b9a10e7d0689
@@ -63,6 +63,8 @@ PurpleAttentionType *purple_get_attentio
/** Send an attention request message.
*
+ * @deprecated Use purple_prpl_send_attention() instead.
+ *
* @param gc The connection to send the message on.
* @param who Whose attention to request.
* @param type_code An index into the prpl's attention_types list determining the type
@@ -76,6 +78,8 @@ void serv_send_attention(PurpleConnectio
/** Process an incoming attention message.
*
+ * @deprecated Use purple_prpl_got_attention() instead.
+ *
* @param gc The connection that received the attention message.
* @param who Who requested your attention.
* @param type_code An index into the prpl's attention_types list determining the type
More information about the Commits
mailing list