Sun, 26 Aug 2007 06:30:41 +0000
In msimprpl, move zap-related code to a separate module.
|
19616
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
1 | /* MySpaceIM Protocol Plugin - zap support |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
2 | * |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
3 | * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im> |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
4 | * |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
5 | * This program is free software; you can redistribute it and/or modify |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
7 | * the Free Software Foundation; either version 2 of the License, or |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
9 | * |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
14 | * |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
16 | * along with this program; if not, write to the Free Software |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
18 | */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
19 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
20 | #include "myspace.h" |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
21 | #include "zap.h" |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
22 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
23 | static gboolean msim_send_zap(MsimSession *session, const gchar *username, guint code); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
24 | static void msim_send_zap_from_menu(PurpleBlistNode *node, gpointer zap_num_ptr); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
25 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
26 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
27 | /** Get zap types. */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
28 | GList * |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
29 | msim_attention_types(PurpleAccount *acct) |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
30 | { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
31 | static GList *types = NULL; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
32 | MsimAttentionType* attn; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
33 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
34 | if (!types) { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
35 | #define _MSIM_ADD_NEW_ATTENTION(icn, nme, incoming, outgoing) \ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
36 | attn = g_new0(MsimAttentionType, 1); \ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
37 | attn->icon_name = icn; \ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
38 | attn->name = nme; \ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
39 | attn->incoming_description = incoming; \ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
40 | attn->outgoing_description = outgoing; \ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
41 | types = g_list_append(types, attn); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
42 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
43 | /* TODO: icons for each zap */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
44 | _MSIM_ADD_NEW_ATTENTION(NULL, _("zap"), _("zapped"), _("Zapping")); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
45 | _MSIM_ADD_NEW_ATTENTION(NULL, _("whack"), _("whacked"), _("Whacking")); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
46 | _MSIM_ADD_NEW_ATTENTION(NULL, _("torch"), _("torched"), _("Torching")); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
47 | _MSIM_ADD_NEW_ATTENTION(NULL, _("smooch"), _("smooched"), _("Smooching")); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
48 | _MSIM_ADD_NEW_ATTENTION(NULL, _("hug"), _("hugged"), _("Hugging")); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
49 | _MSIM_ADD_NEW_ATTENTION(NULL, _("bslap"), _("bslapped"), _("Bslapping")); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
50 | _MSIM_ADD_NEW_ATTENTION(NULL, _("goose"), _("goosed"), _("Goosing")); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
51 | _MSIM_ADD_NEW_ATTENTION(NULL, _("hi-five"), _("hi-fived"), _("Hi-fiving")); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
52 | _MSIM_ADD_NEW_ATTENTION(NULL, _("punk"), _("punk'd"), _("Punking")); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
53 | _MSIM_ADD_NEW_ATTENTION(NULL, _("raspberry"), _("raspberried"), _("Raspberry'ing")); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
54 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
55 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
56 | return types; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
57 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
58 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
59 | /** Send a zap */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
60 | gboolean |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
61 | msim_send_attention(PurpleConnection *gc, const gchar *username, guint code) |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
62 | { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
63 | GList *types; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
64 | MsimSession *session; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
65 | MsimAttentionType *attn; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
66 | PurpleBuddy *buddy; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
67 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
68 | session = (MsimSession *)gc->proto_data; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
69 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
70 | /* Look for this attention type, by the code index given. */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
71 | types = msim_attention_types(gc->account); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
72 | attn = (MsimAttentionType *)g_list_nth_data(types, code); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
73 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
74 | if (!attn) { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
75 | purple_debug_info("msim_send_attention", "got invalid zap code %d\n", code); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
76 | return FALSE; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
77 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
78 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
79 | buddy = purple_find_buddy(session->account, username); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
80 | if (!buddy) { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
81 | return FALSE; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
82 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
83 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
84 | /* TODO: make use of the MsimAttentionType we found, instead of |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
85 | * doing it all over in msim_send_zap_from_menu. */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
86 | msim_send_zap_from_menu(&buddy->node, GUINT_TO_POINTER(code)); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
87 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
88 | return TRUE; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
89 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
90 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
91 | /** Send a zap to a user. */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
92 | static gboolean |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
93 | msim_send_zap(MsimSession *session, const gchar *username, guint code) |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
94 | { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
95 | gchar *zap_string; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
96 | #ifndef MSIM_USE_ATTENTION_API |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
97 | gchar *zap_description; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
98 | #endif |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
99 | GList *types; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
100 | MsimAttentionType *attn; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
101 | gboolean rc; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
102 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
103 | g_return_val_if_fail(session != NULL, FALSE); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
104 | g_return_val_if_fail(username != NULL, FALSE); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
105 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
106 | types = msim_attention_types(session->account); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
107 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
108 | attn = g_list_nth_data(types, code); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
109 | if (!attn) { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
110 | return FALSE; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
111 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
112 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
113 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
114 | #ifdef MSIM_USE_ATTENTION_API |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
115 | serv_got_attention(session->gc, username, attn, FALSE); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
116 | #else |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
117 | zap_description = g_strdup_printf("*** Attention: %s %s ***", attn->outgoing_description, |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
118 | username); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
119 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
120 | serv_got_im(session->gc, username, zap_description, |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
121 | PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
122 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
123 | g_free(zap_description); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
124 | #endif |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
125 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
126 | /* Construct and send the actual zap command. */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
127 | zap_string = g_strdup_printf("!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", code); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
128 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
129 | if (!msim_send_bm(session, username, zap_string, MSIM_BM_ACTION)) { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
130 | purple_debug_info("msim_send_zap_from_menu", "msim_send_bm failed: zapping %s with %s", |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
131 | username, zap_string); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
132 | rc = FALSE; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
133 | } else { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
134 | rc = TRUE; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
135 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
136 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
137 | g_free(zap_string); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
138 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
139 | return rc; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
140 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
141 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
142 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
143 | /** Zap someone. Callback from msim_blist_node_menu zap menu. */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
144 | static void |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
145 | msim_send_zap_from_menu(PurpleBlistNode *node, gpointer zap_num_ptr) |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
146 | { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
147 | PurpleBuddy *buddy; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
148 | PurpleAccount *account; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
149 | PurpleConnection *gc; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
150 | MsimSession *session; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
151 | guint zap; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
152 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
153 | if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
154 | /* Only know about buddies for now. */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
155 | return; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
156 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
157 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
158 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
159 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
160 | buddy = (PurpleBuddy *)node; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
161 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
162 | /* Find the session */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
163 | account = buddy->account; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
164 | gc = purple_account_get_connection(account); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
165 | session = (MsimSession *)gc->proto_data; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
166 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
167 | zap = GPOINTER_TO_INT(zap_num_ptr); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
168 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
169 | g_return_if_fail(msim_send_zap(session, buddy->name, zap)); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
170 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
171 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
172 | /** Return menu, if any, for a buddy list node. */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
173 | GList * |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
174 | msim_blist_node_menu(PurpleBlistNode *node) |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
175 | { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
176 | GList *menu, *zap_menu; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
177 | GList *types; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
178 | PurpleMenuAction *act; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
179 | /* Warning: hardcoded to match that in msim_attention_types. */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
180 | const gchar *zap_names[10]; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
181 | guint i; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
182 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
183 | if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
184 | /* Only know about buddies for now. */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
185 | return NULL; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
186 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
187 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
188 | /* Names from official client. */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
189 | types = msim_attention_types(NULL); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
190 | i = 0; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
191 | do |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
192 | { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
193 | MsimAttentionType *attn; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
194 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
195 | attn = (MsimAttentionType *)types->data; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
196 | zap_names[i] = attn->name; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
197 | ++i; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
198 | } while ((types = g_list_next(types))); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
199 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
200 | menu = zap_menu = NULL; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
201 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
202 | /* TODO: get rid of once is accessible directly in GUI */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
203 | for (i = 0; i < sizeof(zap_names) / sizeof(zap_names[0]); ++i) { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
204 | act = purple_menu_action_new(zap_names[i], PURPLE_CALLBACK(msim_send_zap_from_menu), |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
205 | GUINT_TO_POINTER(i), NULL); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
206 | zap_menu = g_list_append(zap_menu, act); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
207 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
208 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
209 | act = purple_menu_action_new(_("Zap"), NULL, NULL, zap_menu); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
210 | menu = g_list_append(menu, act); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
211 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
212 | return menu; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
213 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
214 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
215 | /** Process an incoming zap. */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
216 | gboolean |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
217 | msim_incoming_zap(MsimSession *session, MsimMessage *msg) |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
218 | { |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
219 | gchar *msg_text, *username; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
220 | gint zap; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
221 | const gchar *zap_past_tense[10]; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
222 | #ifdef MSIM_USE_ATTENTION_API |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
223 | MsimAttentionType attn; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
224 | #else |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
225 | gchar *zap_text; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
226 | #endif |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
227 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
228 | zap_past_tense[0] = _("zapped"); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
229 | zap_past_tense[1] = _("whacked"); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
230 | zap_past_tense[2] = _("torched"); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
231 | zap_past_tense[3] = _("smooched"); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
232 | zap_past_tense[4] = _("hugged"); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
233 | zap_past_tense[5] = _("bslapped"); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
234 | zap_past_tense[6] = _("goosed"); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
235 | zap_past_tense[7] = _("hi-fived"); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
236 | zap_past_tense[8] = _("punk'd"); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
237 | zap_past_tense[9] = _("raspberried"); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
238 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
239 | msg_text = msim_msg_get_string(msg, "msg"); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
240 | username = msim_msg_get_string(msg, "_username"); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
241 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
242 | g_return_val_if_fail(msg_text != NULL, FALSE); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
243 | g_return_val_if_fail(username != NULL, FALSE); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
244 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
245 | g_return_val_if_fail(sscanf(msg_text, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", &zap) == 1, FALSE); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
246 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
247 | zap = CLAMP(zap, 0, sizeof(zap_past_tense) / sizeof(zap_past_tense[0])); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
248 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
249 | /* TODO:ZAP: use msim_attention_types */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
250 | #ifdef MSIM_USE_ATTENTION_API |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
251 | attn.incoming_description = zap_past_tense[zap]; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
252 | attn.outgoing_description = NULL; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
253 | attn.icon_name = NULL; /* TODO: icon */ |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
254 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
255 | serv_got_attention(session->gc, username, &attn, TRUE); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
256 | #else |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
257 | zap_text = g_strdup_printf(_("*** You have been %s! ***"), zap_past_tense[zap]); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
258 | serv_got_im(session->gc, username, zap_text, |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
259 | PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
260 | g_free(zap_text); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
261 | #endif |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
262 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
263 | g_free(msg_text); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
264 | g_free(username); |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
265 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
266 | return TRUE; |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
267 | } |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
268 | |
|
017838ce7393
In msimprpl, move zap-related code to a separate module.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
diff
changeset
|
269 |