comparison libpurple/server.c @ 19426:6395c2e96bc2

Attention API for nudges/buzzes/zaps of various protocols. (This API addition can now be committed since it we're in 2.2.0.) Patch also available at http://msimprpl.darkthoughts.net/attention3.diff. Closes #2662.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Sat, 25 Aug 2007 22:33:40 +0000
parents 7684084830c6
children 3ad938b84843
comparison
equal deleted inserted replaced
19425:4fced00fdc9f 19426:6395c2e96bc2
240 g_free(tmp); 240 g_free(tmp);
241 } 241 }
242 } 242 }
243 } 243 }
244 244
245 /** Indicate that an attention message was sent or received. */
246 void
247 serv_got_attention(PurpleConnection *gc, const char *who, PurpleAttentionType *attn, gboolean incoming)
248 {
249 PurpleConversation *conv;
250 PurpleMessageFlags flags;
251 gchar *description;
252 int plugin_return;
253
254
255 /* For incoming messages, block the attention message if requested (privacy) */
256 if (incoming) {
257 gchar *who_copy;
258
259 if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->set_permit_deny == NULL)
260 if (!purple_privacy_check(gc->account, who))
261 return;
262
263 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, gc->account);
264
265 who_copy = g_strdup(who);
266
267 plugin_return = GPOINTER_TO_INT(
268 purple_signal_emit_return_1(purple_conversations_get_handle(),
269 "receiving-im-msg", gc->account,
270 &who_copy, &attn, conv));
271
272 if (!attn || !who_copy || plugin_return) {
273 g_free(who_copy);
274 return;
275 }
276
277 purple_signal_emit(purple_conversations_get_handle(), "received-im-msg", gc->account,
278 who, attn, conv);
279 }
280
281 /* The attention message was allowed. Create a string representing the message. */
282 flags = PURPLE_MESSAGE_SYSTEM;
283
284 /* TODO: if (attn->icon_name) is non-null, use it to lookup an emoticon and display
285 * it next to the attention command. And if it is null, display a generic icon. */
286
287 if (incoming) {
288 if (attn->incoming_description) {
289 description = g_strdup_printf(_("Attention! You have been %s."), attn->incoming_description);
290 } else {
291 description = g_strdup(_("Attention!"));
292 }
293 flags |= PURPLE_MESSAGE_RECV;
294 } else {
295 if (attn->outgoing_description) {
296 description = g_strdup_printf(_("Attention! %s %s."), attn->outgoing_description, who);
297 } else {
298 description = g_strdup(_("Attention!"));
299 }
300 flags |= PURPLE_MESSAGE_SEND;
301 }
302
303 /* Display it in the conversation window to the user. */
304 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, gc->account);
305 if (!conv)
306 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, gc->account, who);
307
308 purple_conv_im_write(PURPLE_CONV_IM(conv), NULL, description, flags, time(NULL));
309
310 g_free(description);
311 }
312
313
245 /* 314 /*
246 * Move a buddy from one group to another on server. 315 * Move a buddy from one group to another on server.
247 * 316 *
248 * Note: For now we'll not deal with changing gc's at the same time, but 317 * Note: For now we'll not deal with changing gc's at the same time, but
249 * it should be possible. Probably needs to be done, someday. Although, 318 * it should be possible. Probably needs to be done, someday. Although,