Fri, 19 Aug 2016 23:03:37 -0500
Monster merge everything
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
1 | /* |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
2 | * MXit Protocol libPurple Plugin |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
3 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
4 | * -- MXit Forms & Commands -- |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
5 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
6 | * Andrew Victor <libpurple@mxit.com> |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
7 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
8 | * (C) Copyright 2009 MXit Lifestyle (Pty) Ltd. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
9 | * <http://www.mxitlifestyle.com> |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
10 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
11 | * This program is free software; you can redistribute it and/or modify |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
12 | * it under the terms of the GNU General Public License as published by |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
13 | * the Free Software Foundation; either version 2 of the License, or |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
14 | * (at your option) any later version. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
15 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
16 | * This program is distributed in the hope that it will be useful, |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
19 | * GNU General Public License for more details. |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
20 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
21 | * You should have received a copy of the GNU General Public License |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
22 | * along with this program; if not, write to the Free Software |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
24 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
25 | |
|
29106
51c7b2177e42
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <darkrain42@pidgin.im>
parents:
28993
diff
changeset
|
26 | |
|
51c7b2177e42
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <darkrain42@pidgin.im>
parents:
28993
diff
changeset
|
27 | #include "internal.h" |
|
33844
e8edfd4e26ae
MXit: Cleanup the #includes (no purple.h) so that it atleast compiles within InstantBird.
Andrew Victor <andrew.victor@mxit.com>
parents:
33831
diff
changeset
|
28 | #include "debug.h" |
|
34253
e5f98ea3b169
HTTP: get rid of mxit's own http implementation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34233
diff
changeset
|
29 | #include "http.h" |
|
35828
261f7d7810dd
imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35079
diff
changeset
|
30 | #include "image-store.h" |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
31 | |
|
36542
30f40ecc4631
Renamed mxit's protocol.[ch] to client.[ch]
Ankit Vani <a@nevitus.org>
parents:
34878
diff
changeset
|
32 | #include "client.h" |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
33 | #include "mxit.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
34 | #include "markup.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
35 | #include "formcmds.h" |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
36 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
37 | #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
|
38 | |
|
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 | * 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
|
41 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
42 | typedef enum |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
43 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
44 | MXIT_CMD_UNKNOWN = 0, /* Unknown command */ |
|
30206
78a84b7ac7fe
Fix the processing of the "Clear" MXit command.
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
45 | 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
|
46 | 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
|
47 | 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
|
48 | 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
|
49 | 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
|
50 | 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
|
51 | 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
|
52 | 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
|
53 | 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
|
54 | 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
|
55 | } MXitCommandType; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
56 | |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
57 | /* Chat-screen behaviours (bhvr) */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
58 | #define SCREEN_NO_HEADINGS 0x01 |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
59 | #define SCREEN_FULLSCREEN 0x02 |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
60 | #define SCREEN_AUTOCLEAR 0x04 |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
61 | #define SCREEN_NO_AUDIO 0x08 |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
62 | #define SCREEN_NO_MSGPREFIX 0x10 |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
63 | #define SCREEN_NOTIFY 0x20 |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
64 | #define SCREEN_PROGRESSBAR 0x40 |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
65 | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
66 | |
|
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 | * 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
|
69 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
70 | struct ii_url_request |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
71 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
72 | struct RXMsgData* mx; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
73 | char* url; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
74 | }; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
75 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
76 | |
|
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 | * 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
|
79 | */ |
|
34227
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33852
diff
changeset
|
80 | static void |
|
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33852
diff
changeset
|
81 | mxit_cb_ii_returned(PurpleHttpConnection *http_conn, PurpleHttpResponse *response, |
|
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33852
diff
changeset
|
82 | gpointer _iireq) |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
83 | { |
|
34227
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33852
diff
changeset
|
84 | struct ii_url_request* iireq = _iireq; |
|
35828
261f7d7810dd
imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35079
diff
changeset
|
85 | PurpleImage *img; |
|
34227
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33852
diff
changeset
|
86 | const gchar* data; |
|
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33852
diff
changeset
|
87 | size_t len; |
|
28841
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 | #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
|
90 | 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
|
91 | #endif |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
92 | |
|
34287
6cd0c77b1f6a
HTTP: successful is spelled with one l
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34253
diff
changeset
|
93 | if (!purple_http_response_is_successful(response)) { |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
94 | /* 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
|
95 | 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
|
96 | goto done; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
97 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
98 | |
|
31493
f0e79f3b63ae
Recognize (and ignore for now) the Gaming/Table Markup commands.
Andrew Victor <andrew.victor@mxit.com>
parents:
30207
diff
changeset
|
99 | /* lets first see if we don't have the inline image already in cache */ |
|
35828
261f7d7810dd
imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35079
diff
changeset
|
100 | if (g_hash_table_lookup(iireq->mx->session->inline_images, iireq->url)) { |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
101 | /* 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
|
102 | goto done; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
103 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
104 | |
|
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
|
105 | /* we now have the inline image, store a copy in the imagestore */ |
|
34227
6d016a081401
HTTP: migrate purple_util_fetch_url to new API for prpls
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33852
diff
changeset
|
106 | data = purple_http_response_get_data(response, &len); |
|
35828
261f7d7810dd
imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35079
diff
changeset
|
107 | img = purple_image_new_from_data(g_memdup(data, len), len); |
|
261f7d7810dd
imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35079
diff
changeset
|
108 | g_hash_table_insert(iireq->mx->session->inline_images, iireq->url, img); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
109 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
110 | 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
|
111 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
112 | done: |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
113 | 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
|
114 | 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
|
115 | /* |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
116 | * 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
|
117 | * 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
|
118 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
119 | 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
|
120 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
121 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
122 | g_free(iireq); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
123 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
124 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
125 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
126 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
127 | * 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
|
128 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
129 | * @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
|
130 | * @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
|
131 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
132 | 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
|
133 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
134 | char* op; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
135 | char* type; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
136 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
137 | 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
|
138 | if (op) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
139 | 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
|
140 | 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
|
141 | 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
|
142 | return MXIT_CMD_UNKNOWN; |
|
30206
78a84b7ac7fe
Fix the processing of the "Clear" MXit command.
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
143 | 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
|
144 | 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
|
145 | 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
|
146 | 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
|
147 | 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
|
148 | 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
|
149 | 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
|
150 | 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
|
151 | 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
|
152 | 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
|
153 | } |
|
31493
f0e79f3b63ae
Recognize (and ignore for now) the Gaming/Table Markup commands.
Andrew Victor <andrew.victor@mxit.com>
parents:
30207
diff
changeset
|
154 | 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
|
155 | 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
|
156 | 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
|
157 | 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
|
158 | 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
|
159 | 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
|
160 | 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
|
161 | 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
|
162 | 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
|
163 | 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
|
164 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
165 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
166 | 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
|
167 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
168 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
169 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
170 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
171 | * 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
|
172 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
173 | * @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
|
174 | * @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
|
175 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
176 | 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
|
177 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
178 | GHashTable* hash = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
179 | gchar** parts; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
180 | int i = 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
181 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
182 | #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
|
183 | 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
|
184 | #endif |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
185 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
186 | /* 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
|
187 | 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
|
188 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
189 | 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
|
190 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
191 | /* 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
|
192 | 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
|
193 | char* value; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
194 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
195 | 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
|
196 | if (value != NULL) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
197 | *value = '\0'; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
198 | value++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
199 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
200 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
201 | #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
|
202 | 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
|
203 | #endif |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
204 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
205 | 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
|
206 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
207 | i++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
208 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
209 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
210 | g_strfreev(parts); |
|
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 | return hash; |
|
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 | |
|
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 | /*------------------------------------------------------------------------ |
|
30206
78a84b7ac7fe
Fix the processing of the "Clear" MXit command.
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
217 | * 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
|
218 | * [::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
|
219 | * |
|
30207
ca2838c8b6fa
Add support for the "nm=" syle of clickable links.
Andrew Victor <andrew.victor@mxit.com>
parents:
30206
diff
changeset
|
220 | * @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
|
221 | * @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
|
222 | * @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
|
223 | */ |
|
30206
78a84b7ac7fe
Fix the processing of the "Clear" MXit command.
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
224 | 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
|
225 | { |
|
34637
9cdc9e6eecce
Refactored mxit and myspace protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
226 | PurpleIMConversation *im; |
|
30206
78a84b7ac7fe
Fix the processing of the "Clear" MXit command.
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
227 | char* clearmsgscreen; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
228 | |
|
34637
9cdc9e6eecce
Refactored mxit and myspace protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
229 | im = purple_conversations_find_im_with_account(from, session->acc); |
|
9cdc9e6eecce
Refactored mxit and myspace protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
230 | if (im == NULL) { |
|
30206
78a84b7ac7fe
Fix the processing of the "Clear" MXit command.
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
231 | 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
|
232 | return; |
|
78a84b7ac7fe
Fix the processing of the "Clear" MXit command.
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
233 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
234 | |
|
30206
78a84b7ac7fe
Fix the processing of the "Clear" MXit command.
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
235 | 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
|
236 | 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
|
237 | /* this is a command to clear the chat screen */ |
|
34637
9cdc9e6eecce
Refactored mxit and myspace protocols to use the GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
238 | purple_conversation_clear_message_history(PURPLE_CONVERSATION(im)); |
|
30206
78a84b7ac7fe
Fix the processing of the "Clear" MXit command.
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
239 | } |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
240 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
241 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
242 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
243 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
244 | * 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
|
245 | * [::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
|
246 | * [::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
|
247 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
248 | * @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
|
249 | * @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
|
250 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
251 | 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
|
252 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
253 | char* replymsg; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
254 | char* selmsg; |
|
30207
ca2838c8b6fa
Add support for the "nm=" syle of clickable links.
Andrew Victor <andrew.victor@mxit.com>
parents:
30206
diff
changeset
|
255 | char* nm; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
256 | |
|
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
|
257 | 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
|
258 | 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
|
259 | 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
|
260 | |
|
554bc9cc52a8
MXit: When sending a structured response when the user clicks on a link, the format of the response message was not totally correct.
Andrew Victor <andrew.victor@mxit.com>
parents:
33615
diff
changeset
|
261 | 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
|
262 | 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
|
263 | |
|
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 | 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
|
265 | gchar* seltext = g_markup_escape_text(purple_url_decode(selmsg), -1); |
|
34506
f161fc3074d1
Fix two edge-cases in handling command links:
Andrew Victor <andrew.victor@mxit.com>
parents:
33850
diff
changeset
|
266 | gchar* replycmd = g_strdup_printf("type=reply|nm=%s|res=%s|err=0", nm, purple_url_decode(replymsg)); |
|
30207
ca2838c8b6fa
Add support for the "nm=" syle of clickable links.
Andrew Victor <andrew.victor@mxit.com>
parents:
30206
diff
changeset
|
267 | |
|
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
|
268 | 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
|
269 | |
|
ca2838c8b6fa
Add support for the "nm=" syle of clickable links.
Andrew Victor <andrew.victor@mxit.com>
parents:
30206
diff
changeset
|
270 | g_free(seltext); |
|
ca2838c8b6fa
Add support for the "nm=" syle of clickable links.
Andrew Victor <andrew.victor@mxit.com>
parents:
30206
diff
changeset
|
271 | g_free(replycmd); |
|
ca2838c8b6fa
Add support for the "nm=" syle of clickable links.
Andrew Victor <andrew.victor@mxit.com>
parents:
30206
diff
changeset
|
272 | } |
|
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 | else { |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
274 | 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
|
275 | |
|
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
|
276 | 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
|
277 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
278 | g_free(seltext); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
279 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
280 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
281 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
282 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
283 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
284 | * Process a PlatformRequest MXit command. |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
285 | * [::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
|
286 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
287 | * @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
|
288 | * @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
|
289 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
290 | 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
|
291 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
292 | gchar* text = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
293 | char* selmsg; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
294 | char* dest; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
295 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
296 | selmsg = g_hash_table_lookup(hash, "selmsg"); /* find the selection message */ |
|
34506
f161fc3074d1
Fix two edge-cases in handling command links:
Andrew Victor <andrew.victor@mxit.com>
parents:
33850
diff
changeset
|
297 | if (selmsg && (strlen(selmsg) > 0)) { |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
298 | 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
|
299 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
300 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
301 | 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
|
302 | if (dest) { |
|
28945
f94c51ec07d9
Mark a bunch of mxit strings for translation
Mark Doliner <markdoliner@pidgin.im>
parents:
28841
diff
changeset
|
303 | 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
|
304 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
305 | |
|
37426
6fd4989b77e4
The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents:
37135
diff
changeset
|
306 | g_free(text); |
|
28841
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 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
309 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
310 | /*------------------------------------------------------------------------ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
311 | * 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
|
312 | * [::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
|
313 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
314 | * @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
|
315 | * @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
|
316 | * @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
|
317 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
318 | 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
|
319 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
320 | const char* img; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
321 | const char* reply; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
322 | guchar* rawimg; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
323 | gsize rawimglen; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
324 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
325 | 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
|
326 | if (img) { |
|
35828
261f7d7810dd
imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35079
diff
changeset
|
327 | PurpleImage *pimg; |
|
261f7d7810dd
imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35079
diff
changeset
|
328 | guint pimg_id; |
|
261f7d7810dd
imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35079
diff
changeset
|
329 | |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
330 | 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
|
331 | //purple_util_write_data_to_file_absolute("/tmp/mxitinline.png", (char*) rawimg, rawimglen); |
|
35828
261f7d7810dd
imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35079
diff
changeset
|
332 | pimg = purple_image_new_from_data(rawimg, rawimglen); |
|
261f7d7810dd
imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35079
diff
changeset
|
333 | pimg_id = purple_image_store_add(pimg); |
|
261f7d7810dd
imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35079
diff
changeset
|
334 | g_string_append_printf(msg, "<img src=\"" |
|
261f7d7810dd
imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35079
diff
changeset
|
335 | PURPLE_IMAGE_STORE_PROTOCOL "%u\">", pimg_id); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
336 | 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
|
337 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
338 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
339 | img = g_hash_table_lookup(hash, "src"); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
340 | if (img) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
341 | 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
|
342 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
343 | 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
|
344 | 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
|
345 | iireq->mx = mx; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
346 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
347 | 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
|
348 | 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
|
349 | |
|
31493
f0e79f3b63ae
Recognize (and ignore for now) the Gaming/Table Markup commands.
Andrew Victor <andrew.victor@mxit.com>
parents:
30207
diff
changeset
|
350 | /* lets first see if we don't have the inline image already in cache */ |
|
35828
261f7d7810dd
imgstore: unref mxit
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35079
diff
changeset
|
351 | if (g_hash_table_lookup(mx->session->inline_images, iireq->url)) { |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
352 | /* 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
|
353 | g_free(iireq); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
354 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
355 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
356 | /* 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
|
357 | 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
|
358 | |
|
34233
8bdcc4f84a5e
HTTP: introduce purple_http_get_printf, make purple_http_get consistent with it
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34227
diff
changeset
|
359 | purple_http_get(mx->session->con, mxit_cb_ii_returned, iireq, iireq->url); |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
360 | mx->img_count++; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
361 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
362 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
363 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
364 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
365 | /* 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
|
366 | 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
|
367 | if (reply) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
368 | 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
|
369 | 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
|
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 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
373 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
374 | /*------------------------------------------------------------------------ |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
375 | * Process an Imagestrip MXit command. |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
376 | * [::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
|
377 | * |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
378 | * @param from The sender of the message. |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
379 | * @param hash The MXit command <key,value> map |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
380 | */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
381 | 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
|
382 | { |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
383 | const char* name; |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
384 | const char* validator; |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
385 | const char* tmp; |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
386 | int width, height, layer; |
|
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 | 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
|
389 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
390 | /* image strip name */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
391 | name = g_hash_table_lookup(hash, "nm"); |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
392 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
393 | /* validator */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
394 | validator = g_hash_table_lookup(hash, "v"); |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
395 | |
|
37806
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
396 | if (!name || !validator) |
|
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
397 | return; |
|
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
398 | |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
399 | /* image data */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
400 | tmp = g_hash_table_lookup(hash, "dat"); |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
401 | if (tmp) { |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
402 | guchar* rawimg; |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
403 | gsize rawimglen; |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
404 | 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
|
405 | 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
|
406 | 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
|
407 | char* escvalidator; |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
408 | char* filename; |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
409 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
410 | /* base64 decode the image data */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
411 | 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
|
412 | 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
|
413 | return; |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
414 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
415 | /* 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
|
416 | 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
|
417 | 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
|
418 | |
|
33743
a8aef1d340f2
Fix a bug where a remote MXit user could possibly specify a local
Mark Doliner <mark@kingant.net>
parents:
33617
diff
changeset
|
419 | 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
|
420 | 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
|
421 | 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
|
422 | 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
|
423 | |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
424 | 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
|
425 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
426 | 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
|
427 | 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
|
428 | 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
|
429 | g_free(escvalidator); |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
430 | g_free(filename); |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
431 | } |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
432 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
433 | tmp = g_hash_table_lookup(hash, "fw"); |
|
37806
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
434 | width = (tmp ? atoi(tmp) : 0); |
|
31727
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 | tmp = g_hash_table_lookup(hash, "fh"); |
|
37806
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
437 | height = (tmp ? atoi(tmp) : 0); |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
438 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
439 | tmp = g_hash_table_lookup(hash, "layer"); |
|
37806
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
440 | layer = (tmp ? atoi(tmp) : 0); |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
441 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
442 | 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
|
443 | } |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
444 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
445 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
446 | /*------------------------------------------------------------------------ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
447 | * Process a Chat-Screen-Info MXit command. |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
448 | * [::op=csi:] |
|
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 | * @param session The MXit session object |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
451 | * @param from The sender of the message. |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
452 | */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
453 | 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
|
454 | { |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
455 | char* response; |
|
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 | 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
|
458 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
459 | // TODO: Determine width, height, colors of chat-screen. |
|
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 | 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
|
462 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
463 | /* send response back to MXit */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
464 | mxit_send_message( session, from, response, FALSE, TRUE ); |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
465 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
466 | g_free(response); |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
467 | } |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
468 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
469 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
470 | /*------------------------------------------------------------------------ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
471 | * Process a Chat-Screen-Configure MXit command. |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
472 | * [::op=csc|bhvr=|menu=<menu>|col=<colors>:] |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
473 | * where: |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
474 | * menu ::= <menuitem> { ";" <menuitem> } |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
475 | * menuitem ::= { type "," <text> "," <name> "," <meta> } |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
476 | * colors ::= <color> { ";" <color> } |
|
33831
d160ede64878
MXit: Whitespace changes for coding-style consistency.
Andrew Victor <andrew.victor@mxit.com>
parents:
33816
diff
changeset
|
477 | * color ::= <colorid> "," <ARGB hex color> |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
478 | * |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
479 | * @param session The MXit session object |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
480 | * @param from The sender of the message. |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
481 | * @param hash The MXit command <key,value> map |
|
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 | 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
|
484 | { |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
485 | const char* tmp; |
|
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 | 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
|
488 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
489 | /* Behaviour */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
490 | tmp = g_hash_table_lookup(hash, "bhvr"); |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
491 | if (tmp) { |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
492 | 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
|
493 | // TODO: Re-configure conversation screen. |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
494 | } |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
495 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
496 | /* Menu */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
497 | tmp = g_hash_table_lookup(hash, "menu"); |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
498 | if (tmp) { |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
499 | 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
|
500 | // TODO: Implement conversation-specific sub-menu. |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
501 | } |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
502 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
503 | /* Colours */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
504 | tmp = g_hash_table_lookup(hash, "col"); |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
505 | if (tmp) { |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
506 | 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
|
507 | // TODO: Re-configuration conversation colors. |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
508 | } |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
509 | } |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
510 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
511 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
512 | /*------------------------------------------------------------------------ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
513 | * Process a Table Markup MXit command. |
|
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 | * @param mx The received message data object |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
516 | * @param hash The MXit command <key,value> map |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
517 | */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
518 | 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
|
519 | { |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
520 | const char* tmp; |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
521 | const char* name; |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
522 | int mode; |
|
37804
abdc3025f6b8
Fix TALOS-CAN-0134
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
523 | unsigned int nr_columns = 0, nr_rows = 0; |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
524 | gchar** coldata; |
|
37804
abdc3025f6b8
Fix TALOS-CAN-0134
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
525 | unsigned int i, j; |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
526 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
527 | /* table name */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
528 | name = g_hash_table_lookup(hash, "nm"); |
|
37806
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
529 | if (!name) |
|
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
530 | return; |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
531 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
532 | /* number of columns */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
533 | tmp = g_hash_table_lookup(hash, "col"); |
|
37806
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
534 | nr_columns = (tmp ? atoi(tmp) : 0); |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
535 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
536 | /* number of rows */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
537 | tmp = g_hash_table_lookup(hash, "row"); |
|
37806
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
538 | nr_rows = (tmp ? atoi(tmp) : 0); |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
539 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
540 | /* mode */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
541 | tmp = g_hash_table_lookup(hash, "mode"); |
|
37806
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
542 | mode = (tmp ? atoi(tmp) : 0); |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
543 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
544 | /* table data */ |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
545 | tmp = g_hash_table_lookup(hash, "d"); |
|
37806
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
546 | if (!tmp) |
|
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
547 | tmp = ""; |
|
1c4acc6977a8
Fix TALOS-CAN-0133
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
548 | |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
549 | 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
|
550 | |
|
37804
abdc3025f6b8
Fix TALOS-CAN-0134
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
551 | if (g_strv_length(coldata) != (nr_rows * nr_columns)) { |
|
abdc3025f6b8
Fix TALOS-CAN-0134
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
552 | purple_debug_info(MXIT_PLUGIN_ID, "Invalid table data: cols=%i rows=%i\n", nr_columns, nr_rows); |
|
abdc3025f6b8
Fix TALOS-CAN-0134
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
553 | g_strfreev(coldata); |
|
abdc3025f6b8
Fix TALOS-CAN-0134
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
554 | return; |
|
abdc3025f6b8
Fix TALOS-CAN-0134
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
555 | } |
|
abdc3025f6b8
Fix TALOS-CAN-0134
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
556 | |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
557 | 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
|
558 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
559 | for (i = 0; i < nr_rows; i++) { |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
560 | for (j = 0; j < nr_columns; j++) { |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
561 | 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
|
562 | } |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
563 | } |
|
37804
abdc3025f6b8
Fix TALOS-CAN-0134
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
564 | |
|
abdc3025f6b8
Fix TALOS-CAN-0134
Andrew Victor <andrew.victor@mxit.com>
parents:
34506
diff
changeset
|
565 | g_strfreev(coldata); |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
566 | } |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
567 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
568 | |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
569 | /*------------------------------------------------------------------------ |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
570 | * 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
|
571 | * |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
572 | * @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
|
573 | * @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
|
574 | * @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
|
575 | */ |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
576 | 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
|
577 | { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
578 | GHashTable* hash = NULL; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
579 | char* start; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
580 | char* end; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
581 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
582 | /* 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
|
583 | 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
|
584 | /* 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
|
585 | return 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
586 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
587 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
588 | start = message + 2; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
589 | end = strstr(start, ":"); |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
590 | if (end) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
591 | /* 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
|
592 | *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
|
593 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
594 | 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
|
595 | if (hash) { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
596 | 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
|
597 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
598 | switch (type) { |
|
30206
78a84b7ac7fe
Fix the processing of the "Clear" MXit command.
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
599 | case MXIT_CMD_CLEAR : |
|
78a84b7ac7fe
Fix the processing of the "Clear" MXit command.
Andrew Victor <andrew.victor@mxit.com>
parents:
29106
diff
changeset
|
600 | 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
|
601 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
602 | case MXIT_CMD_REPLY : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
603 | 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
|
604 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
605 | 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
|
606 | 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
|
607 | break; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
608 | 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
|
609 | 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
|
610 | break; |
|
31727
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
611 | case MXIT_CMD_SCREENCONFIG : |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
612 | command_screenconfig(mx->session, mx->from, hash); |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
613 | break; |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
614 | case MXIT_CMD_SCREENINFO : |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
615 | command_screeninfo(mx->session, mx->from); |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
616 | break; |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
617 | case MXIT_CMD_IMAGESTRIP : |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
618 | command_imagestrip(mx->session, mx->from, hash); |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
619 | break; |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
620 | case MXIT_CMD_TABLE : |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
621 | command_table(mx, hash); |
|
c5097c76d9a3
Start on Gaming & Table markup.
Andrew Victor <andrew.victor@mxit.com>
parents:
31724
diff
changeset
|
622 | break; |
|
28841
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
623 | default : |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
624 | /* 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
|
625 | break; |
|
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 | 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
|
628 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
629 | *end = ':'; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
630 | |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
631 | return end - message; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
632 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
633 | else { |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
634 | return 0; |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
635 | } |
|
6b9568572bcb
Initial addition of the MXit protocol plugin, provided by the MXit folks
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff
changeset
|
636 | } |