Mercurial > pidgin
comparison libpurple/protocols/mxit/formcmds.c @ 29994:be01173f597a
Fix the processing of the "Clear" MXit command.
The command is specified as "type=clear|clearmsgscreen=true", and not "type=clearmsgscreen"
author | andrew.victor@mxit.com |
---|---|
date | Wed, 19 May 2010 17:57:14 +0000 |
parents | 259bbfb423d4 |
children | 985b57c4f55c |
comparison
equal
deleted
inserted
replaced
29993:c9dbf4d38c32 | 29994:be01173f597a |
---|---|
40 * the MXit Command identifiers | 40 * the MXit Command identifiers |
41 */ | 41 */ |
42 typedef enum | 42 typedef enum |
43 { | 43 { |
44 MXIT_CMD_UNKNOWN = 0, /* Unknown command */ | 44 MXIT_CMD_UNKNOWN = 0, /* Unknown command */ |
45 MXIT_CMD_CLRSCR, /* Clear screen (clrmsgscreen) */ | 45 MXIT_CMD_CLEAR, /* Clear (clear) */ |
46 MXIT_CMD_SENDSMS, /* Send SMS (sendsms) */ | 46 MXIT_CMD_SENDSMS, /* Send SMS (sendsms) */ |
47 MXIT_CMD_REPLY, /* Reply (reply) */ | 47 MXIT_CMD_REPLY, /* Reply (reply) */ |
48 MXIT_CMD_PLATREQ, /* Platform Request (platreq) */ | 48 MXIT_CMD_PLATREQ, /* Platform Request (platreq) */ |
49 MXIT_CMD_SELECTCONTACT, /* Select Contact (selc) */ | 49 MXIT_CMD_SELECTCONTACT, /* Select Contact (selc) */ |
50 MXIT_CMD_IMAGE /* Inline image (img) */ | 50 MXIT_CMD_IMAGE /* Inline image (img) */ |
136 if (op) { | 136 if (op) { |
137 if ( strcmp(op, "cmd") == 0 ) { | 137 if ( strcmp(op, "cmd") == 0 ) { |
138 type = g_hash_table_lookup(hash, "type"); | 138 type = g_hash_table_lookup(hash, "type"); |
139 if (type == NULL) /* no command provided */ | 139 if (type == NULL) /* no command provided */ |
140 return MXIT_CMD_UNKNOWN; | 140 return MXIT_CMD_UNKNOWN; |
141 else if (strcmp(type, "clrmsgscreen") == 0) /* clear the screen */ | 141 else if (strcmp(type, "clear") == 0) /* clear */ |
142 return MXIT_CMD_CLRSCR; | 142 return MXIT_CMD_CLEAR; |
143 else if (strcmp(type, "sendsms") == 0) /* send an SMS */ | 143 else if (strcmp(type, "sendsms") == 0) /* send an SMS */ |
144 return MXIT_CMD_SENDSMS; | 144 return MXIT_CMD_SENDSMS; |
145 else if (strcmp(type, "reply") == 0) /* list of options */ | 145 else if (strcmp(type, "reply") == 0) /* list of options */ |
146 return MXIT_CMD_REPLY; | 146 return MXIT_CMD_REPLY; |
147 else if (strcmp(type, "platreq") == 0) /* platform request */ | 147 else if (strcmp(type, "platreq") == 0) /* platform request */ |
203 return hash; | 203 return hash; |
204 } | 204 } |
205 | 205 |
206 | 206 |
207 /*------------------------------------------------------------------------ | 207 /*------------------------------------------------------------------------ |
208 * Process a ClearScreen MXit command. | 208 * Process a Clear MXit command. |
209 * [::op=cmd|type=clear|clearmsgscreen=true|auto=true|id=12345:] | |
209 * | 210 * |
210 * @param session The MXit session object | 211 * @param session The MXit session object |
211 * @param from The sender of the message. | 212 * @param from The sender of the message. |
212 */ | 213 */ |
213 static void command_clearscreen(struct MXitSession* session, const char* from) | 214 static void command_clear(struct MXitSession* session, const char* from, GHashTable* hash) |
214 { | 215 { |
215 PurpleConversation *conv; | 216 PurpleConversation *conv; |
216 | 217 char* clearmsgscreen; |
217 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, session->acc); | 218 |
218 if (conv == NULL) { | 219 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, session->acc); |
219 purple_debug_error(MXIT_PLUGIN_ID, _( "Conversation with '%s' not found\n" ), from); | 220 if (conv == NULL) { |
220 return; | 221 purple_debug_error(MXIT_PLUGIN_ID, _( "Conversation with '%s' not found\n" ), from); |
221 } | 222 return; |
222 | 223 } |
223 purple_conversation_clear_message_history(conv); // TODO: This doesn't actually clear the screen. | 224 |
225 clearmsgscreen = g_hash_table_lookup(hash, "clearmsgscreen"); | |
226 if ( (clearmsgscreen) && (strcmp(clearmsgscreen, "true") == 0) ) { | |
227 /* this is a command to clear the chat screen */ | |
228 purple_debug_info(MXIT_PLUGIN_ID, "Clear the screen\n"); | |
229 | |
230 purple_conversation_clear_message_history(conv); // TODO: This doesn't actually clear the screen. | |
231 } | |
224 } | 232 } |
225 | 233 |
226 | 234 |
227 /*------------------------------------------------------------------------ | 235 /*------------------------------------------------------------------------ |
228 * Process a Reply MXit command. | 236 * Process a Reply MXit command. |
364 hash = command_tokenize(start); /* break into <key,value> pairs */ | 372 hash = command_tokenize(start); /* break into <key,value> pairs */ |
365 if (hash) { | 373 if (hash) { |
366 MXitCommandType type = command_type(hash); | 374 MXitCommandType type = command_type(hash); |
367 | 375 |
368 switch (type) { | 376 switch (type) { |
369 case MXIT_CMD_CLRSCR : | 377 case MXIT_CMD_CLEAR : |
370 command_clearscreen(mx->session, mx->from); | 378 command_clear(mx->session, mx->from, hash); |
371 break; | 379 break; |
372 case MXIT_CMD_REPLY : | 380 case MXIT_CMD_REPLY : |
373 command_reply(mx, hash); | 381 command_reply(mx, hash); |
374 break; | 382 break; |
375 case MXIT_CMD_PLATREQ : | 383 case MXIT_CMD_PLATREQ : |