comparison libpurple/protocols/myspace/zap.c @ 22097:eab7d03edfcb

This adds accessor and mutator API for the PurpleAttentionType struct. I also took the liberty of updating all the prpls that use PurpleAttentionType to use this new API.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Sun, 13 Jan 2008 22:44:01 +0000
parents c99f6ea2634d
children 797377cbd5bf
comparison
equal deleted inserted replaced
22095:4c28d1e4e284 22097:eab7d03edfcb
27 /** Get zap types. */ 27 /** Get zap types. */
28 GList * 28 GList *
29 msim_attention_types(PurpleAccount *acct) 29 msim_attention_types(PurpleAccount *acct)
30 { 30 {
31 static GList *types = NULL; 31 static GList *types = NULL;
32 MsimAttentionType* attn; 32 PurpleAttentionType* attn;
33 33
34 if (!types) { 34 if (!types) {
35 #define _MSIM_ADD_NEW_ATTENTION(icn, nme, incoming, outgoing) \ 35 #define _MSIM_ADD_NEW_ATTENTION(icn, ulname, nme, incoming, outgoing) \
36 attn = g_new0(MsimAttentionType, 1); \ 36 attn = purple_attention_type_new(ulname, nme, incoming, outgoing); \
37 attn->icon_name = icn; \ 37 purple_attention_type_set_icon_name(attn, icn); \
38 attn->name = nme; \
39 attn->incoming_description = incoming; \
40 attn->outgoing_description = outgoing; \
41 types = g_list_append(types, attn); 38 types = g_list_append(types, attn);
42 39
43 /* TODO: icons for each zap */ 40 /* TODO: icons for each zap */
44 41
45 /* Lots of comments for translators: */ 42 /* Lots of comments for translators: */
46 43
47 /* Zap means "to strike suddenly and forcefully as if with a 44 /* Zap means "to strike suddenly and forcefully as if with a
48 * projectile or weapon." This term often has an electrical 45 * projectile or weapon." This term often has an electrical
49 * connotation, for example, "he was zapped by electricity when 46 * connotation, for example, "he was zapped by electricity when
50 * he put a fork in the toaster." */ 47 * he put a fork in the toaster." */
51 _MSIM_ADD_NEW_ATTENTION(NULL, _("Zap"), _("%s has zapped you!"), _("Zapping %s...")); 48 _MSIM_ADD_NEW_ATTENTION(NULL, "Zap", _("Zap"), _("%s has zapped you!"),
49 _("Zapping %s..."));
52 50
53 /* Whack means "to hit or strike someone with a sharp blow" */ 51 /* Whack means "to hit or strike someone with a sharp blow" */
54 _MSIM_ADD_NEW_ATTENTION(NULL, _("Whack"), _("%s has whacked you!"), _("Whacking %s...")); 52 _MSIM_ADD_NEW_ATTENTION(NULL, "Whack", _("Whack"),
53 _("%s has whacked you!"), _("Whacking %s..."));
55 54
56 /* Torch means "to set on fire." Don't worry, this doesn't 55 /* Torch means "to set on fire." Don't worry, this doesn't
57 * make a whole lot of sense in English, either. Feel free 56 * make a whole lot of sense in English, either. Feel free
58 * to translate it literally. */ 57 * to translate it literally. */
59 _MSIM_ADD_NEW_ATTENTION(NULL, _("Torch"), _("%s has torched you!"), _("Torching %s...")); 58 _MSIM_ADD_NEW_ATTENTION(NULL, "Torch", _("Torch"),
59 _("%s has torched you!"), _("Torching %s..."));
60 60
61 /* Smooch means "to kiss someone, often enthusiastically" */ 61 /* Smooch means "to kiss someone, often enthusiastically" */
62 _MSIM_ADD_NEW_ATTENTION(NULL, _("Smooch"), _("%s has smooched you!"), _("Smooching %s...")); 62 _MSIM_ADD_NEW_ATTENTION(NULL, "Smooch", _("Smooch"),
63 _("%s has smooched you!"), _("Smooching %s..."));
63 64
64 /* A hug is a display of affection; wrapping your arms around someone */ 65 /* A hug is a display of affection; wrapping your arms around someone */
65 _MSIM_ADD_NEW_ATTENTION(NULL, _("Hug"), _("%s has hugged you!"), _("Hugging %s...")); 66 _MSIM_ADD_NEW_ATTENTION(NULL, "Hug", _("Hug"), _("%s has hugged you!"),
67 _("Hugging %s..."));
66 68
67 /* Slap means "to hit someone with an open/flat hand" */ 69 /* Slap means "to hit someone with an open/flat hand" */
68 _MSIM_ADD_NEW_ATTENTION(NULL, _("Slap"), _("%s has slapped you!"), _("Slapping %s...")); 70 _MSIM_ADD_NEW_ATTENTION(NULL, "Slap", _("Slap"),
71 _("%s has slapped you!"), _("Slapping %s..."));
69 72
70 /* Goose means "to pinch someone on their butt" */ 73 /* Goose means "to pinch someone on their butt" */
71 _MSIM_ADD_NEW_ATTENTION(NULL, _("Goose"), _("%s has goosed you!"), _("Goosing %s...")); 74 _MSIM_ADD_NEW_ATTENTION(NULL, "Goose", _("Goose"),
75 _("%s has goosed you!"), _("Goosing %s..."));
72 76
73 /* A high-five is when two people's hands slap each other 77 /* A high-five is when two people's hands slap each other
74 * in the air above their heads. It is done to celebrate 78 * in the air above their heads. It is done to celebrate
75 * something, often a victory, or to congratulate someone. */ 79 * something, often a victory, or to congratulate someone. */
76 _MSIM_ADD_NEW_ATTENTION(NULL, _("High-five"), _("%s has high-fived you!"), _("High-fiving %s...")); 80 _MSIM_ADD_NEW_ATTENTION(NULL, "High-five", _("High-five"),
81 _("%s has high-fived you!"), _("High-fiving %s..."));
77 82
78 /* We're not entirely sure what the MySpace people mean by 83 /* We're not entirely sure what the MySpace people mean by
79 * this... but we think it's the equivalent of "prank." Or, for 84 * this... but we think it's the equivalent of "prank." Or, for
80 * someone to perform a mischievous trick or practical joke. */ 85 * someone to perform a mischievous trick or practical joke. */
81 _MSIM_ADD_NEW_ATTENTION(NULL, _("Punk"), _("%s has punk'd you!"), _("Punking %s...")); 86 _MSIM_ADD_NEW_ATTENTION(NULL, "Punk", _("Punk"),
87 _("%s has punk'd you!"), _("Punking %s..."));
82 88
83 /* Raspberry is a slang term for the vibrating sound made 89 /* Raspberry is a slang term for the vibrating sound made
84 * when you stick your tongue out of your mouth with your 90 * when you stick your tongue out of your mouth with your
85 * lips closed and blow. It is typically done when 91 * lips closed and blow. It is typically done when
86 * gloating or bragging. Nowadays it's a pretty silly 92 * gloating or bragging. Nowadays it's a pretty silly
87 * gesture, so it does not carry a harsh negative 93 * gesture, so it does not carry a harsh negative
88 * connotation. It is generally used in a playful tone 94 * connotation. It is generally used in a playful tone
89 * with friends. */ 95 * with friends. */
90 _MSIM_ADD_NEW_ATTENTION(NULL, _("Raspberry"), _("%s has raspberried you!"), _("Raspberrying %s...")); 96 _MSIM_ADD_NEW_ATTENTION(NULL, "Raspberry", _("Raspberry"),
97 _("%s has raspberried you!"), _("Raspberrying %s..."));
91 } 98 }
92 99
93 return types; 100 return types;
94 } 101 }
95 102
97 gboolean 104 gboolean
98 msim_send_attention(PurpleConnection *gc, const gchar *username, guint code) 105 msim_send_attention(PurpleConnection *gc, const gchar *username, guint code)
99 { 106 {
100 GList *types; 107 GList *types;
101 MsimSession *session; 108 MsimSession *session;
102 MsimAttentionType *attn; 109 PurpleAttentionType *attn;
103 PurpleBuddy *buddy; 110 PurpleBuddy *buddy;
104 111
105 session = (MsimSession *)gc->proto_data; 112 session = (MsimSession *)gc->proto_data;
106 113
107 /* Look for this attention type, by the code index given. */ 114 /* Look for this attention type, by the code index given. */
108 types = msim_attention_types(gc->account); 115 types = msim_attention_types(gc->account);
109 attn = (MsimAttentionType *)g_list_nth_data(types, code); 116 attn = (PurpleAttentionType *)g_list_nth_data(types, code);
110 117
111 if (!attn) { 118 if (!attn) {
112 purple_debug_info("msim_send_attention", "got invalid zap code %d\n", code); 119 purple_debug_info("msim_send_attention", "got invalid zap code %d\n", code);
113 return FALSE; 120 return FALSE;
114 } 121 }
198 /* TODO: get rid of once is accessible directly in GUI */ 205 /* TODO: get rid of once is accessible directly in GUI */
199 types = msim_attention_types(NULL); 206 types = msim_attention_types(NULL);
200 i = 0; 207 i = 0;
201 do 208 do
202 { 209 {
203 MsimAttentionType *attn; 210 PurpleAttentionType *attn;
204 211
205 attn = (MsimAttentionType *)types->data; 212 attn = (PurpleAttentionType *)types->data;
206 213
207 act = purple_menu_action_new(attn->name, PURPLE_CALLBACK(msim_send_zap_from_menu), 214 act = purple_menu_action_new(purple_attention_type_get_name(attn),
208 GUINT_TO_POINTER(i), NULL); 215 PURPLE_CALLBACK(msim_send_zap_from_menu), GUINT_TO_POINTER(i), NULL);
209 zap_menu = g_list_append(zap_menu, act); 216 zap_menu = g_list_append(zap_menu, act);
210 217
211 ++i; 218 ++i;
212 } while ((types = g_list_next(types))); 219 } while ((types = g_list_next(types)));
213 220