Mercurial > pidgin
annotate libpurple/protocols/myspace/zap.c @ 20125:3e8531514ad7
Add disconnection reasons to qq.
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Tue, 02 Oct 2007 00:14:12 +0000 |
parents | 472e263e88a8 |
children | 51457cf3d27b 1141d47b162c |
rev | line source |
---|---|
19432
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
1 /* MySpaceIM Protocol Plugin - zap support |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
2 * |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
3 * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im> |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
4 * |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
7 * the Free Software Foundation; either version 2 of the License, or |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
8 * (at your option) any later version. |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
9 * |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
13 * GNU General Public License for more details. |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
14 * |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
16 * along with this program; if not, write to the Free Software |
19681
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19654
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
19432
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
18 */ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
19 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
20 #include "myspace.h" |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
21 #include "zap.h" |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
22 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
23 static gboolean msim_send_zap(MsimSession *session, const gchar *username, guint code); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
24 static void msim_send_zap_from_menu(PurpleBlistNode *node, gpointer zap_num_ptr); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
25 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
26 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
27 /** Get zap types. */ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
28 GList * |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
29 msim_attention_types(PurpleAccount *acct) |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
30 { |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
31 static GList *types = NULL; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
32 MsimAttentionType* attn; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
33 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
34 if (!types) { |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
35 #define _MSIM_ADD_NEW_ATTENTION(icn, nme, incoming, outgoing) \ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
36 attn = g_new0(MsimAttentionType, 1); \ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
37 attn->icon_name = icn; \ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
38 attn->name = nme; \ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
39 attn->incoming_description = incoming; \ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
40 attn->outgoing_description = outgoing; \ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
41 types = g_list_append(types, attn); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
42 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
43 /* TODO: icons for each zap */ |
19704
d3d9e3978d82
Clear up translation ambiguity with the attention API.
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
44 _MSIM_ADD_NEW_ATTENTION(NULL, _("Zap"), _("%s has zapped you!"), _("Zapping %s...")); |
d3d9e3978d82
Clear up translation ambiguity with the attention API.
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
45 _MSIM_ADD_NEW_ATTENTION(NULL, _("Whack"), _("%s has whacked you!"), _("Whacking %s...")); |
d3d9e3978d82
Clear up translation ambiguity with the attention API.
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
46 _MSIM_ADD_NEW_ATTENTION(NULL, _("Torch"), _("%s has torched you!"), _("Torching %s...")); |
d3d9e3978d82
Clear up translation ambiguity with the attention API.
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
47 _MSIM_ADD_NEW_ATTENTION(NULL, _("Smooch"), _("%s has smooched you!"), _("Smooching %s...")); |
d3d9e3978d82
Clear up translation ambiguity with the attention API.
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
48 _MSIM_ADD_NEW_ATTENTION(NULL, _("Hug"), _("%s has hugged you!"), _("Hugging %s...")); |
d3d9e3978d82
Clear up translation ambiguity with the attention API.
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
49 _MSIM_ADD_NEW_ATTENTION(NULL, _("Slap"), _("%s has slapped you!"), _("Slapping %s...")); |
d3d9e3978d82
Clear up translation ambiguity with the attention API.
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
50 _MSIM_ADD_NEW_ATTENTION(NULL, _("Goose"), _("%s has goosed you!"), _("Goosing %s...")); |
d3d9e3978d82
Clear up translation ambiguity with the attention API.
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
51 _MSIM_ADD_NEW_ATTENTION(NULL, _("High-five"), _("%s has high-fived you!"), _("High-fiving %s...")); |
d3d9e3978d82
Clear up translation ambiguity with the attention API.
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
52 _MSIM_ADD_NEW_ATTENTION(NULL, _("Punk"), _("%s has punk'd you!"), _("Punking %s...")); |
d3d9e3978d82
Clear up translation ambiguity with the attention API.
Richard Laager <rlaager@wiktel.com>
parents:
19681
diff
changeset
|
53 _MSIM_ADD_NEW_ATTENTION(NULL, _("Raspberry"), _("%s has raspberried you!"), _("Raspberrying %s...")); |
19432
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
54 } |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
55 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
56 return types; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
57 } |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
58 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
59 /** Send a zap */ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
60 gboolean |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
61 msim_send_attention(PurpleConnection *gc, const gchar *username, guint code) |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
62 { |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
63 GList *types; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
64 MsimSession *session; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
65 MsimAttentionType *attn; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
66 PurpleBuddy *buddy; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
67 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
68 session = (MsimSession *)gc->proto_data; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
69 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
70 /* Look for this attention type, by the code index given. */ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
71 types = msim_attention_types(gc->account); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
72 attn = (MsimAttentionType *)g_list_nth_data(types, code); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
73 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
74 if (!attn) { |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
75 purple_debug_info("msim_send_attention", "got invalid zap code %d\n", code); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
76 return FALSE; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
77 } |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
78 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
79 buddy = purple_find_buddy(session->account, username); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
80 if (!buddy) { |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
81 return FALSE; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
82 } |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
83 |
19463
3f6f84d11ce2
Change serv_send_attention() to call prpl_info->send_attention(), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19461
diff
changeset
|
84 msim_send_zap(session, username, code); |
19432
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
85 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
86 return TRUE; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
87 } |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
88 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
89 /** Send a zap to a user. */ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
90 static gboolean |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
91 msim_send_zap(MsimSession *session, const gchar *username, guint code) |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
92 { |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
93 gchar *zap_string; |
19461
1b5e786d137a
In the attention API, use the PURPLE_NOTIFY_MESSAGE flag to serv_got_im()
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19432
diff
changeset
|
94 gboolean rc; |
19432
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
95 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
96 g_return_val_if_fail(session != NULL, FALSE); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
97 g_return_val_if_fail(username != NULL, FALSE); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
98 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
99 /* Construct and send the actual zap command. */ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
100 zap_string = g_strdup_printf("!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", code); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
101 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
102 if (!msim_send_bm(session, username, zap_string, MSIM_BM_ACTION)) { |
19654
941965d6fd88
Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19463
diff
changeset
|
103 purple_debug_info("msim_send_zap_from_menu", "msim_send_bm failed: zapping %s with %s\n", |
19432
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
104 username, zap_string); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
105 rc = FALSE; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
106 } else { |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
107 rc = TRUE; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
108 } |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
109 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
110 g_free(zap_string); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
111 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
112 return rc; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
113 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
114 } |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
115 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
116 /** Zap someone. Callback from msim_blist_node_menu zap menu. */ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
117 static void |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
118 msim_send_zap_from_menu(PurpleBlistNode *node, gpointer zap_num_ptr) |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
119 { |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
120 PurpleBuddy *buddy; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
121 PurpleAccount *account; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
122 PurpleConnection *gc; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
123 MsimSession *session; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
124 guint zap; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
125 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
126 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
127 /* Only know about buddies for now. */ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
128 return; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
129 } |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
130 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
131 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
132 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
133 buddy = (PurpleBuddy *)node; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
134 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
135 /* Find the session */ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
136 account = buddy->account; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
137 gc = purple_account_get_connection(account); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
138 session = (MsimSession *)gc->proto_data; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
139 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
140 zap = GPOINTER_TO_INT(zap_num_ptr); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
141 |
19463
3f6f84d11ce2
Change serv_send_attention() to call prpl_info->send_attention(), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19461
diff
changeset
|
142 serv_send_attention(session->gc, buddy->name, zap); |
19432
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
143 } |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
144 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
145 /** Return menu, if any, for a buddy list node. */ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
146 GList * |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
147 msim_blist_node_menu(PurpleBlistNode *node) |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
148 { |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
149 GList *menu, *zap_menu; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
150 GList *types; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
151 PurpleMenuAction *act; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
152 guint i; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
153 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
154 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
155 /* Only know about buddies for now. */ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
156 return NULL; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
157 } |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
158 |
19716
472e263e88a8
Eliminate an excess array and loop.
Richard Laager <rlaager@wiktel.com>
parents:
19715
diff
changeset
|
159 zap_menu = NULL; |
472e263e88a8
Eliminate an excess array and loop.
Richard Laager <rlaager@wiktel.com>
parents:
19715
diff
changeset
|
160 |
472e263e88a8
Eliminate an excess array and loop.
Richard Laager <rlaager@wiktel.com>
parents:
19715
diff
changeset
|
161 /* TODO: get rid of once is accessible directly in GUI */ |
19432
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
162 types = msim_attention_types(NULL); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
163 i = 0; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
164 do |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
165 { |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
166 MsimAttentionType *attn; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
167 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
168 attn = (MsimAttentionType *)types->data; |
19716
472e263e88a8
Eliminate an excess array and loop.
Richard Laager <rlaager@wiktel.com>
parents:
19715
diff
changeset
|
169 |
472e263e88a8
Eliminate an excess array and loop.
Richard Laager <rlaager@wiktel.com>
parents:
19715
diff
changeset
|
170 act = purple_menu_action_new(attn->name, PURPLE_CALLBACK(msim_send_zap_from_menu), |
472e263e88a8
Eliminate an excess array and loop.
Richard Laager <rlaager@wiktel.com>
parents:
19715
diff
changeset
|
171 GUINT_TO_POINTER(i), NULL); |
472e263e88a8
Eliminate an excess array and loop.
Richard Laager <rlaager@wiktel.com>
parents:
19715
diff
changeset
|
172 zap_menu = g_list_append(zap_menu, act); |
472e263e88a8
Eliminate an excess array and loop.
Richard Laager <rlaager@wiktel.com>
parents:
19715
diff
changeset
|
173 |
19432
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
174 ++i; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
175 } while ((types = g_list_next(types))); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
176 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
177 act = purple_menu_action_new(_("Zap"), NULL, NULL, zap_menu); |
19716
472e263e88a8
Eliminate an excess array and loop.
Richard Laager <rlaager@wiktel.com>
parents:
19715
diff
changeset
|
178 menu = g_list_append(NULL, act); |
19432
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
179 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
180 return menu; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
181 } |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
182 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
183 /** Process an incoming zap. */ |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
184 gboolean |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
185 msim_incoming_zap(MsimSession *session, MsimMessage *msg) |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
186 { |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
187 gchar *msg_text, *username; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
188 gint zap; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
189 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
190 msg_text = msim_msg_get_string(msg, "msg"); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
191 username = msim_msg_get_string(msg, "_username"); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
192 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
193 g_return_val_if_fail(msg_text != NULL, FALSE); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
194 g_return_val_if_fail(username != NULL, FALSE); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
195 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
196 g_return_val_if_fail(sscanf(msg_text, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", &zap) == 1, FALSE); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
197 |
19461
1b5e786d137a
In the attention API, use the PURPLE_NOTIFY_MESSAGE flag to serv_got_im()
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19432
diff
changeset
|
198 zap = CLAMP(zap, 0, 9); |
19432
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
199 |
19461
1b5e786d137a
In the attention API, use the PURPLE_NOTIFY_MESSAGE flag to serv_got_im()
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
19432
diff
changeset
|
200 serv_got_attention(session->gc, username, zap); |
19432
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
201 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
202 g_free(msg_text); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
203 g_free(username); |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
204 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
205 return TRUE; |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
206 } |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
207 |
210f792efd7c
In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
diff
changeset
|
208 |