annotate libpurple/protocols/mxit/formcmds.c @ 32778:14787acaf9d7

Patch from OpenBSD Ports to fix finch build on OpenBSD
author Ethan Blanton <elb@pidgin.im>
date Fri, 21 Oct 2011 14:36:06 +0000
parents b1a6535f99d9
children 9ad5fcde4af4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1 /*
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2 * MXit Protocol libPurple Plugin
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4 * -- MXit Forms & Commands --
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
6 * Andrew Victor <libpurple@mxit.com>
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
7 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
8 * (C) Copyright 2009 MXit Lifestyle (Pty) Ltd.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
9 * <http://www.mxitlifestyle.com>
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
10 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
14 * (at your option) any later version.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
15 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
19 * GNU General Public License for more details.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
20 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
24 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
25
29152
259bbfb423d4 Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents: 29041
diff changeset
26
259bbfb423d4 Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents: 29041
diff changeset
27 #include "internal.h"
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
28 #include <glib/gprintf.h>
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
29
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
30 #include "purple.h"
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
31
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
32 #include "protocol.h"
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
33 #include "mxit.h"
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
34 #include "markup.h"
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
35 #include "formcmds.h"
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
36
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
37 #undef MXIT_DEBUG_COMMANDS
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
38
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
39 /*
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
40 * the MXit Command identifiers
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
41 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
42 typedef enum
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
43 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
44 MXIT_CMD_UNKNOWN = 0, /* Unknown command */
30414
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
45 MXIT_CMD_CLEAR, /* Clear (clear) */
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
46 MXIT_CMD_SENDSMS, /* Send SMS (sendsms) */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
47 MXIT_CMD_REPLY, /* Reply (reply) */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
48 MXIT_CMD_PLATREQ, /* Platform Request (platreq) */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
49 MXIT_CMD_SELECTCONTACT, /* Select Contact (selc) */
31737
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
50 MXIT_CMD_IMAGE, /* Inline image (img) */
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
51 MXIT_CMD_SCREENCONFIG, /* Chat-screen config (csc) */
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
52 MXIT_CMD_SCREENINFO, /* Chat-screen info (csi) */
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
53 MXIT_CMD_IMAGESTRIP, /* Image Strip (is) */
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
54 MXIT_CMD_TABLE /* Table (tbl) */
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
55 } MXitCommandType;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
56
31965
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
57 /* Chat-screen behaviours (bhvr) */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
58 #define SCREEN_NO_HEADINGS 0x01
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
59 #define SCREEN_FULLSCREEN 0x02
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
60 #define SCREEN_AUTOCLEAR 0x04
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
61 #define SCREEN_NO_AUDIO 0x08
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
62 #define SCREEN_NO_MSGPREFIX 0x10
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
63 #define SCREEN_NOTIFY 0x20
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
64 #define SCREEN_PROGRESSBAR 0x40
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
65
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
66
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
67 /*
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
68 * object for an inline image request with an URL
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
69 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
70 struct ii_url_request
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
71 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
72 struct RXMsgData* mx;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
73 char* url;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
74 };
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
75
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
76
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
77 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
78 * Callback function invoked when an inline image request to a web site completes.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
79 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
80 * @param url_data
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
81 * @param user_data The Markup message object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
82 * @param url_text The data returned from the WAP site
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
83 * @param len The length of the data returned
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
84 * @param error_message Descriptive error message
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
85 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
86 static void mxit_cb_ii_returned(PurpleUtilFetchUrlData* url_data, gpointer user_data, const gchar* url_text, gsize len, const gchar* error_message)
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
87 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
88 struct ii_url_request* iireq = (struct ii_url_request*) user_data;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
89 char* ii_data;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
90 int* intptr = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
91 int id;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
92
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
93 #ifdef MXIT_DEBUG_COMMANDS
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
94 purple_debug_info(MXIT_PLUGIN_ID, "Inline Image returned from %s\n", iireq->url);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
95 #endif
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
96
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
97 if (!url_text) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
98 /* no reply from the WAP site */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
99 purple_debug_error(MXIT_PLUGIN_ID, "Error downloading Inline Image from %s.\n", iireq->url);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
100 goto done;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
101 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
102
31737
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
103 /* lets first see if we don't have the inline image already in cache */
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
104 if (g_hash_table_lookup(iireq->mx->session->iimages, iireq->url)) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
105 /* inline image found in the cache, so we just ignore this reply */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
106 goto done;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
107 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
108
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
109 /* make a copy of the data */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
110 ii_data = g_malloc(len);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
111 memcpy(ii_data, (const char*) url_text, len);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
112
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
113 /* we now have the inline image, store it in the imagestore */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
114 id = purple_imgstore_add_with_id(ii_data, len, NULL);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
115
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
116 /* map the inline image id to purple image id */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
117 intptr = g_malloc(sizeof(int));
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
118 *intptr = id;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
119 g_hash_table_insert(iireq->mx->session->iimages, iireq->url, intptr);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
120
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
121 iireq->mx->flags |= PURPLE_MESSAGE_IMAGES;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
122
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
123 done:
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
124 iireq->mx->img_count--;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
125 if ((iireq->mx->img_count == 0) && (iireq->mx->converted)) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
126 /*
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
127 * this was the last outstanding emoticon for this message,
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
128 * so we can now display it to the user.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
129 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
130 mxit_show_message(iireq->mx);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
131 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
132
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
133 g_free(iireq);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
134 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
135
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
136
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
137 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
138 * Return the command identifier of this MXit Command.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
139 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
140 * @param cmd The MXit command <key,value> map
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
141 * @return The MXit command identifier
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
142 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
143 static MXitCommandType command_type(GHashTable* hash)
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
144 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
145 char* op;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
146 char* type;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
147
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
148 op = g_hash_table_lookup(hash, "op");
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
149 if (op) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
150 if ( strcmp(op, "cmd") == 0 ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
151 type = g_hash_table_lookup(hash, "type");
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
152 if (type == NULL) /* no command provided */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
153 return MXIT_CMD_UNKNOWN;
30414
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
154 else if (strcmp(type, "clear") == 0) /* clear */
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
155 return MXIT_CMD_CLEAR;
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
156 else if (strcmp(type, "sendsms") == 0) /* send an SMS */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
157 return MXIT_CMD_SENDSMS;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
158 else if (strcmp(type, "reply") == 0) /* list of options */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
159 return MXIT_CMD_REPLY;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
160 else if (strcmp(type, "platreq") == 0) /* platform request */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
161 return MXIT_CMD_PLATREQ;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
162 else if (strcmp(type, "selc") == 0) /* select contact */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
163 return MXIT_CMD_SELECTCONTACT;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
164 }
31737
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
165 else if (strcmp(op, "img") == 0) /* inline image */
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
166 return MXIT_CMD_IMAGE;
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
167 else if (strcmp(op, "csc") == 0) /* chat-screen config */
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
168 return MXIT_CMD_SCREENCONFIG;
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
169 else if (strcmp(op, "csi") == 0) /* chat-screen info */
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
170 return MXIT_CMD_SCREENINFO;
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
171 else if (strcmp(op, "is") == 0) /* image-strip */
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
172 return MXIT_CMD_IMAGESTRIP;
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
173 else if (strcmp(op, "tbl") == 0) /* table */
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
174 return MXIT_CMD_TABLE;
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
175 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
176
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
177 return MXIT_CMD_UNKNOWN;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
178 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
179
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
180
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
181 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
182 * Tokenize a MXit Command string into a <key,value> map.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
183 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
184 * @param cmd The MXit command string
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
185 * @return The <key,value> hash-map, or NULL on error.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
186 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
187 static GHashTable* command_tokenize(char* cmd)
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
188 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
189 GHashTable* hash = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
190 gchar** parts;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
191 int i = 0;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
192
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
193 #ifdef MXIT_DEBUG_COMMANDS
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
194 purple_debug_info(MXIT_PLUGIN_ID, "command: '%s'\n", cmd);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
195 #endif
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
196
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
197 /* explode the command into parts */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
198 parts = g_strsplit(cmd, "|", 0);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
199
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
200 hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
201
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
202 /* now break part into a key & value */
32050
b1a6535f99d9 Get rid of a few other dead variables.
Paul Aurich <paul@darkrain42.org>
parents: 31965
diff changeset
203 while (parts[i] != NULL) {
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
204 char* value;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
205
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
206 value = strchr(parts[i], '='); /* find start of value */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
207 if (value != NULL) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
208 *value = '\0';
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
209 value++;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
210 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
211
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
212 #ifdef MXIT_DEBUG_COMMANDS
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
213 purple_debug_info(MXIT_PLUGIN_ID, " key='%s' value='%s'\n", parts[i], value);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
214 #endif
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
215
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
216 g_hash_table_insert(hash, g_strdup(parts[i]), g_strdup(value));
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
217
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
218 i++;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
219 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
220
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
221 g_strfreev(parts);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
222
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
223 return hash;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
224 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
225
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
226
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
227 /*------------------------------------------------------------------------
30414
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
228 * Process a Clear MXit command.
30415
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
229 * [::op=cmd|type=clear|clearmsgscreen=true|auto=true|id=12345:]
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
230 *
30415
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
231 * @param session The MXit session object
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
232 * @param from The sender of the message.
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
233 * @param hash The MXit command <key,value> map
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
234 */
30414
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
235 static void command_clear(struct MXitSession* session, const char* from, GHashTable* hash)
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
236 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
237 PurpleConversation *conv;
30414
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
238 char* clearmsgscreen;
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
239
30414
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
240 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, session->acc);
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
241 if (conv == NULL) {
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
242 purple_debug_error(MXIT_PLUGIN_ID, _( "Conversation with '%s' not found\n" ), from);
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
243 return;
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
244 }
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
245
30414
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
246 clearmsgscreen = g_hash_table_lookup(hash, "clearmsgscreen");
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
247 if ( (clearmsgscreen) && (strcmp(clearmsgscreen, "true") == 0) ) {
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
248 /* this is a command to clear the chat screen */
31962
eb927f960c14 Fix comment - it does not clear the screen.
andrew.victor@mxit.com
parents: 31737
diff changeset
249 purple_conversation_clear_message_history(conv);
30414
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
250 }
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
251 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
252
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
253
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
254 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
255 * Process a Reply MXit command.
30415
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
256 * [::op=cmd|type=reply|replymsg=back|selmsg=b) Back|id=12345:]
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
257 * [::op=cmd|nm=rep|type=reply|replymsg=back|selmsg=b) Back|id=12345:]
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
258 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
259 * @param mx The received message data object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
260 * @param hash The MXit command <key,value> map
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
261 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
262 static void command_reply(struct RXMsgData* mx, GHashTable* hash)
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
263 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
264 char* replymsg;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
265 char* selmsg;
30415
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
266 char* nm;
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
267
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
268 selmsg = g_hash_table_lookup(hash, "selmsg"); /* find the selection message */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
269 replymsg = g_hash_table_lookup(hash, "replymsg"); /* find the reply message */
30415
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
270 nm = g_hash_table_lookup(hash, "nm"); /* name parameter */
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
271 if ((selmsg) && (replymsg) && (nm)) {
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
272 gchar* seltext = g_markup_escape_text(purple_url_decode(selmsg), -1);
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
273 gchar* replycmd = g_strdup_printf("::type=reply|nm=%s|res=%s|err=0:", nm, replymsg);
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
274
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
275 mxit_add_html_link( mx, replycmd, seltext );
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
276
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
277 g_free(seltext);
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
278 g_free(replycmd);
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
279 }
985b57c4f55c Add support for the "nm=" syle of clickable links.
andrew.victor@mxit.com
parents: 30414
diff changeset
280 else if ((selmsg) && (replymsg)) {
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
281 gchar* seltext = g_markup_escape_text(purple_url_decode(selmsg), -1);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
282
29041
2b964c74de53 The data sent back to MXit when the user clicks on a link should be sent
andrew.victor@mxit.com
parents: 29038
diff changeset
283 mxit_add_html_link( mx, purple_url_decode(replymsg), seltext );
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
284
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
285 g_free(seltext);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
286 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
287 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
288
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
289
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
290 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
291 * Process a PlatformRequest MXit command.
31965
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
292 * [::op=cmd|type=platreq|selmsg=Upgrade MXit|dest=http%3a//m.mxit.com|id=12345:]
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
293 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
294 * @param hash The MXit command <key,value> map
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
295 * @param msg The message to display (as generated so far)
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
296 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
297 static void command_platformreq(GHashTable* hash, GString* msg)
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
298 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
299 gchar* text = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
300 char* selmsg;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
301 char* dest;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
302
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
303 selmsg = g_hash_table_lookup(hash, "selmsg"); /* find the selection message */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
304 if (selmsg) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
305 text = g_markup_escape_text(purple_url_decode(selmsg), -1);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
306 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
307
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
308 dest = g_hash_table_lookup(hash, "dest"); /* find the destination */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
309 if (dest) {
28994
5f80ab7ac183 Mark a bunch of mxit strings for translation
Mark Doliner <mark@kingant.net>
parents: 28903
diff changeset
310 g_string_append_printf(msg, "<a href=\"%s\">%s</a>", purple_url_decode(dest), (text) ? text : _( "Download" )); /* add link to display message */
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
311 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
312
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
313 if (text)
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
314 g_free(text);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
315 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
316
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
317
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
318 /*------------------------------------------------------------------------
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
319 * Process an inline image MXit command.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
320 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
321 * @param mx The received message data object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
322 * @param hash The MXit command <key,value> map
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
323 * @param msg The message to display (as generated so far)
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
324 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
325 static void command_image(struct RXMsgData* mx, GHashTable* hash, GString* msg)
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
326 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
327 const char* img;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
328 const char* reply;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
329 guchar* rawimg;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
330 char link[256];
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
331 gsize rawimglen;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
332 int imgid;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
333
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
334 img = g_hash_table_lookup(hash, "dat");
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
335 if (img) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
336 rawimg = purple_base64_decode(img, &rawimglen);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
337 //purple_util_write_data_to_file_absolute("/tmp/mxitinline.png", (char*) rawimg, rawimglen);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
338 imgid = purple_imgstore_add_with_id(rawimg, rawimglen, NULL);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
339 g_snprintf(link, sizeof(link), "<img id=\"%i\">", imgid);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
340 g_string_append_printf(msg, "%s", link);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
341 mx->flags |= PURPLE_MESSAGE_IMAGES;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
342 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
343 else {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
344 img = g_hash_table_lookup(hash, "src");
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
345 if (img) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
346 struct ii_url_request* iireq;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
347
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
348 iireq = g_new0(struct ii_url_request,1);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
349 iireq->url = g_strdup(purple_url_decode(img));
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
350 iireq->mx = mx;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
351
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
352 g_string_append_printf(msg, "%s%s>", MXIT_II_TAG, iireq->url);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
353 mx->got_img = TRUE;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
354
31737
34c9e0d4b4d3 Recognize (and ignore for now) the Gaming/Table Markup commands.
andrew.victor@mxit.com
parents: 30415
diff changeset
355 /* lets first see if we don't have the inline image already in cache */
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
356 if (g_hash_table_lookup(mx->session->iimages, iireq->url)) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
357 /* inline image found in the cache, so we do not have to request it from the web */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
358 g_free(iireq);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
359 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
360 else {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
361 /* send the request for the inline image */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
362 purple_debug_info(MXIT_PLUGIN_ID, "sending request for inline image '%s'\n", iireq->url);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
363
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
364 /* request the image (reference: "libpurple/util.h") */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
365 purple_util_fetch_url_request(iireq->url, TRUE, NULL, TRUE, NULL, FALSE, mxit_cb_ii_returned, iireq);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
366 mx->img_count++;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
367 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
368 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
369 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
370
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
371 /* if this is a clickable image, show a click link */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
372 reply = g_hash_table_lookup(hash, "replymsg");
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
373 if (reply) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
374 g_string_append_printf(msg, "\n");
28994
5f80ab7ac183 Mark a bunch of mxit strings for translation
Mark Doliner <mark@kingant.net>
parents: 28903
diff changeset
375 mxit_add_html_link(mx, reply, _( "click here" ));
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
376 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
377 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
378
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
379
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
380 /*------------------------------------------------------------------------
31965
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
381 * Process an Imagestrip MXit command.
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
382 * [::op=is|nm=status|dat=iVBORw0KGgoAAAA%3d%3d|v=63398792426788|fw=8|fh=8|layer=0:]
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
383 *
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
384 * @param from The sender of the message.
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
385 * @param hash The MXit command <key,value> map
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
386 */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
387 static void command_imagestrip(struct MXitSession* session, const char* from, GHashTable* hash)
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
388 {
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
389 const char* name;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
390 const char* validator;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
391 const char* tmp;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
392 int width, height, layer;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
393
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
394 purple_debug_info(MXIT_PLUGIN_ID, "ImageStrip received from %s\n", from);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
395
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
396 /* image strip name */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
397 name = g_hash_table_lookup(hash, "nm");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
398
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
399 /* validator */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
400 validator = g_hash_table_lookup(hash, "v");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
401
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
402 /* image data */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
403 tmp = g_hash_table_lookup(hash, "dat");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
404 if (tmp) {
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
405 guchar* rawimg;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
406 gsize rawimglen;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
407 char* dir;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
408 char* filename;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
409
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
410 /* base64 decode the image data */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
411 rawimg = purple_base64_decode(tmp, &rawimglen);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
412
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
413 /* save it to a file */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
414 dir = g_strdup_printf("%s/mxit/imagestrips", purple_user_dir());
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
415 purple_build_dir(dir, S_IRUSR | S_IWUSR | S_IXUSR); /* ensure directory exists */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
416
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
417 filename = g_strdup_printf("%s/%s-%s-%s.png", dir, from, name, validator);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
418 purple_util_write_data_to_file_absolute(filename, (char*) rawimg, rawimglen);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
419
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
420 g_free(dir);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
421 g_free(filename);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
422 }
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
423
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
424 tmp = g_hash_table_lookup(hash, "fw");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
425 width = atoi(tmp);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
426
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
427 tmp = g_hash_table_lookup(hash, "fh");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
428 height = atoi(tmp);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
429
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
430 tmp = g_hash_table_lookup(hash, "layer");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
431 layer = atoi(tmp);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
432
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
433 purple_debug_info(MXIT_PLUGIN_ID, "ImageStrip %s from %s: [w=%i h=%i l=%i validator=%s]\n", name, from, width, height, layer, validator);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
434 }
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
435
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
436
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
437 /*------------------------------------------------------------------------
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
438 * Process a Chat-Screen-Info MXit command.
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
439 * [::op=csi:]
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
440 *
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
441 * @param session The MXit session object
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
442 * @param from The sender of the message.
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
443 */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
444 static void command_screeninfo(struct MXitSession* session, const char* from)
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
445 {
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
446 char* response;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
447
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
448 purple_debug_info(MXIT_PLUGIN_ID, "Chat Screen Info received from %s\n", from);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
449
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
450 // TODO: Determine width, height, colors of chat-screen.
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
451
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
452 response = g_strdup_printf("::type=csi|res=bhvr,0;w,%i;h,%i;col,0.ffffffff,29.ff000000:", 300, 400);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
453
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
454 /* send response back to MXit */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
455 mxit_send_message( session, from, response, FALSE, TRUE );
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
456
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
457 g_free(response);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
458 }
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
459
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
460
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
461 /*------------------------------------------------------------------------
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
462 * Process a Chat-Screen-Configure MXit command.
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
463 * [::op=csc|bhvr=|menu=<menu>|col=<colors>:]
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
464 * where:
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
465 * menu ::= <menuitem> { ";" <menuitem> }
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
466 * menuitem ::= { type "," <text> "," <name> "," <meta> }
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
467 * colors ::= <color> { ";" <color> }
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
468 * color ::= <colorid> "," <ARGB hex color>
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
469 *
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
470 * @param session The MXit session object
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
471 * @param from The sender of the message.
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
472 * @param hash The MXit command <key,value> map
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
473 */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
474 static void command_screenconfig(struct MXitSession* session, const char* from, GHashTable* hash)
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
475 {
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
476 const char* tmp;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
477
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
478 purple_debug_info(MXIT_PLUGIN_ID, "Chat Screen Configure received from %s\n", from);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
479
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
480 /* Behaviour */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
481 tmp = g_hash_table_lookup(hash, "bhvr");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
482 if (tmp) {
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
483 purple_debug_info(MXIT_PLUGIN_ID, " behaviour = %s\n", tmp);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
484 // TODO: Re-configure conversation screen.
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
485 }
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
486
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
487 /* Menu */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
488 tmp = g_hash_table_lookup(hash, "menu");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
489 if (tmp) {
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
490 purple_debug_info(MXIT_PLUGIN_ID, " menu = %s\n", tmp);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
491 // TODO: Implement conversation-specific sub-menu.
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
492 }
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
493
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
494 /* Colours */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
495 tmp = g_hash_table_lookup(hash, "col");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
496 if (tmp) {
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
497 purple_debug_info(MXIT_PLUGIN_ID, " colours = %s\n", tmp);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
498 // TODO: Re-configuration conversation colors.
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
499 }
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
500 }
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
501
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
502
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
503 /*------------------------------------------------------------------------
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
504 * Process a Table Markup MXit command.
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
505 *
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
506 * @param mx The received message data object
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
507 * @param hash The MXit command <key,value> map
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
508 */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
509 static void command_table(struct RXMsgData* mx, GHashTable* hash)
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
510 {
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
511 const char* tmp;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
512 const char* name;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
513 int mode;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
514 int nr_columns = 0, nr_rows = 0;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
515 gchar** coldata;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
516 int i, j;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
517
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
518 /* table name */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
519 name = g_hash_table_lookup(hash, "nm");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
520
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
521 /* number of columns */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
522 tmp = g_hash_table_lookup(hash, "col");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
523 nr_columns = atoi(tmp);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
524
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
525 /* number of rows */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
526 tmp = g_hash_table_lookup(hash, "row");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
527 nr_rows = atoi(tmp);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
528
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
529 /* mode */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
530 tmp = g_hash_table_lookup(hash, "mode");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
531 mode = atoi(tmp);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
532
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
533 /* table data */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
534 tmp = g_hash_table_lookup(hash, "d");
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
535 coldata = g_strsplit(tmp, "~", 0); /* split into entries for each row & column */
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
536
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
537 purple_debug_info(MXIT_PLUGIN_ID, "Table %s from %s: [cols=%i rows=%i mode=%i]\n", name, mx->from, nr_columns, nr_rows, mode);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
538
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
539 for (i = 0; i < nr_rows; i++) {
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
540 for (j = 0; j < nr_columns; j++) {
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
541 purple_debug_info(MXIT_PLUGIN_ID, " Row %i Column %i = %s\n", i, j, coldata[i*nr_columns + j]);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
542 }
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
543 }
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
544 }
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
545
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
546
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
547 /*------------------------------------------------------------------------
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
548 * Process a received MXit Command message.
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
549 *
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
550 * @param mx The received message data object
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
551 * @param message The message text
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
552 * @return The length of the command
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
553 */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
554 int mxit_parse_command(struct RXMsgData* mx, char* message)
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
555 {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
556 GHashTable* hash = NULL;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
557 char* start;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
558 char* end;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
559
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
560 /* ensure that this is really a command */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
561 if ( ( message[0] != ':' ) || ( message[1] != ':' ) ) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
562 /* this is not a command */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
563 return 0;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
564 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
565
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
566 start = message + 2;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
567 end = strstr(start, ":");
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
568 if (end) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
569 /* end of a command found */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
570 *end = '\0'; /* terminate command string */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
571
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
572 hash = command_tokenize(start); /* break into <key,value> pairs */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
573 if (hash) {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
574 MXitCommandType type = command_type(hash);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
575
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
576 switch (type) {
30414
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
577 case MXIT_CMD_CLEAR :
be01173f597a Fix the processing of the "Clear" MXit command.
andrew.victor@mxit.com
parents: 29152
diff changeset
578 command_clear(mx->session, mx->from, hash);
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
579 break;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
580 case MXIT_CMD_REPLY :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
581 command_reply(mx, hash);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
582 break;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
583 case MXIT_CMD_PLATREQ :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
584 command_platformreq(hash, mx->msg);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
585 break;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
586 case MXIT_CMD_IMAGE :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
587 command_image(mx, hash, mx->msg);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
588 break;
31965
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
589 case MXIT_CMD_SCREENCONFIG :
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
590 command_screenconfig(mx->session, mx->from, hash);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
591 break;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
592 case MXIT_CMD_SCREENINFO :
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
593 command_screeninfo(mx->session, mx->from);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
594 break;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
595 case MXIT_CMD_IMAGESTRIP :
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
596 command_imagestrip(mx->session, mx->from, hash);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
597 break;
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
598 case MXIT_CMD_TABLE :
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
599 command_table(mx, hash);
000aac6e42fe Start on Gaming & Table markup.
andrew.victor@mxit.com
parents: 31962
diff changeset
600 break;
28903
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
601 default :
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
602 /* command unknown, or not currently supported */
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
603 break;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
604 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
605 g_hash_table_destroy(hash);
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
606 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
607 *end = ':';
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
608
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
609 return end - message;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
610 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
611 else {
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
612 return 0;
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
613 }
69aa4660401a Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
614 }