annotate libpurple/protocols/mxit/formcmds.c @ 32393:5dafa68c8eb0

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