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