libpurple/protocols/mxit/formcmds.c

Thu, 02 Jun 2016 14:53:51 -0500

author
Andrew Victor <andrew.victor@mxit.com>
date
Thu, 02 Jun 2016 14:53:51 -0500
branch
release-2.x.y
changeset 37806
1c4acc6977a8
parent 34506
f161fc3074d1
child 37844
406382495c37
permissions
-rw-r--r--

Fix TALOS-CAN-0133

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

mercurial