Mercurial > pidgin
annotate libpurple/protocols/myspace/myspace.c @ 17692:3aed9c8c6af7
Fix bug where string returned from msim_msg_get_string() is not a new
string if the data type is a string (oops). This fixes the get info crash
on Windows.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Thu, 05 Jul 2007 00:29:25 +0000 |
parents | b9fd55903979 |
children | 3c613fec5617 |
rev | line source |
---|---|
16394 | 1 /* MySpaceIM Protocol Plugin |
2 * | |
3 * \author Jeff Connelly | |
4 * | |
17680
d87916bd1d73
Fix email address.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17679
diff
changeset
|
5 * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im> |
16394 | 6 * |
16396 | 7 * Based on Purple's "C Plugin HOWTO" hello world example. |
16394 | 8 * |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
9 * Code also drawn from mockprpl: |
16396 | 10 * http://snarfed.org/space/purple+mock+protocol+plugin |
16394 | 11 * Copyright (C) 2004-2007, Ryan Barrett <mockprpl@ryanb.org> |
12 * | |
16396 | 13 * and some constructs also based on existing Purple plugins, which are: |
14 * Copyright (C) 2003, Robbert Haarman <purple@inglorion.net> | |
16394 | 15 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> |
16 * Copyright (C) 2000-2003, Rob Flynn <rob@tgflinux.com> | |
17 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
18 * | |
19 * This program is free software; you can redistribute it and/or modify | |
20 * it under the terms of the GNU General Public License as published by | |
21 * the Free Software Foundation; either version 2 of the License, or | |
22 * (at your option) any later version. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, | |
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
27 * GNU General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program; if not, write to the Free Software | |
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
32 */ | |
33 | |
16396 | 34 #define PURPLE_PLUGIN |
16394 | 35 |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
36 #include "message.h" |
17286
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
37 #include "persist.h" |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
38 #include "myspace.h" |
16394 | 39 |
16726
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
40 /** |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
41 * Load the plugin. |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
42 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
43 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
44 msim_load(PurplePlugin *plugin) |
16726
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
45 { |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
46 /* If compiled to use RC4 from libpurple, check if it is really there. */ |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
47 if (!purple_ciphers_find_cipher("rc4")) |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
48 { |
17683
dbf7fe20799d
Remove RC4 implementation, now exclusively rely on libpurple to provide RC4.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17681
diff
changeset
|
49 purple_debug_error("msim", "rc4 not in libpurple, but it is required - not loading MySpaceIM plugin!\n"); |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
50 purple_notify_error(plugin, _("Missing Cipher"), |
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
51 _("The RC4 cipher could not be found"), |
17683
dbf7fe20799d
Remove RC4 implementation, now exclusively rely on libpurple to provide RC4.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17681
diff
changeset
|
52 _("Upgrade " |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
53 "to a libpurple with RC4 support (>= 2.0.1). MySpaceIM " |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
54 "plugin will not be loaded.")); |
16726
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
55 return FALSE; |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
56 } |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
57 return TRUE; |
16394 | 58 } |
59 | |
60 /** | |
61 * Get possible user status types. Based on mockprpl. | |
62 * | |
63 * @return GList of status types. | |
64 */ | |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
65 GList * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
66 msim_status_types(PurpleAccount *acct) |
16394 | 67 { |
68 GList *types; | |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
69 PurpleStatusType *status; |
16394 | 70 |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
71 purple_debug_info("myspace", "returning status types\n"); |
16394 | 72 |
73 types = NULL; | |
74 | |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
75 status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE, NULL, NULL, FALSE, TRUE, FALSE); |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
76 types = g_list_append(types, status); |
16394 | 77 |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
78 status = purple_status_type_new_full(PURPLE_STATUS_AWAY, NULL, NULL, FALSE, TRUE, FALSE); |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
79 types = g_list_append(types, status); |
16394 | 80 |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
81 status = purple_status_type_new_full(PURPLE_STATUS_OFFLINE, NULL, NULL, FALSE, TRUE, FALSE); |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
82 types = g_list_append(types, status); |
16394 | 83 |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
84 status = purple_status_type_new_full(PURPLE_STATUS_INVISIBLE, NULL, NULL, FALSE, TRUE, FALSE); |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
85 types = g_list_append(types, status); |
16394 | 86 |
87 return types; | |
88 } | |
89 | |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
90 /** |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
91 * Return the icon name for a buddy and account. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
92 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
93 * @param acct The account to find the icon for, or NULL for protocol icon. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
94 * @param buddy The buddy to find the icon for, or NULL for the account icon. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
95 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
96 * @return The base icon name string. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
97 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
98 const gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
99 msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy) |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
100 { |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
101 /* Use a MySpace icon submitted by hbons at |
16733
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
102 * http://developer.pidgin.im/wiki/MySpaceIM. */ |
16406
f62023eddfc6
Add and use MySpaceIM icon uploaded by hbons (48x48 original and resized 22x22 and 16x16 versions).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
103 return "myspace"; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
104 } |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
105 |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
106 /* Replacement codes to be replaced with associated replacement text, |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
107 * used for protocol message escaping / unescaping. */ |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
108 static gchar* msim_replacement_code[] = { "/1", "/2", NULL }; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
109 static gchar* msim_replacement_text[] = { "/", "\\", NULL }; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
110 |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
111 /** |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
112 * Unescape or escape a protocol message. |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
113 * |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
114 * @param msg The message to be unescaped or escaped. WILL BE FREED. |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
115 * @param escape TRUE to escape, FALSE to unescape. |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
116 * |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
117 * @return The unescaped or escaped message. Caller must g_free(). |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
118 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
119 gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
120 msim_unescape_or_escape(gchar *msg, gboolean escape) |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
121 { |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
122 gchar *tmp, *code, *text; |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
123 guint i; |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
124 |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
125 /* Replace each code in msim_replacement_code with |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
126 * corresponding entry in msim_replacement_text. */ |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
127 for (i = 0; (code = msim_replacement_code[i]) |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
128 && (text = msim_replacement_text[i]); ++i) |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
129 { |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
130 if (escape) |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
131 { |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
132 tmp = str_replace(msg, text, code); |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
133 } |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
134 else |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
135 { |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
136 tmp = str_replace(msg, code, text); |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
137 } |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
138 g_free(msg); |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
139 msg = tmp; |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
140 } |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
141 |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
142 return msg; |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
143 } |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
144 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
145 /** |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
146 * Escape a protocol message. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
147 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
148 * @return The escaped message. Caller must g_free(). |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
149 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
150 gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
151 msim_escape(const gchar *msg) |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
152 { |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
153 return msim_unescape_or_escape(g_strdup(msg), TRUE); |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
154 } |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
155 |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
156 gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
157 msim_unescape(const gchar *msg) |
17649
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
158 { |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17648
diff
changeset
|
159 return msim_unescape_or_escape(g_strdup(msg), FALSE); |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
160 } |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
161 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
162 /** |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
163 * Replace 'old' with 'new' in 'str'. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
164 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
165 * @param str The original string. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
166 * @param old The substring of 'str' to replace. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
167 * @param new The replacement for 'old' within 'str'. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
168 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
169 * @return A _new_ string, based on 'str', with 'old' replaced |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
170 * by 'new'. Must be g_free()'d by caller. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
171 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
172 * This string replace method is based on |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
173 * http://mail.gnome.org/archives/gtk-app-devel-list/2000-July/msg00201.html |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
174 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
175 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
176 gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
177 str_replace(const gchar *str, const gchar *old, const gchar *new) |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
178 { |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
179 gchar **items; |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
180 gchar *ret; |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
181 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
182 items = g_strsplit(str, old, -1); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
183 ret = g_strjoinv(new, items); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
184 g_free(items); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
185 return ret; |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
186 } |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
187 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
188 #ifdef MSIM_DEBUG_MSG |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
189 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
190 print_hash_item(gpointer key, gpointer value, gpointer user_data) |
16394 | 191 { |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
192 purple_debug_info("msim", "%s=%s\n", (gchar *)key, (gchar *)value); |
16394 | 193 } |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
194 #endif |
16394 | 195 |
196 /** | |
17660
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
197 * Send raw data (given as a NUL-terminated string) to the server. |
16394 | 198 * |
199 * @param session | |
17660
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
200 * @param msg The raw data to send, in a NUL-terminated string. |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
201 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
202 * @return TRUE if succeeded, FALSE if not. |
16394 | 203 * |
204 */ | |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
205 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
206 msim_send_raw(MsimSession *session, const gchar *msg) |
16394 | 207 { |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
208 purple_debug_info("msim", "msim_send_raw: writing <%s>\n", msg); |
16394 | 209 |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
210 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
211 g_return_val_if_fail(msg != NULL, FALSE); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
212 |
17660
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
213 return msim_send_really_raw(session->gc, msg, strlen(msg)) == |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
214 strlen(msg); |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
215 } |
16394 | 216 |
17660
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
217 /** Send raw data to the server, possibly with embedded NULs. |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
218 * |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
219 * Used in prpl_info struct, so that plugins can have the most possible |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
220 * control of what is sent over the connection. Inside this prpl, |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
221 * msim_send_raw() is used, since it sends NUL-terminated strings (easier). |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
222 * |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
223 * @param gc PurpleConnection |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
224 * @param buf Buffer to send |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
225 * @param total_bytes Size of buffer to send |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
226 * |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
227 * @return Bytes successfully sent, or -1 on error. |
17660
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
228 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
229 int |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
230 msim_send_really_raw(PurpleConnection *gc, const char *buf, int total_bytes) |
17660
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
231 { |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
232 int total_bytes_sent; |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
233 MsimSession *session; |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
234 |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
235 g_return_val_if_fail(gc != NULL, -1); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
236 g_return_val_if_fail(buf != NULL, -1); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
237 g_return_val_if_fail(total_bytes >= 0, -1); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
238 |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
239 session = (MsimSession *)(gc->proto_data); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
240 |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
241 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
17660
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
242 |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
243 /* Loop until all data is sent, or a failure occurs. */ |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
244 total_bytes_sent = 0; |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
245 do |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
246 { |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
247 int bytes_sent; |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
248 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
249 bytes_sent = send(session->fd, buf + total_bytes_sent, |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
250 total_bytes - total_bytes_sent, 0); |
16394 | 251 |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
252 if (bytes_sent < 0) |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
253 { |
16723
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
254 purple_debug_info("msim", "msim_send_raw(%s): send() failed: %s\n", |
17660
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
255 buf, g_strerror(errno)); |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
256 return total_bytes_sent; |
16409
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
257 } |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
258 total_bytes_sent += bytes_sent; |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
259 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
260 } while(total_bytes_sent < total_bytes); |
17660
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
261 |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
262 return total_bytes_sent; |
16394 | 263 } |
264 | |
17660
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
265 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
266 /** |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
267 * Start logging in to the MSIM servers. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
268 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
269 * @param acct Account information to use to login. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
270 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
271 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
272 msim_login(PurpleAccount *acct) |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
273 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
274 PurpleConnection *gc; |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
275 const gchar *host; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
276 int port; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
277 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
278 g_return_if_fail(acct != NULL); |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
279 g_return_if_fail(acct->username != NULL); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
280 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
281 purple_debug_info("myspace", "logging in %s\n", acct->username); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
282 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
283 gc = purple_account_get_connection(acct); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
284 gc->proto_data = msim_session_new(acct); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
285 |
17684
e440846f9a21
Increase password length limit to 10 and update changes file.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17683
diff
changeset
|
286 /* Passwords are limited in length. */ |
17665
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
287 if (strlen(acct->password) > MSIM_MAX_PASSWORD_LENGTH) |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
288 { |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
289 gchar *str; |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
290 |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
291 str = g_strdup_printf( |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
292 _("Sorry, passwords over %d characters in length (yours is " |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
293 "%d) are not supported by the MySpaceIM plugin."), |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
294 MSIM_MAX_PASSWORD_LENGTH, |
17665
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
295 (int)strlen(acct->password)); |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
296 |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
297 /* Notify an error message also, because this is important! */ |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
298 purple_notify_error(acct, g_strdup(_("MySpaceIM Error")), str, NULL); |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
299 |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
300 purple_connection_error(gc, str); |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
301 |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
302 g_free(str); |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
303 } |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17664
diff
changeset
|
304 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
305 /* 1. connect to server */ |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
306 purple_connection_update_progress(gc, _("Connecting"), |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
307 0, /* which connection step this is */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
308 4); /* total number of steps */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
309 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
310 host = purple_account_get_string(acct, "server", MSIM_SERVER); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
311 port = purple_account_get_int(acct, "port", MSIM_PORT); |
16733
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
312 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
313 /* From purple.sf.net/api: |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
314 * """Note that this function name can be misleading--although it is called |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
315 * "proxy connect," it is used for establishing any outgoing TCP connection, |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
316 * whether through a proxy or not.""" */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
317 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
318 /* Calls msim_connect_cb when connected. */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
319 if (purple_proxy_connect(gc, acct, host, port, msim_connect_cb, gc) == NULL) |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
320 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
321 /* TODO: try other ports if in auto mode, then save |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
322 * working port and try that first next time. */ |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
323 purple_connection_error(gc, _("Couldn't create socket")); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
324 return; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
325 } |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
326 } |
17660
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
327 |
16394 | 328 /** |
329 * Process a login challenge, sending a response. | |
330 * | |
331 * @param session | |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
332 * @param msg Login challenge message. |
16394 | 333 * |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
334 * @return TRUE if successful, FALSE if not |
16394 | 335 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
336 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
337 msim_login_challenge(MsimSession *session, MsimMessage *msg) |
16394 | 338 { |
16396 | 339 PurpleAccount *account; |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
340 const gchar *response; |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
341 guint response_len; |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
342 gchar *nc; |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
343 gsize nc_len; |
16394 | 344 |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
345 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
346 g_return_val_if_fail(msg != NULL, FALSE); |
16394 | 347 |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
348 g_return_val_if_fail(msim_msg_get_binary(msg, "nc", &nc, &nc_len), FALSE); |
16394 | 349 |
350 account = session->account; | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
351 |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
352 g_return_val_if_fail(account != NULL, FALSE); |
16394 | 353 |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
354 purple_connection_update_progress(session->gc, _("Reading challenge"), 1, 4); |
16394 | 355 |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
356 purple_debug_info("msim", "nc is %d bytes, decoded\n", nc_len); |
16394 | 357 |
358 if (nc_len != 0x40) | |
359 { | |
16396 | 360 purple_debug_info("msim", "bad nc length: %x != 0x40\n", nc_len); |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
361 purple_connection_error(session->gc, _("Unexpected challenge length from server")); |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
362 return FALSE; |
16394 | 363 } |
364 | |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
365 purple_connection_update_progress(session->gc, _("Logging in"), 2, 4); |
16394 | 366 |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
367 response = msim_compute_login_response(nc, account->username, account->password, &response_len); |
16394 | 368 |
369 g_free(nc); | |
370 | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
371 return msim_send(session, |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
372 "login2", MSIM_TYPE_INTEGER, MSIM_AUTH_ALGORITHM, |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
373 /* This is actually user's email address. */ |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
374 "username", MSIM_TYPE_STRING, g_strdup(account->username), |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
375 /* GString and gchar * response will be freed in msim_msg_free() in msim_send(). */ |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
376 "response", MSIM_TYPE_BINARY, g_string_new_len(response, response_len), |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
377 "clientver", MSIM_TYPE_INTEGER, MSIM_CLIENT_VERSION, |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
378 "reconn", MSIM_TYPE_INTEGER, 0, |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
379 "status", MSIM_TYPE_INTEGER, 100, |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
380 "id", MSIM_TYPE_INTEGER, 1, |
16731
2e0bd3e6f2c7
Incomplete attempt at using msim_send() instead of msim_send_raw().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16730
diff
changeset
|
381 NULL); |
16394 | 382 } |
383 | |
384 /** | |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
385 * Compute the base64'd login challenge response based on username, password, nonce, and IPs. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
386 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
387 * @param nonce The base64 encoded nonce ('nc') field from the server. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
388 * @param email User's email address (used as login name). |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
389 * @param password User's cleartext password. |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
390 * @param response_len Will be written with response length. |
16394 | 391 * |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
392 * @return Binary login challenge response, ready to send to the server. |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
393 * Must be g_free()'d when finished. NULL if error. |
16394 | 394 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
395 const gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
396 msim_compute_login_response(const gchar nonce[2 * NONCE_SIZE], |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
397 const gchar *email, const gchar *password, guint *response_len) |
16394 | 398 { |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
399 PurpleCipherContext *key_context; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
400 PurpleCipher *sha1; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
401 PurpleCipherContext *rc4; |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
402 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
403 guchar hash_pw[HASH_SIZE]; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
404 guchar key[HASH_SIZE]; |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
405 gchar *password_utf16le; |
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
406 guchar *data; |
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
407 guchar *data_out; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
408 size_t data_len, data_out_len; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
409 gsize conv_bytes_read, conv_bytes_written; |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
410 GError *conv_error; |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
411 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
412 int i; |
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
413 #endif |
16394 | 414 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
415 g_return_val_if_fail(nonce != NULL, NULL); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
416 g_return_val_if_fail(email != NULL, NULL); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
417 g_return_val_if_fail(password != NULL, NULL); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
418 g_return_val_if_fail(response_len != NULL, NULL); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
419 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
420 /* Convert ASCII password to UTF16 little endian */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
421 purple_debug_info("msim", "converting password to UTF-16LE\n"); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
422 conv_error = NULL; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
423 password_utf16le = g_convert(password, -1, "UTF-16LE", "UTF-8", |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
424 &conv_bytes_read, &conv_bytes_written, &conv_error); |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
425 |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
426 g_return_val_if_fail(conv_bytes_read == strlen(password), NULL); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
427 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
428 if (conv_error != NULL) |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
429 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
430 purple_debug_error("msim", |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
431 "g_convert password UTF8->UTF16LE failed: %s", |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
432 conv_error->message); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
433 g_error_free(conv_error); |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
434 return NULL; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
435 } |
16394 | 436 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
437 /* Compute password hash */ |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
438 purple_cipher_digest_region("sha1", (guchar *)password_utf16le, |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
439 conv_bytes_written, sizeof(hash_pw), hash_pw, NULL); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
440 g_free(password_utf16le); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
441 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
442 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
443 purple_debug_info("msim", "pwhash = "); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
444 for (i = 0; i < sizeof(hash_pw); i++) |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
445 purple_debug_info("msim", "%.2x ", hash_pw[i]); |
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
446 purple_debug_info("msim", "\n"); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
447 #endif |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
448 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
449 /* key = sha1(sha1(pw) + nonce2) */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
450 sha1 = purple_ciphers_find_cipher("sha1"); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
451 key_context = purple_cipher_context_new(sha1, NULL); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
452 purple_cipher_context_append(key_context, hash_pw, HASH_SIZE); |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
453 purple_cipher_context_append(key_context, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
454 purple_cipher_context_digest(key_context, sizeof(key), key, NULL); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
455 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
456 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
457 purple_debug_info("msim", "key = "); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
458 for (i = 0; i < sizeof(key); i++) |
16394 | 459 { |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
460 purple_debug_info("msim", "%.2x ", key[i]); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
461 } |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
462 purple_debug_info("msim", "\n"); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
463 #endif |
16394 | 464 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
465 rc4 = purple_cipher_context_new_by_name("rc4", NULL); |
16394 | 466 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
467 /* Note: 'key' variable is 0x14 bytes (from SHA-1 hash), |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
468 * but only first 0x10 used for the RC4 key. */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
469 purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
470 purple_cipher_context_set_key(rc4, key); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
471 |
17652
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17651
diff
changeset
|
472 /* TODO: obtain IPs of network interfaces */ |
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17651
diff
changeset
|
473 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
474 /* rc4 encrypt: |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
475 * nonce1+email+IP list */ |
17652
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17651
diff
changeset
|
476 |
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17651
diff
changeset
|
477 data_len = NONCE_SIZE + strlen(email) + MSIM_LOGIN_IP_LIST_LEN; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
478 data = g_new0(guchar, data_len); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
479 memcpy(data, nonce, NONCE_SIZE); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
480 memcpy(data + NONCE_SIZE, email, strlen(email)); |
17652
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17651
diff
changeset
|
481 memcpy(data + NONCE_SIZE + strlen(email), MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
482 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
483 data_out = g_new0(guchar, data_len); |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
484 |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
485 purple_cipher_context_encrypt(rc4, (const guchar *)data, |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
486 data_len, data_out, &data_out_len); |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
487 purple_cipher_context_destroy(rc4); |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
488 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
489 g_assert(data_out_len == data_len); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
490 |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
491 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
492 purple_debug_info("msim", "response=<%s>\n", data_out); |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
493 #endif |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
494 |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
495 *response_len = data_out_len; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
496 |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
497 return (const gchar *)data_out; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
498 } |
16394 | 499 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
500 /** |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
501 * Schedule an IM to be sent once the user ID is looked up. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
502 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
503 * @param gc Connection. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
504 * @param who A user id, email, or username to send the message to. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
505 * @param message Instant message text to send. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
506 * @param flags Flags. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
507 * |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
508 * @return 1 if successful or postponed, -1 if failed |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
509 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
510 * Allows sending to a user by username, email address, or userid. If |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
511 * a username or email address is given, the userid must be looked up. |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
512 * This function does that by calling msim_postprocess_outgoing(). |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
513 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
514 int |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
515 msim_send_im(PurpleConnection *gc, const gchar *who, const gchar *message, |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
516 PurpleMessageFlags flags) |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
517 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
518 MsimSession *session; |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
519 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
520 g_return_val_if_fail(gc != NULL, -1); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
521 g_return_val_if_fail(who != NULL, -1); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
522 g_return_val_if_fail(message != NULL, -1); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
523 |
17300
176b1ba4bafe
Remove 'flags' from send_im_cb_struct - it was never needed.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17299
diff
changeset
|
524 /* 'flags' has many options, not used here. */ |
176b1ba4bafe
Remove 'flags' from send_im_cb_struct - it was never needed.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17299
diff
changeset
|
525 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
526 session = (MsimSession *)gc->proto_data; |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
527 |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
528 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
529 |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
530 if (msim_send_bm(session, who, message, MSIM_BM_INSTANT)) |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
531 { |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
532 /* Return 1 to have Purple show this IM as being sent, 0 to not. I always |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
533 * return 1 even if the message could not be sent, since I don't know if |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
534 * it has failed yet--because the IM is only sent after the userid is |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
535 * retrieved from the server (which happens after this function returns). |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
536 */ |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
537 /* TODO: maybe if message is delayed, don't echo to conv window, |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
538 * but do echo it to conv window manually once it is actually |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
539 * sent? Would be complicated. */ |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
540 return 1; |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
541 } else { |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
542 return -1; |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
543 } |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
544 /* |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
545 * In MySpace, you login with your email address, but don't talk to other |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
546 * users using their email address. So there is currently an asymmetry in the |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
547 * IM windows when using this plugin: |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
548 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
549 * you@example.com: hello |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
550 * some_other_user: what's going on? |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
551 * you@example.com: just coding a prpl |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
552 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
553 * TODO: Make the sent IM's appear as from the user's username, instead of |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
554 * their email address. Purple uses the login (in MSIM, the email)--change this. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
555 */ |
16394 | 556 } |
557 | |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
558 /** Send a buddy message of a given type. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
559 * |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
560 * @param session |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
561 * @param who Username to send message to. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
562 * @param text Message text to send. Not freed; will be copied. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
563 * @param type A MSIM_BM_* constant. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
564 * |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
565 * @return TRUE if success, FALSE if fail. |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
566 * |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
567 * Buddy messages ('bm') include instant messages, action messages, status messages, etc. |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
568 * |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
569 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
570 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
571 msim_send_bm(MsimSession *session, const gchar *who, const gchar *text, |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
572 int type) |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
573 { |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
574 gboolean rc; |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
575 MsimMessage *msg; |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
576 const gchar *from_username; |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
577 |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
578 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
579 g_return_val_if_fail(who != NULL, FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
580 g_return_val_if_fail(text != NULL, FALSE); |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
581 |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
582 from_username = session->account->username; |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
583 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
584 purple_debug_info("msim", "sending %d message from %s to %s: %s\n", |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
585 type, from_username, who, text); |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
586 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
587 msg = msim_msg_new(TRUE, |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
588 "bm", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(type), |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
589 "sesskey", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(session->sesskey), |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
590 /* 't' will be inserted here */ |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
591 "cv", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(MSIM_CLIENT_VERSION), |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
592 "msg", MSIM_TYPE_STRING, g_strdup(text), |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
593 NULL); |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
594 |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
595 rc = msim_postprocess_outgoing(session, msg, who, "t", "cv"); |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
596 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
597 msim_msg_free(msg); |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
598 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
599 return rc; |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
600 } |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
601 |
17681
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
602 |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
603 #ifdef MSIM_FONT_SIZE_WORKS |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
604 /** Convert a msim markup font height to points. */ |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
605 static guint |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
606 msim_font_height_to_point(guint height) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
607 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
608 /* See also: libpurple/protocols/bonjour/jabber.c |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
609 * _font_size_ichat_to_purple */ |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
610 switch (height) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
611 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
612 case 11: return 8; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
613 case 12: return 9; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
614 case 13: return 10; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
615 case 14: |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
616 case 15: return 11; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
617 case 16: return 12; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
618 case 17: |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
619 case 18: return 13; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
620 case 19: return 14; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
621 case 20: return 15; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
622 case 21: return 16; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
623 default: return 12; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
624 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
625 } |
17681
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
626 #endif |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
627 |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
628 /** Convert the msim markup <f> (font) tag into HTML. */ |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
629 static void |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
630 msim_markup_f_to_html(xmlnode *root, gchar **begin, gchar **end) |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
631 { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
632 const gchar *face, *height_str, *decor_str; |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
633 GString *gs_end, *gs_begin; |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
634 guint decor, height; |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
635 |
17678
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
636 face = xmlnode_get_attrib(root, "f"); |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
637 height_str = xmlnode_get_attrib(root, "h"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
638 decor_str = xmlnode_get_attrib(root, "s"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
639 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
640 if (height_str) |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
641 height = atol(height_str); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
642 else |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
643 height = 12; |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
644 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
645 if (decor_str) |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
646 decor = atol(decor_str); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
647 else |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
648 decor = 0; |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
649 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
650 gs_begin = g_string_new(""); |
17678
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
651 #ifdef MSIM_FONT_SIZE_WORKS |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
652 /* TODO: get font size working */ |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
653 if (!face) |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
654 g_string_printf(gs_begin, "<font size='%d'>", |
17678
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
655 msim_font_height_to_point(height)); |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
656 else |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
657 g_string_printf(gs_begin, "<font face='%s' size='%d'>", face, |
17678
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
658 msim_font_height_to_point(height)); |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
659 #else |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
660 if (face) |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
661 { |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
662 g_string_printf(gs_begin, "<font face='%s'>", face); |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
663 } else { |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
664 g_string_printf(gs_begin, "<font>"); |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
665 } |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
666 #endif |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
667 |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
668 |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
669 /* No support for font-size CSS? */ |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
670 /* g_string_printf(gs_begin, "<span style='font-family: %s; font-size: %dpt'>", face, |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
671 msim_font_height_to_point(height)); */ |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
672 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
673 gs_end = g_string_new("</font>"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
674 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
675 if (decor & MSIM_TEXT_BOLD) |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
676 { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
677 g_string_append(gs_begin, "<b>"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
678 g_string_prepend(gs_end, "</b>"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
679 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
680 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
681 if (decor & MSIM_TEXT_ITALICS) |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
682 { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
683 g_string_append(gs_begin, "<i>"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
684 g_string_append(gs_end, "</i>"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
685 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
686 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
687 if (decor & MSIM_TEXT_UNDERLINE) |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
688 { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
689 g_string_append(gs_begin, "<u>"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
690 g_string_append(gs_end, "</u>"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
691 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
692 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
693 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
694 *begin = gs_begin->str; |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
695 *end = gs_end->str; |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
696 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
697 |
17677
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
698 /** Convert a msim markup color to a color suitable for libpurple. |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
699 * |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
700 * @param msim Either a color name, or an rgb(x,y,z) code. |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
701 * |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
702 * @return A new string, either a color name or #rrggbb code. Must g_free(). |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
703 */ |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
704 static char * |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
705 msim_color_to_purple(const char *msim) |
17677
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
706 { |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
707 guint red, green, blue; |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
708 |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
709 if (!msim) |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
710 return g_strdup("black"); |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
711 |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
712 if (sscanf(msim, "rgb(%d,%d,%d)", &red, &green, &blue) != 3) |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
713 { |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
714 /* Color name. */ |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
715 return g_strdup(msim); |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
716 } |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
717 /* TODO: rgba (alpha). */ |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
718 |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
719 return g_strdup_printf("#%.2x%.2x%.2x", red, green, blue); |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
720 } |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
721 |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
722 /** Convert the msim markup <p> (paragraph) tag into HTML. */ |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
723 static void |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
724 msim_markup_p_to_html(xmlnode *root, gchar **begin, gchar **end) |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
725 { |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
726 /* Just pass through unchanged. |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
727 * |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
728 * Note: attributes currently aren't passed, if there are any. */ |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
729 *begin = g_strdup("<p>"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
730 *end = g_strdup("</p>"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
731 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
732 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
733 /** Convert the msim markup <c> tag (text color) into HTML. TODO: Test */ |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
734 static void |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
735 msim_markup_c_to_html(xmlnode *root, gchar **begin, gchar **end) |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
736 { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
737 const gchar *color; |
17677
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
738 gchar *purple_color; |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
739 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
740 color = xmlnode_get_attrib(root, "v"); |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
741 if (!color) |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
742 { |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
743 purple_debug_info("msim", "msim_markup_c_to_html: <c> tag w/o v attr"); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
744 *begin = g_strdup(""); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
745 *end = g_strdup(""); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
746 /* TODO: log as unrecognized */ |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
747 return; |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
748 } |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
749 |
17677
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
750 purple_color = msim_color_to_purple(color); |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
751 |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
752 *begin = g_strdup_printf("<font color='%s'>", purple_color); |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
753 |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
754 g_free(purple_color); |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
755 |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
756 /* *begin = g_strdup_printf("<span style='color: %s'>", color); */ |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
757 *end = g_strdup("</font>"); |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
758 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
759 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
760 /** Convert the msim markup <b> tag (background color) into HTML. TODO: Test */ |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
761 static void |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
762 msim_markup_b_to_html(xmlnode *root, gchar **begin, gchar **end) |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
763 { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
764 const gchar *color; |
17677
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
765 gchar *purple_color; |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
766 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
767 color = xmlnode_get_attrib(root, "v"); |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
768 if (!color) |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
769 { |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
770 *begin = g_strdup(""); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
771 *end = g_strdup(""); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
772 purple_debug_info("msim", "msim_markup_b_to_html: <b> w/o v attr"); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
773 /* TODO: log as unrecognized. */ |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
774 return; |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
775 } |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
776 |
17677
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
777 purple_color = msim_color_to_purple(color); |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
778 |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
779 /* TODO: find out how to set background color. */ |
17677
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
780 *begin = g_strdup_printf("<span style='background-color: %s'>", |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
781 purple_color); |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
782 g_free(purple_color); |
11988aee28f2
Add msim_color_to_purple() to convert msim markup color to a color for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17676
diff
changeset
|
783 |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
784 *end = g_strdup("</p>"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
785 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
786 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
787 /** Convert the msim markup <i> tag (emoticon image) into HTML. TODO: Test */ |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
788 static void |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
789 msim_markup_i_to_html(xmlnode *root, gchar **begin, gchar **end) |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
790 { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
791 const gchar *name; |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
792 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
793 name = xmlnode_get_attrib(root, "n"); |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
794 if (!name) |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
795 { |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
796 purple_debug_info("msim", "msim_markup_i_to_html: <i> w/o n"); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
797 *begin = g_strdup(""); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
798 *end = g_strdup(""); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
799 /* TODO: log as unrecognized */ |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
800 return; |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
801 } |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
802 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
803 /* TODO: Support these emoticons: |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
804 * |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
805 * bigsmile growl mad scared tongue devil happy messed sidefrown upset |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
806 * frazzled heart nerd sinister wink geek laugh oops smirk worried |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
807 * googles mohawk pirate straight kiss |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
808 */ |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
809 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
810 *begin = g_strdup_printf("<img id='%s'>", name); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
811 *end = g_strdup("</p>"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
812 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
813 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
814 |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
815 /** Convert an xmlnode of msim markup to an HTML string. |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
816 * @return An HTML string. Caller frees. |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
817 */ |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
818 static gchar * |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
819 msim_markup_xmlnode_to_html(xmlnode *root) |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
820 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
821 xmlnode *node; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
822 gchar *begin, *inner, *end; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
823 gchar *final; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
824 |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
825 if (!root || !root->name) |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
826 return g_strdup(""); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
827 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
828 purple_debug_info("msim", "msim_markup_xmlnode_to_html: got root=%s\n", |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
829 root->name); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
830 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
831 begin = inner = end = NULL; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
832 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
833 if (!strcmp(root->name, "f")) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
834 { |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
835 msim_markup_f_to_html(root, &begin, &end); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
836 } else if (!strcmp(root->name, "p")) { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
837 msim_markup_p_to_html(root, &begin, &end); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
838 } else if (!strcmp(root->name, "c")) { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
839 msim_markup_c_to_html(root, &begin, &end); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
840 } else if (!strcmp(root->name, "b")) { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
841 msim_markup_b_to_html(root, &begin, &end); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
842 } else if (!strcmp(root->name, "i")) { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
843 msim_markup_i_to_html(root, &begin, &end); |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
844 } else { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
845 purple_debug_info("msim", "msim_markup_xmlnode_to_html: " |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
846 "unknown tag name=%s, ignoring", root->name); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
847 begin = g_strdup(""); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
848 end = g_strdup(""); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
849 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
850 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
851 /* Loop over all child nodes. */ |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
852 for (node = root->child; node != NULL; node = node->next) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
853 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
854 switch (node->type) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
855 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
856 case XMLNODE_TYPE_ATTRIB: |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
857 /* Attributes handled above. */ |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
858 break; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
859 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
860 case XMLNODE_TYPE_TAG: |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
861 /* A tag or tag with attributes. Recursively descend. */ |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
862 inner = msim_markup_xmlnode_to_html(node); |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
863 g_return_val_if_fail(inner != NULL, NULL); |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
864 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
865 purple_debug_info("msim", " ** node name=%s\n", node->name); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
866 break; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
867 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
868 case XMLNODE_TYPE_DATA: |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
869 /* Literal text. */ |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
870 inner = g_new0(char, node->data_sz + 1); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
871 strncpy(inner, node->data, node->data_sz); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
872 inner[node->data_sz + 1] = 0; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
873 |
17678
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
874 purple_debug_info("msim", " ** node data=%s\n", inner); |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
875 break; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
876 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
877 default: |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
878 purple_debug_info("msim", |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
879 "msim_markup_xmlnode_to_html: strange node\n"); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
880 inner = g_strdup(""); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
881 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
882 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
883 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
884 final = g_strconcat(begin, inner, end, NULL); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
885 g_free(begin); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
886 g_free(inner); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
887 g_free(end); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
888 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
889 purple_debug_info("msim", "msim_markup_xmlnode_to_gtkhtml: RETURNING %s\n", |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
890 final); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
891 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
892 return final; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
893 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
894 |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
895 /** Convert MySpaceIM markup to Purple (HTML) markup. |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
896 * |
17668
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17665
diff
changeset
|
897 * @return Purple markup string, must be g_free()'d. */ |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
898 gchar * |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
899 msim_markup_to_html(const gchar *raw) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
900 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
901 xmlnode *root; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
902 gchar *str; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
903 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
904 root = xmlnode_from_str(raw, -1); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
905 if (!root) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
906 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
907 purple_debug_info("msim", "msim_markup_to_html: couldn't parse " |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
908 "%s as XML, returning raw\n", raw); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
909 return g_strdup(raw); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
910 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
911 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
912 str = msim_markup_xmlnode_to_html(root); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
913 purple_debug_info("msim", "msim_markup_to_html: returning %s\n", str); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
914 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
915 xmlnode_free(root); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
916 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
917 return g_strdup(str); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
918 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
919 |
16394 | 920 /** |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
921 * Handle an incoming instant message. |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
922 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
923 * @param session The session |
17307
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
924 * @param msg Message from the server, containing 'f' (userid from) and 'msg'. |
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
925 * Should also contain username in _username from preprocessing. |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
926 * |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
927 * @return TRUE if successful. |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
928 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
929 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
930 msim_incoming_im(MsimSession *session, MsimMessage *msg) |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
931 { |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
932 gchar *username, *msg_msim_markup, *msg_purple_markup; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
933 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
934 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
935 g_return_val_if_fail(msg != NULL, FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
936 |
17307
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
937 username = msim_msg_get_string(msg, "_username"); |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
938 g_return_val_if_fail(username != NULL, FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
939 |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
940 msg_msim_markup = msim_msg_get_string(msg, "msg"); |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
941 g_return_val_if_fail(msg_msim_markup != NULL, FALSE); |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
942 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
943 msg_purple_markup = msim_markup_to_html(msg_msim_markup); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
944 g_free(msg_msim_markup); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
945 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
946 serv_got_im(session->gc, username, msg_purple_markup, |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
947 PURPLE_MESSAGE_RECV, time(NULL)); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
948 |
17307
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
949 g_free(username); |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
950 g_free(msg_purple_markup); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
951 |
17307
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
952 return TRUE; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
953 } |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
954 |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
955 /** |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
956 * Process unrecognized information. |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
957 * |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
958 * @param session |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
959 * @param msg An MsimMessage that was unrecognized, or NULL. |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
960 * @param note Information on what was unrecognized, or NULL. |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
961 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
962 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
963 msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note) |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
964 { |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
965 /* TODO: Some more context, outwardly equivalent to a backtrace, |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
966 * for helping figure out what this msg is for. What was going on? |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
967 * But not too much information so that a user |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
968 * posting this dump reveals confidential information. |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
969 */ |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
970 |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
971 /* TODO: dump unknown msgs to file, so user can send them to me |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
972 * if they wish, to help add support for new messages (inspired |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
973 * by Alexandr Shutko, who maintains OSCAR protocol documentation). */ |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
974 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
975 purple_debug_info("msim", "Unrecognized data on account for %s\n", |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
976 session->account->username); |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
977 if (note) |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
978 { |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
979 purple_debug_info("msim", "(Note: %s)\n", note); |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
980 } |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
981 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
982 if (msg) |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
983 { |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
984 msim_msg_dump("Unrecognized message dump: %s\n", msg); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
985 } |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
986 } |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
987 |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
988 /** |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
989 * Handle an incoming action message. |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
990 * |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
991 * @param session |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
992 * @param msg |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
993 * |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
994 * @return TRUE if successful. |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
995 * |
17308
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
996 * UNTESTED |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
997 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
998 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
999 msim_incoming_action(MsimSession *session, MsimMessage *msg) |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1000 { |
17308
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1001 gchar *msg_text, *username; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1002 gboolean rc; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1003 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1004 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1005 g_return_val_if_fail(msg != NULL, FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1006 |
17308
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1007 msg_text = msim_msg_get_string(msg, "msg"); |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1008 g_return_val_if_fail(msg_text != NULL, FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1009 |
17308
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1010 username = msim_msg_get_string(msg, "_username"); |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1011 g_return_val_if_fail(username != NULL, FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1012 |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1013 purple_debug_info("msim", "msim_incoming_action: action <%s> from <%d>\n", |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1014 msg_text, username); |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1015 |
17308
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1016 if (strcmp(msg_text, "%typing%") == 0) |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1017 { |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1018 /* TODO: find out if msim repeatedly sends typing messages, so we can |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1019 * give it a timeout. Right now, there does seem to be an inordinately |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1020 * amount of time between typing stopped-typing notifications. */ |
17308
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1021 serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1022 rc = TRUE; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1023 } else if (strcmp(msg_text, "%stoptyping%") == 0) { |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1024 serv_got_typing_stopped(session->gc, username); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1025 rc = TRUE; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1026 } else { |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1027 msim_unrecognized(session, msg, |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1028 "got to msim_incoming_action but unrecognized value for 'msg'"); |
17308
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1029 rc = FALSE; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1030 } |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1031 |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1032 g_free(msg_text); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1033 g_free(username); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1034 |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17307
diff
changeset
|
1035 return rc; |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1036 } |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1037 |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1038 /** |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1039 * Handle when our user starts or stops typing to another user. |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1040 * |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1041 * @param gc |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1042 * @param name The buddy name to which our user is typing to |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1043 * @param state PURPLE_TYPING, PURPLE_TYPED, PURPLE_NOT_TYPING |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1044 * |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1045 * @return 0 |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1046 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1047 unsigned int |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1048 msim_send_typing(PurpleConnection *gc, const gchar *name, |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1049 PurpleTypingState state) |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1050 { |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
1051 const gchar *typing_str; |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
1052 MsimSession *session; |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
1053 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1054 g_return_val_if_fail(gc != NULL, 0); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1055 g_return_val_if_fail(name != NULL, 0); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1056 |
17315
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17314
diff
changeset
|
1057 session = (MsimSession *)gc->proto_data; |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1058 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1059 g_return_val_if_fail(MSIM_SESSION_VALID(session), 0); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1060 |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1061 switch (state) |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1062 { |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1063 case PURPLE_TYPING: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1064 typing_str = "%typing%"; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1065 break; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1066 |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1067 case PURPLE_TYPED: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1068 case PURPLE_NOT_TYPING: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1069 default: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1070 typing_str = "%stoptyping%"; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1071 break; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1072 } |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1073 |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
1074 purple_debug_info("msim", "msim_send_typing(%s): %d (%s)\n", name, state, typing_str); |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
1075 msim_send_bm(session, name, typing_str, MSIM_BM_ACTION); |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1076 return 0; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1077 } |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1078 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1079 /** Callback for msim_get_info(), for when user info is received. */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1080 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1081 msim_get_info_cb(MsimSession *session, MsimMessage *user_info_msg, gpointer data) |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
1082 { |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1083 GHashTable *body; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1084 gchar *body_str; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1085 MsimMessage *msg; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1086 gchar *user; |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
1087 PurpleNotifyUserInfo *user_info; |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
1088 PurpleBuddy *buddy; |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1089 const gchar *str, *str2; |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1090 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1091 g_return_if_fail(MSIM_SESSION_VALID(session)); |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1092 |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1093 /* Get user{name,id} from msim_get_info, passed as an MsimMessage for |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1094 orthogonality. */ |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1095 msg = (MsimMessage *)data; |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1096 g_return_if_fail(msg != NULL); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1097 |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1098 user = msim_msg_get_string(msg, "user"); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1099 if (!user) |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1100 { |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1101 purple_debug_info("msim", "msim_get_info_cb: no 'user' in msg"); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1102 return; |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1103 } |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1104 |
17692
3aed9c8c6af7
Fix bug where string returned from msim_msg_get_string() is not a new
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17691
diff
changeset
|
1105 msim_msg_free(msg); |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1106 purple_debug_info("msim", "msim_get_info_cb: got for user: %s\n", user); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1107 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1108 body_str = msim_msg_get_string(user_info_msg, "body"); |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1109 g_return_if_fail(body_str != NULL); |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1110 body = msim_parse_body(body_str); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1111 g_free(body_str); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1112 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1113 buddy = purple_find_buddy(session->account, user); |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1114 /* Note: don't assume buddy is non-NULL; will be if lookup random user |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1115 * not on blist. */ |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
1116 |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
1117 user_info = purple_notify_user_info_new(); |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
1118 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1119 /* Identification */ |
17692
3aed9c8c6af7
Fix bug where string returned from msim_msg_get_string() is not a new
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17691
diff
changeset
|
1120 purple_notify_user_info_add_pair(user_info, _("User"), user); |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
1121 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1122 /* note: g_hash_table_lookup does not create a new string! */ |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1123 str = g_hash_table_lookup(body, "UserID"); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1124 if (str) |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1125 purple_notify_user_info_add_pair(user_info, _("User ID"), |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1126 g_strdup(str)); |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
1127 |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
1128 /* a/s/l...the vitals */ |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1129 str = g_hash_table_lookup(body, "Age"); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1130 if (str) |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1131 purple_notify_user_info_add_pair(user_info, _("Age"), g_strdup(str)); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1132 |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1133 str = g_hash_table_lookup(body, "Gender"); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1134 if (str) |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1135 purple_notify_user_info_add_pair(user_info, _("Gender"), g_strdup(str)); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1136 |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1137 str = g_hash_table_lookup(body, "Location"); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1138 if (str) |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1139 purple_notify_user_info_add_pair(user_info, _("Location"), |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1140 g_strdup(str)); |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
1141 |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
1142 /* Other information */ |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1143 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1144 /* Headline comes from buddy status messages */ |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1145 if (buddy) |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1146 { |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1147 str = purple_blist_node_get_string(&buddy->node, "Headline"); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1148 if (str) |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1149 purple_notify_user_info_add_pair(user_info, "Headline", str); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1150 } |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1151 |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1152 |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1153 str = g_hash_table_lookup(body, "BandName"); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1154 str2 = g_hash_table_lookup(body, "SongName"); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1155 if (str || str2) |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1156 { |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1157 purple_notify_user_info_add_pair(user_info, _("Song"), |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1158 g_strdup_printf("%s - %s", |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1159 str ? str : "Unknown Artist", |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1160 str2 ? str2 : "Unknown Song")); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1161 } |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1162 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1163 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1164 /* Total friends only available if looked up by uid, not username. */ |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1165 str = g_hash_table_lookup(body, "TotalFriends"); |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1166 if (str) |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1167 purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1168 g_strdup(str)); |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1169 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1170 purple_notify_userinfo(session->gc, user, user_info, NULL, NULL); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1171 purple_debug_info("msim", "msim_get_info_cb: username=%s\n", user); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1172 //purple_notify_user_info_destroy(user_info); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1173 /* Do not free username, since it will be used by user_info. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1174 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1175 //g_hash_table_destroy(body); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1176 } |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1177 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1178 /** Retrieve a user's profile. */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1179 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1180 msim_get_info(PurpleConnection *gc, const gchar *user) |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1181 { |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1182 PurpleBuddy *buddy; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1183 MsimSession *session; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1184 guint uid; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1185 gchar *user_to_lookup; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1186 MsimMessage *user_msg; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1187 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1188 g_return_if_fail(gc != NULL); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1189 g_return_if_fail(user != NULL); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1190 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1191 session = (MsimSession *)gc->proto_data; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1192 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1193 g_return_if_fail(MSIM_SESSION_VALID(session)); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1194 |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1195 /* Obtain uid of buddy. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1196 buddy = purple_find_buddy(session->account, user); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1197 if (buddy) |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1198 { |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1199 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1200 if (!uid) |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1201 { |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1202 PurpleNotifyUserInfo *user_info; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1203 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1204 user_info = purple_notify_user_info_new(); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1205 purple_notify_user_info_add_pair(user_info, NULL, |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1206 _("This buddy appears to not have a userid stored in the buddy list, can't look up. Is the user really on the buddy list?")); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1207 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1208 purple_notify_userinfo(session->gc, user, user_info, NULL, NULL); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1209 purple_notify_user_info_destroy(user_info); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1210 return; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1211 } |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1212 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1213 user_to_lookup = g_strdup_printf("%d", uid); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1214 } else { |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1215 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1216 /* Looking up buddy not on blist. Lookup by whatever user entered. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1217 user_to_lookup = g_strdup(user); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1218 } |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1219 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1220 /* Pass the username to msim_get_info_cb(), because since we lookup |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1221 * by userid, the userinfo message will only contain the uid (not |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1222 * the username). |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1223 */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1224 user_msg = msim_msg_new(TRUE, |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1225 "user", MSIM_TYPE_STRING, g_strdup(user), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1226 NULL); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1227 purple_debug_info("msim", "msim_get_info, setting up lookup, user=%s\n", user); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1228 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1229 msim_lookup_user(session, user_to_lookup, msim_get_info_cb, user_msg); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1230 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1231 g_free(user_to_lookup); |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
1232 } |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
1233 |
17681
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1234 /** Set your status - callback for when user manually sets it. */ |
17679
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1235 void |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1236 msim_set_status(PurpleAccount *account, PurpleStatus *status) |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1237 { |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1238 PurpleStatusType *type; |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1239 MsimSession *session; |
17686
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1240 guint status_code; |
17679
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1241 |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1242 session = (MsimSession *)account->gc->proto_data; |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1243 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1244 g_return_if_fail(MSIM_SESSION_VALID(session)); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1245 |
17679
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1246 type = purple_status_get_type(status); |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1247 |
17686
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1248 switch (purple_status_type_get_primitive(type)) |
17679
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1249 { |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1250 case PURPLE_STATUS_AVAILABLE: |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1251 status_code = MSIM_STATUS_CODE_ONLINE; |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1252 break; |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1253 |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1254 case PURPLE_STATUS_INVISIBLE: |
17680
d87916bd1d73
Fix email address.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17679
diff
changeset
|
1255 status_code = MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN; |
17679
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1256 break; |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1257 |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1258 case PURPLE_STATUS_AWAY: |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1259 status_code = MSIM_STATUS_CODE_AWAY; |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1260 break; |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1261 |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1262 default: |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1263 purple_debug_info("msim", "msim_set_status: unknown " |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1264 "status interpreting as online"); |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1265 status_code = MSIM_STATUS_CODE_ONLINE; |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1266 break; |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1267 } |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1268 |
17686
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1269 |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1270 msim_set_status_code(session, status_code); |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1271 } |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1272 |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1273 /** Go idle. */ |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1274 void |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1275 msim_set_idle(PurpleConnection *gc, int time) |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1276 { |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1277 MsimSession *session; |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1278 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1279 g_return_if_fail(gc != NULL); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1280 |
17686
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1281 session = (MsimSession *)gc->proto_data; |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1282 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1283 g_return_if_fail(MSIM_SESSION_VALID(session)); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1284 |
17686
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1285 if (time == 0) |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1286 { |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1287 /* Going back from idle. In msim, idle is mutually exclusive |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1288 * from the other states (you can only be away or idle, but not |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1289 * both, for example), so by going non-idle I go online. |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1290 */ |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1291 msim_set_status_code(session, MSIM_STATUS_CODE_ONLINE); |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1292 } else { |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1293 /* msim doesn't support idle time, so just go idle */ |
17686
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1294 msim_set_status_code(session, MSIM_STATUS_CODE_IDLE); |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1295 } |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1296 } |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1297 |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1298 /** Set status using an MSIM_STATUS_CODE_* value. (TODO: also set message) */ |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1299 void |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1300 msim_set_status_code(MsimSession *session, guint status_code) |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1301 { |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1302 g_return_if_fail(MSIM_SESSION_VALID(session)); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1303 |
17679
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1304 if (!msim_send(session, |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1305 "status", MSIM_TYPE_INTEGER, status_code, |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1306 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1307 "statstring", MSIM_TYPE_STRING, g_strdup(""), |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1308 "locstring", MSIM_TYPE_STRING, g_strdup(""))) |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1309 { |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1310 purple_debug_info("msim", "msim_set_status: failed to set status"); |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1311 } |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1312 |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1313 } |
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
1314 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1315 /** After a uid is resolved to username, tag it with the username and submit for processing. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1316 * |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1317 * @param session |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1318 * @param userinfo Response messsage to resolving request. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1319 * @param data MsimMessage *, the message to attach information to. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1320 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1321 static void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1322 msim_incoming_resolved(MsimSession *session, MsimMessage *userinfo, |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1323 gpointer data) |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1324 { |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1325 gchar *body_str; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1326 GHashTable *body; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1327 gchar *username; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1328 MsimMessage *msg; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1329 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1330 g_return_if_fail(MSIM_SESSION_VALID(session)); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1331 g_return_if_fail(userinfo != NULL); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1332 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1333 body_str = msim_msg_get_string(userinfo, "body"); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1334 g_return_if_fail(body_str != NULL); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1335 body = msim_parse_body(body_str); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1336 g_return_if_fail(body != NULL); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1337 g_free(body_str); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1338 |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1339 username = g_hash_table_lookup(body, "UserName"); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1340 g_return_if_fail(username != NULL); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1341 |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1342 msg = (MsimMessage *)data; |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1343 g_return_if_fail(msg != NULL); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1344 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1345 /* Special elements name beginning with '_', we'll use internally within the |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1346 * program (did not come from the wire). */ |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1347 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1348 |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1349 msim_process(session, msg); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1350 |
17307
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17306
diff
changeset
|
1351 /* TODO: Free copy cloned from msim_preprocess_incoming(). */ |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1352 //XXX msim_msg_free(msg); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1353 g_hash_table_destroy(body); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1354 } |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1355 |
17669
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1356 #if 0 |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1357 /* Lookup a username by userid, from buddy list. |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1358 * |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1359 * @param wanted_uid |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1360 * |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1361 * @return Username of wanted_uid, if on blist, or NULL. Static string. |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1362 * |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1363 * XXX WARNING: UNKNOWN MEMORY CORRUPTION HERE! |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1364 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1365 static const gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1366 msim_uid2username_from_blist(MsimSession *session, guint wanted_uid) |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1367 { |
17669
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1368 GSList *buddies, *cur; |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1369 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1370 buddies = purple_find_buddies(session->account, NULL); |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1371 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1372 if (!buddies) |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1373 { |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1374 purple_debug_info("msim", "msim_uid2username_from_blist: no buddies?"); |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1375 return NULL; |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1376 } |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1377 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1378 for (cur = buddies; cur != NULL; cur = g_slist_next(cur)) |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1379 { |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1380 PurpleBuddy *buddy; |
17669
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1381 //PurpleBlistNode *node; |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1382 guint uid; |
17669
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1383 const gchar *name; |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1384 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1385 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1386 /* See finch/gnthistory.c */ |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1387 buddy = cur->data; |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1388 //node = cur->data; |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1389 |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1390 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
17669
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1391 //uid = purple_blist_node_get_int(node, "UserID"); |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1392 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1393 /* name = buddy->name; */ /* crash */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1394 /* name = PURPLE_BLIST_NODE_NAME(&buddy->node); */ /* crash */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1395 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1396 /* XXX Is this right? Memory corruption here somehow. Happens only |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1397 * when return one of these values. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1398 name = purple_buddy_get_name(buddy); /* crash */ |
17669
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1399 //name = purple_buddy_get_name((PurpleBuddy *)node); /* crash */ |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1400 /* return name; */ /* crash (with above) */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1401 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1402 /* name = NULL; */ /* no crash */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1403 /* return NULL; */ /* no crash (with anything) */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1404 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1405 /* crash = |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1406 *** glibc detected *** pidgin: realloc(): invalid pointer: 0x0000000000d2aec0 *** |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1407 ======= Backtrace: ========= |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1408 /lib/libc.so.6(__libc_realloc+0x323)[0x2b7bfc012e03] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1409 /usr/lib/libglib-2.0.so.0(g_realloc+0x31)[0x2b7bfba79a41] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1410 /usr/lib/libgtk-x11-2.0.so.0(gtk_tree_path_append_index+0x3a)[0x2b7bfa110d5a] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1411 /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa1287dc] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1412 /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128e56] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1413 /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128efd] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1414 /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x1b4)[0x2b7bfba72c84] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1415 /usr/lib/libglib-2.0.so.0[0x2b7bfba75acd] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1416 /usr/lib/libglib-2.0.so.0(g_main_loop_run+0x1ca)[0x2b7bfba75dda] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1417 /usr/lib/libgtk-x11-2.0.so.0(gtk_main+0xa3)[0x2b7bfa0475f3] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1418 pidgin(main+0x8be)[0x46b45e] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1419 /lib/libc.so.6(__libc_start_main+0xf4)[0x2b7bfbfbf0c4] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1420 pidgin(gtk_widget_grab_focus+0x39)[0x429ab9] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1421 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1422 or: |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1423 *** glibc detected *** /usr/local/bin/pidgin: malloc(): memory corruption (fast): 0x0000000000c10076 *** |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1424 (gdb) bt |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1425 #0 0x00002b4074ecd47b in raise () from /lib/libc.so.6 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1426 #1 0x00002b4074eceda0 in abort () from /lib/libc.so.6 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1427 #2 0x00002b4074f0453b in __fsetlocking () from /lib/libc.so.6 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1428 #3 0x00002b4074f0c810 in free () from /lib/libc.so.6 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1429 #4 0x00002b4074f0d6dd in malloc () from /lib/libc.so.6 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1430 #5 0x00002b4074974b5b in g_malloc () from /usr/lib/libglib-2.0.so.0 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1431 #6 0x00002b40749868bf in g_strdup () from /usr/lib/libglib-2.0.so.0 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1432 #7 0x00002b407810969f in msim_parse ( |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1433 raw=0xd2a910 "\\bm\\100\\f\\3656574\\msg\\|s|0|ss|Offline") |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1434 at message.c:648 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1435 #8 0x00002b407810889c in msim_input_cb (gc_uncasted=0xcf92c0, |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1436 source=<value optimized out>, cond=<value optimized out>) at myspace.c:1478 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1437 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1438 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1439 Why is it crashing in msim_parse()'s g_strdup()? |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1440 */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1441 purple_debug_info("msim", "msim_uid2username_from_blist: %s's uid=%d (want %d)\n", |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1442 name, uid, wanted_uid); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1443 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1444 if (uid == wanted_uid) |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1445 { |
17669
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1446 gchar *ret; |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1447 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1448 ret = g_strdup(name); |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1449 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1450 g_slist_free(buddies); |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1451 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1452 return ret; |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1453 } |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1454 } |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1455 |
17669
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1456 g_slist_free(buddies); |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1457 return NULL; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1458 } |
17314
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1459 #endif |
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1460 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1461 /** Preprocess incoming messages, resolving as needed, calling msim_process() when ready to process. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1462 * |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1463 * @param session |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1464 * @param msg MsimMessage *, freed by caller. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1465 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1466 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1467 msim_preprocess_incoming(MsimSession *session, MsimMessage *msg) |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1468 { |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1469 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1470 g_return_val_if_fail(msg != NULL, FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1471 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1472 if (msim_msg_get(msg, "bm") && msim_msg_get(msg, "f")) |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1473 { |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1474 guint uid; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1475 const gchar *username; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1476 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1477 /* 'f' = userid message is from, in buddy messages */ |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1478 uid = msim_msg_get_integer(msg, "f"); |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1479 |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1480 /* TODO: Make caching work. Currently it is commented out because |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1481 * it crashes for unknown reasons, memory realloc error. */ |
17669
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1482 #if 0 |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1483 username = msim_uid2username_from_blist(session, uid); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1484 #else |
17669
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17668
diff
changeset
|
1485 username = NULL; |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1486 #endif |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1487 |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1488 if (username) |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1489 { |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1490 /* Know username already, use it. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1491 purple_debug_info("msim", "msim_preprocess_incoming: tagging with _username=%s\n", |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1492 username); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1493 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1494 return msim_process(session, msg); |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1495 |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1496 } else { |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1497 gchar *from; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1498 |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1499 /* Send lookup request. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1500 /* XXX: where is msim_msg_get_string() freed? make _strdup and _nonstrdup. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1501 purple_debug_info("msim", "msim_incoming: sending lookup, setting up callback\n"); |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1502 from = msim_msg_get_string(msg, "f"); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1503 msim_lookup_user(session, from, msim_incoming_resolved, msim_msg_clone(msg)); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
1504 g_free(from); |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1505 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1506 /* indeterminate */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1507 return TRUE; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1508 } |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1509 } else { |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1510 /* Nothing to resolve - send directly to processing. */ |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1511 return msim_process(session, msg); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1512 } |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1513 } |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1514 |
17687
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1515 /** Check if the connection is still alive, based on last communication. */ |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1516 gboolean |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1517 msim_check_alive(gpointer data) |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1518 { |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1519 MsimSession *session; |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1520 time_t delta; |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1521 gchar *errmsg; |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1522 |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1523 session = (MsimSession *)data; |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1524 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1525 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1526 |
17687
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1527 delta = time(NULL) - session->last_comm; |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1528 purple_debug_info("msim", "msim_check_alive: delta=%d\n", delta); |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1529 if (delta >= MSIM_KEEPALIVE_INTERVAL) |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1530 { |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1531 errmsg = g_strdup_printf(_("Connection to server lost (no data received within %d seconds)"), delta); |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1532 |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1533 purple_debug_info("msim", "msim_check_alive: %s > interval of %d, presumed dead\n", |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1534 errmsg, MSIM_KEEPALIVE_INTERVAL); |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1535 purple_connection_error(session->gc, errmsg); |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1536 |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1537 purple_notify_error(session->gc, NULL, errmsg, NULL); |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1538 |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1539 g_free(errmsg); |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1540 |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1541 return FALSE; |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1542 } |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1543 |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1544 return TRUE; |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1545 } |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1546 |
17681
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1547 /** Called when the session key arrives. */ |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1548 gboolean |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1549 msim_we_are_logged_on(MsimSession *session, MsimMessage *msg) |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1550 { |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1551 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1552 g_return_val_if_fail(msg != NULL, FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1553 |
17681
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1554 purple_connection_update_progress(session->gc, _("Connected"), 3, 4); |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1555 |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1556 session->sesskey = msim_msg_get_integer(msg, "sesskey"); |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1557 purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey); |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1558 |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1559 /* Comes with: proof,profileid,userid,uniquenick -- all same values |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1560 * some of the time, but can vary. This is our own user ID. */ |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1561 session->userid = msim_msg_get_integer(msg, "userid"); |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1562 |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1563 purple_connection_set_state(session->gc, PURPLE_CONNECTED); |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1564 |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1565 /* We now know are our own username, only after we're logged in.. |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1566 * which is weird, but happens because you login with your email |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1567 * address and not username. Will be freed in msim_session_destroy(). */ |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1568 session->username = msim_msg_get_string(msg, "uniquenick"); |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1569 |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1570 #ifdef MSIM_FAKE_SELF_ONLINE |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1571 /* Fake our self coming online. */ |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1572 purple_prpl_got_user_status(session->account, session->username, purple_primitive_get_id_from_type(PURPLE_STATUS_AVAILABLE), NULL); |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1573 #endif |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1574 |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1575 /* Set status depending on preference. */ |
17687
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1576 /* TODO: set status to current status, change status to hidden if sign on as hidden. |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1577 * Or remove this preference alltogether, and set status to current status? */ |
17686
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1578 msim_set_status_code(session, |
17681
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1579 purple_account_get_bool(session->account, "hidden", FALSE) |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1580 ? PURPLE_STATUS_INVISIBLE |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1581 : PURPLE_STATUS_AVAILABLE); |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1582 |
17687
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1583 purple_timeout_add(MSIM_KEEPALIVE_INTERVAL_CHECK, msim_check_alive, session); |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
1584 |
17681
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1585 return TRUE; |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1586 } |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1587 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1588 /** |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1589 * Process a message. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1590 * |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1591 * @param session |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1592 * @param msg A message from the server, ready for processing (possibly with resolved username information attached). Caller frees. |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1593 * |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1594 * @return TRUE if successful. FALSE if processing failed. |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1595 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1596 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1597 msim_process(MsimSession *session, MsimMessage *msg) |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1598 { |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1599 g_return_val_if_fail(session != NULL, FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1600 g_return_val_if_fail(msg != NULL, FALSE); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1601 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
1602 #ifdef MSIM_DEBUG_MSG |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
1603 { |
17298
9c5b1dc7404f
Change msim_msg_debug_string() to msim_msg_dump(), which prints the string
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17297
diff
changeset
|
1604 msim_msg_dump("ready to process: %s\n", msg); |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
1605 } |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
1606 #endif |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1607 |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1608 if (msim_msg_get(msg, "nc")) |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1609 { |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1610 return msim_login_challenge(session, msg); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1611 } else if (msim_msg_get(msg, "sesskey")) { |
17681
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
1612 return msim_we_are_logged_on(session, msg); |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1613 } else if (msim_msg_get(msg, "bm")) { |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1614 guint bm; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1615 |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1616 bm = msim_msg_get_integer(msg, "bm"); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1617 switch (bm) |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1618 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1619 case MSIM_BM_STATUS: |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1620 return msim_status(session, msg); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1621 case MSIM_BM_INSTANT: |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1622 return msim_incoming_im(session, msg); |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1623 case MSIM_BM_ACTION: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1624 return msim_incoming_action(session, msg); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1625 default: |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1626 /* Not really an IM, but show it for informational |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1627 * purposes during development. */ |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1628 return msim_incoming_im(session, msg); |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1629 } |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1630 } else if (msim_msg_get(msg, "rid")) { |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1631 return msim_process_reply(session, msg); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1632 } else if (msim_msg_get(msg, "error")) { |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1633 return msim_error(session, msg); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1634 } else if (msim_msg_get(msg, "ka")) { |
17650
0d799da3b893
Add TODO for msimprpl to timeout (handling keep-alives).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17649
diff
changeset
|
1635 /* TODO: Setup a timer, if keep-alive is not received within ~3 minutes, then |
0d799da3b893
Add TODO for msimprpl to timeout (handling keep-alives).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17649
diff
changeset
|
1636 * disconnect the user. As it stands, if Internet connection goes out (this |
0d799da3b893
Add TODO for msimprpl to timeout (handling keep-alives).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17649
diff
changeset
|
1637 * just happened here), msimprpl will appear to be connected forever, while |
0d799da3b893
Add TODO for msimprpl to timeout (handling keep-alives).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17649
diff
changeset
|
1638 * other plugins (oscar, etc.) will time out. Msimprpl should timeout too. */ |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1639 purple_debug_info("msim", "msim_process: got keep alive\n"); |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1640 return TRUE; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1641 } else { |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
1642 msim_unrecognized(session, msg, "in msim_process"); |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1643 return FALSE; |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1644 } |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1645 } |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
1646 |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1647 /** Store an field of information about a buddy. */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1648 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1649 msim_store_buddy_info_each(gpointer key, gpointer value, gpointer user_data) |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1650 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1651 PurpleBuddy *buddy; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1652 gchar *key_str, *value_str; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1653 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1654 buddy = (PurpleBuddy *)user_data; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1655 key_str = (gchar *)key; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1656 value_str = (gchar *)value; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1657 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1658 if (strcmp(key_str, "UserID") == 0 || |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1659 strcmp(key_str, "Age") == 0 || |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1660 strcmp(key_str, "TotalFriends") == 0) |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1661 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1662 /* Certain fields get set as integers, instead of strings, for |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1663 * convenience. May not be the best way to do it, but having at least |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1664 * UserID as an integer is convenient...until it overflows! */ |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1665 purple_blist_node_set_int(&buddy->node, key_str, atol(value_str)); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1666 } else { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1667 purple_blist_node_set_string(&buddy->node, key_str, value_str); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1668 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1669 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1670 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1671 /** Save buddy information to the buddy list from a user info reply message. |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1672 * |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1673 * @param session |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1674 * @param msg The user information reply, with any amount of information. |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1675 * |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1676 * The information is saved to the buddy's blist node, which ends up in blist.xml. |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1677 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1678 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1679 msim_store_buddy_info(MsimSession *session, MsimMessage *msg) |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1680 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1681 GHashTable *body; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1682 gchar *username, *body_str, *uid; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1683 PurpleBuddy *buddy; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1684 guint rid; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1685 |
17691
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1686 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1687 g_return_val_if_fail(msg != NULL, FALSE); |
b9fd55903979
General clean up and adding more error-checking.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17689
diff
changeset
|
1688 |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1689 rid = msim_msg_get_integer(msg, "rid"); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1690 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1691 g_return_val_if_fail(rid != 0, FALSE); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1692 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1693 body_str = msim_msg_get_string(msg, "body"); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1694 g_return_val_if_fail(body_str != NULL, FALSE); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1695 body = msim_parse_body(body_str); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1696 g_free(body_str); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1697 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1698 /* TODO: implement a better hash-like interface, and use it. */ |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1699 username = g_hash_table_lookup(body, "UserName"); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1700 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1701 if (!username) |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1702 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1703 purple_debug_info("msim", |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1704 "msim_process_reply: not caching body, no UserName\n"); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1705 return FALSE; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1706 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1707 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1708 uid = g_hash_table_lookup(body, "UserID"); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1709 g_return_val_if_fail(uid, FALSE); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1710 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1711 purple_debug_info("msim", "associating uid %d with username %s\n", uid, username); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1712 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1713 buddy = purple_find_buddy(session->account, username); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1714 if (buddy) |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1715 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1716 g_hash_table_foreach(body, msim_store_buddy_info_each, buddy); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1717 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1718 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1719 return TRUE; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1720 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1721 |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
1722 /** |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
1723 * Process a persistance message reply from the server. |
16394 | 1724 * |
1725 * @param session | |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1726 * @param msg Message reply from server. |
16394 | 1727 * |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1728 * @return TRUE if successful. |
16394 | 1729 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1730 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1731 msim_process_reply(MsimSession *session, MsimMessage *msg) |
16394 | 1732 { |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1733 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1734 g_return_val_if_fail(msg != NULL, FALSE); |
16394 | 1735 |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1736 if (msim_msg_get(msg, "rid")) /* msim_lookup_user sets callback for here */ |
16394 | 1737 { |
1738 MSIM_USER_LOOKUP_CB cb; | |
1739 gpointer data; | |
1740 guint rid; | |
17314
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
1741 |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1742 msim_store_buddy_info(session, msg); |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
1743 |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1744 rid = msim_msg_get_integer(msg, "rid"); |
16394 | 1745 |
1746 /* If a callback is registered for this userid lookup, call it. */ | |
1747 cb = g_hash_table_lookup(session->user_lookup_cb, GUINT_TO_POINTER(rid)); | |
1748 data = g_hash_table_lookup(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); | |
1749 | |
1750 if (cb) | |
1751 { | |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1752 purple_debug_info("msim", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1753 "msim_process_body: calling callback now\n"); |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1754 /* Clone message, so that the callback 'cb' can use it (needs to free it also). */ |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1755 cb(session, msim_msg_clone(msg), data); |
16394 | 1756 g_hash_table_remove(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
1757 g_hash_table_remove(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); | |
1758 } else { | |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1759 purple_debug_info("msim", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1760 "msim_process_body: no callback for rid %d\n", rid); |
16394 | 1761 } |
1762 } | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1763 |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1764 return TRUE; |
16394 | 1765 } |
1766 | |
1767 /** | |
1768 * Handle an error from the server. | |
1769 * | |
1770 * @param session | |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1771 * @param msg The message. |
16394 | 1772 * |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1773 * @return TRUE if successfully reported error. |
16394 | 1774 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1775 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1776 msim_error(MsimSession *session, MsimMessage *msg) |
16394 | 1777 { |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1778 gchar *errmsg, *full_errmsg; |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1779 guint err; |
16394 | 1780 |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1781 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1782 g_return_val_if_fail(msg != NULL, FALSE); |
16394 | 1783 |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1784 err = msim_msg_get_integer(msg, "err"); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1785 errmsg = msim_msg_get_string(msg, "errmsg"); |
16394 | 1786 |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1787 full_errmsg = g_strdup_printf(_("Protocol error, code %d: %s"), err, |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
1788 errmsg ? errmsg : "no 'errmsg' given"); |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1789 |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1790 g_free(errmsg); |
16394 | 1791 |
16396 | 1792 purple_debug_info("msim", "msim_error: %s\n", full_errmsg); |
16394 | 1793 |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
1794 purple_notify_error(session->account, g_strdup(_("MySpaceIM Error")), |
16394 | 1795 full_errmsg, NULL); |
1796 | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1797 /* Destroy session if fatal. */ |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
1798 if (msim_msg_get(msg, "fatal")) |
16394 | 1799 { |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1800 purple_debug_info("msim", "fatal error, closing\n"); |
16396 | 1801 purple_connection_error(session->gc, full_errmsg); |
16394 | 1802 } |
1803 | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1804 return TRUE; |
16394 | 1805 } |
1806 | |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1807 /** |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1808 * Process incoming status messages. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1809 * |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1810 * @param session |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1811 * @param msg Status update message. Caller frees. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1812 * |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1813 * @return TRUE if successful. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1814 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1815 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1816 msim_status(MsimSession *session, MsimMessage *msg) |
16394 | 1817 { |
16396 | 1818 PurpleBuddyList *blist; |
1819 PurpleBuddy *buddy; | |
1820 //PurpleStatus *status; | |
16394 | 1821 gchar **status_array; |
1822 GList *list; | |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1823 gchar *status_headline; |
16394 | 1824 gchar *status_str; |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1825 gint i, status_code, purple_status_code; |
16394 | 1826 gchar *username; |
1827 | |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1828 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1829 g_return_val_if_fail(msg != NULL, FALSE); |
17305
6476a55a9542
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17304
diff
changeset
|
1830 |
6476a55a9542
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17304
diff
changeset
|
1831 status_str = msim_msg_get_string(msg, "msg"); |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1832 g_return_val_if_fail(status_str != NULL, FALSE); |
16394 | 1833 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1834 msim_msg_dump("msim_status msg=%s\n", msg); |
16394 | 1835 |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1836 /* Helpfully looked up by msim_incoming_resolve() for us. */ |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1837 username = msim_msg_get_string(msg, "_username"); |
16394 | 1838 /* Note: DisplayName doesn't seem to be resolvable. It could be displayed on |
1839 * the buddy list, if the UserID was stored along with it. */ | |
1840 | |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1841 if (username == NULL) |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1842 { |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1843 g_free(status_str); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1844 g_return_val_if_fail(NULL, FALSE); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1845 } |
16394 | 1846 |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1847 purple_debug_info("msim", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1848 "msim_status_cb: updating status for <%s> to <%s>\n", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1849 username, status_str); |
16394 | 1850 |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1851 /* TODO: generic functions to split into a GList, part of MsimMessage */ |
16394 | 1852 status_array = g_strsplit(status_str, "|", 0); |
1853 for (list = NULL, i = 0; | |
1854 status_array[i]; | |
1855 i++) | |
1856 { | |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1857 /* Note: this adds the 0th ordinal too, which might not be a value |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1858 * at all (the 0 in the 0|1|2|3... status fields, but 0 always appears blank). |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1859 */ |
16394 | 1860 list = g_list_append(list, status_array[i]); |
1861 } | |
1862 | |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1863 /* Example fields: |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1864 * |s|0|ss|Offline |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1865 * |s|1|ss|:-)|ls||ip|0|p|0 |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1866 * |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1867 * TODO: write list support in MsimMessage, and use it here. |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1868 */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1869 |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1870 status_code = atoi(g_list_nth_data(list, MSIM_STATUS_ORDINAL_ONLINE)); |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1871 purple_debug_info("msim", "msim_status_cb: %s's status code = %d\n", username, status_code); |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1872 status_headline = g_list_nth_data(list, MSIM_STATUS_ORDINAL_HEADLINE); |
16394 | 1873 |
16396 | 1874 blist = purple_get_blist(); |
16394 | 1875 |
1876 /* Add buddy if not found */ | |
16396 | 1877 buddy = purple_find_buddy(session->account, username); |
16394 | 1878 if (!buddy) |
1879 { | |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1880 purple_debug_info("msim", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
1881 "msim_status: making new buddy for %s\n", username); |
16396 | 1882 buddy = purple_buddy_new(session->account, username, NULL); |
16394 | 1883 |
16396 | 1884 purple_blist_add_buddy(buddy, NULL, NULL, NULL); |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
1885 |
17299
c6305f8845d8
Add TODOs about username/email->userid resolution, use g_return_if_fail() in a few places.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17298
diff
changeset
|
1886 /* All buddies on list should have 'uid' integer associated with them. */ |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
1887 purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f")); |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
1888 |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
1889 msim_store_buddy_info(session, msg); |
16394 | 1890 } else { |
16396 | 1891 purple_debug_info("msim", "msim_status: found buddy %s\n", username); |
16394 | 1892 } |
1893 | |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
1894 purple_blist_node_set_string(&buddy->node, "Headline", status_headline); |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1895 |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1896 /* Set user status */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1897 switch (status_code) |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1898 { |
17680
d87916bd1d73
Fix email address.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17679
diff
changeset
|
1899 case MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN: |
17674
e24d44e3b6d2
Recognize online/away status of buddies on buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17673
diff
changeset
|
1900 purple_status_code = PURPLE_STATUS_OFFLINE; |
e24d44e3b6d2
Recognize online/away status of buddies on buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17673
diff
changeset
|
1901 break; |
e24d44e3b6d2
Recognize online/away status of buddies on buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17673
diff
changeset
|
1902 |
e24d44e3b6d2
Recognize online/away status of buddies on buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17673
diff
changeset
|
1903 case MSIM_STATUS_CODE_ONLINE: |
e24d44e3b6d2
Recognize online/away status of buddies on buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17673
diff
changeset
|
1904 purple_status_code = PURPLE_STATUS_AVAILABLE; |
e24d44e3b6d2
Recognize online/away status of buddies on buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17673
diff
changeset
|
1905 break; |
e24d44e3b6d2
Recognize online/away status of buddies on buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17673
diff
changeset
|
1906 |
e24d44e3b6d2
Recognize online/away status of buddies on buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17673
diff
changeset
|
1907 case MSIM_STATUS_CODE_AWAY: |
e24d44e3b6d2
Recognize online/away status of buddies on buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17673
diff
changeset
|
1908 purple_status_code = PURPLE_STATUS_AWAY; |
e24d44e3b6d2
Recognize online/away status of buddies on buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17673
diff
changeset
|
1909 break; |
e24d44e3b6d2
Recognize online/away status of buddies on buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17673
diff
changeset
|
1910 |
17686
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1911 case MSIM_STATUS_CODE_IDLE: |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1912 /* will be handled below */ |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1913 purple_status_code = -1; |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1914 break; |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1915 |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1916 default: |
17674
e24d44e3b6d2
Recognize online/away status of buddies on buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17673
diff
changeset
|
1917 purple_debug_info("msim", "msim_status_cb for %s, unknown status code %d, treating as available\n", |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1918 username, status_code); |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1919 purple_status_code = PURPLE_STATUS_AVAILABLE; |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
1920 } |
17670
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
1921 |
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
1922 #ifdef MSIM_FAKE_SELF_ONLINE |
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
1923 if (!strcmp(username, session->username) && purple_status_code == PURPLE_STATUS_OFFLINE) |
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
1924 { |
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
1925 /* Hack to ignore offline status notices on self. */ |
17686
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1926 } else if (status_code != MSIM_STATUS_CODE_IDLE) { |
17670
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
1927 #endif |
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
1928 purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL); |
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
1929 #ifdef MSIM_FAKE_SELF_ONLINE |
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
1930 } |
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
1931 #endif |
16394 | 1932 |
17686
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1933 if (status_code == MSIM_STATUS_CODE_IDLE) |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1934 { |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1935 purple_debug_info("msim", "msim_status: got idle: %s\n", username); |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1936 purple_prpl_got_user_idle(session->account, username, TRUE, time(NULL)); |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1937 } else { |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1938 /* All other statuses indicate going back to non-idle. */ |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1939 purple_prpl_got_user_idle(session->account, username, FALSE, time(NULL)); |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1940 } |
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
1941 |
16394 | 1942 g_strfreev(status_array); |
17305
6476a55a9542
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17304
diff
changeset
|
1943 g_free(status_str); |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
1944 g_free(username); |
16394 | 1945 g_list_free(list); |
1946 | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
1947 return TRUE; |
16394 | 1948 } |
1949 | |
17331
b33a6f16356a
Update several outdated TODO comments.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17330
diff
changeset
|
1950 /** Add a buddy to user's buddy list. */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1951 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
1952 msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1953 { |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1954 MsimSession *session; |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1955 MsimMessage *msg; |
17654
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1956 /* MsimMessage *msg_blocklist; */ |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1957 |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1958 session = (MsimSession *)gc->proto_data; |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1959 purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n", buddy->name, |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1960 group ? group->name : "(no group)"); |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1961 |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1962 msg = msim_msg_new(TRUE, |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1963 "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
17297
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17296
diff
changeset
|
1964 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1965 /* "newprofileid" will be inserted here with uid. */ |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1966 "reason", MSIM_TYPE_STRING, g_strdup(""), |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1967 NULL); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1968 |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1969 if (!msim_postprocess_outgoing(session, msg, buddy->name, "newprofileid", "reason")) |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1970 { |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1971 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed.")); |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1972 msim_msg_free(msg); |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
1973 return; |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1974 } |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1975 msim_msg_free(msg); |
17654
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1976 |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1977 /* TODO: if addbuddy fails ('error' message is returned), delete added buddy from |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1978 * buddy list since Purple adds it locally. */ |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
1979 |
17654
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1980 /* TODO: Update blocklist. */ |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
1981 #if 0 |
17654
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1982 msg_blocklist = msim_msg_new(TRUE, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1983 "persist", MSIM_TYPE_INTEGER, 1, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1984 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1985 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_PUT, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1986 "dsn", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_DSN, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1987 "lid", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_LID, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1988 /* TODO: Use msim_new_reply_callback to get rid. */ |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1989 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1990 "body", MSIM_TYPE_STRING, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1991 g_strdup_printf("ContactID=<uid>\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1992 "GroupName=%s\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1993 "Position=1000\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1994 "Visibility=1\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1995 "NickName=\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1996 "NameSelect=0", |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1997 "Friends" /*group->name*/ )); |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1998 |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
1999 if (!msim_postprocess_outgoing(session, msg, buddy->name, "body", NULL)) |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
2000 { |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
2001 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); |
17654
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
2002 msim_msg_free(msg_blocklist); |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2003 return; |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
2004 } |
17654
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17653
diff
changeset
|
2005 msim_msg_free(msg_blocklist); |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2006 #endif |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
2007 } |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
2008 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2009 /** Perform actual postprocessing on a message, adding userid as specified. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2010 * |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2011 * @param msg The message to postprocess. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2012 * @param uid_before Name of field where to insert new field before, or NULL for end. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2013 * @param uid_field_name Name of field to add uid to. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2014 * @param uid The userid to insert. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2015 * |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2016 * If the field named by uid_field_name already exists, then its string contents will |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2017 * be used for the field, except "<uid>" will be replaced by the userid. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2018 * |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2019 * If the field named by uid_field_name does not exist, it will be added before the |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2020 * field named by uid_before, as an integer, with the userid. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2021 * |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2022 * Does not handle sending, or scheduling userid lookup. For that, see msim_postprocess_outgoing(). |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2023 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2024 MsimMessage * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2025 msim_do_postprocessing(MsimMessage *msg, const gchar *uid_before, |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2026 const gchar *uid_field_name, guint uid) |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2027 { |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2028 purple_debug_info("msim", "msim_do_postprocessing called with ufn=%s, ub=%s, uid=%d\n", |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2029 uid_field_name, uid_before, uid); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2030 msim_msg_dump("msim_do_postprocessing msg: %s\n", msg); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2031 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2032 /* First, check - if the field already exists, treat it as a format string. */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2033 if (msim_msg_get(msg, uid_field_name)) |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2034 { |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2035 MsimMessageElement *elem; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2036 gchar *fmt_string; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2037 gchar *uid_str; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2038 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2039 /* Warning: this probably violates the encapsulation of MsimMessage */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2040 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2041 elem = msim_msg_get(msg, uid_field_name); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2042 g_return_val_if_fail(elem->type == MSIM_TYPE_STRING, NULL); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2043 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2044 /* Get the raw string, not with msim_msg_get_string() since that copies it. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2045 * Want the original string so can free it. */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2046 fmt_string = (gchar *)(elem->data); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2047 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2048 uid_str = g_strdup_printf("%d", uid); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2049 elem->data = str_replace(fmt_string, "<uid>", uid_str); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2050 g_free(uid_str); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2051 g_free(fmt_string); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2052 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2053 purple_debug_info("msim", "msim_postprocess_outgoing_cb: formatted new string, %s\n", |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2054 elem->data); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2055 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2056 } else { |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2057 /* Otherwise, insert new field into outgoing message. */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2058 msg = msim_msg_insert_before(msg, uid_before, uid_field_name, MSIM_TYPE_INTEGER, GUINT_TO_POINTER(uid)); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2059 } |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2060 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2061 return msg; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2062 } |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2063 |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2064 /** Callback for msim_postprocess_outgoing() to add a userid to a message, and send it (once receiving userid). |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2065 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2066 * @param session |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2067 * @param userinfo The user information reply message, containing the user ID |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2068 * @param data The message to postprocess and send. |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2069 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2070 * The data message should contain these fields: |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2071 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2072 * _uid_field_name: string, name of field to add with userid from userinfo message |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2073 * _uid_before: string, name of field before field to insert, or NULL for end |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2074 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2075 * |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2076 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2077 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2078 msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2079 { |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2080 gchar *body_str; |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2081 GHashTable *body; |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2082 gchar *uid, *uid_field_name, *uid_before; |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2083 MsimMessage *msg; |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2084 |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2085 msg = (MsimMessage *)data; |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2086 |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2087 msim_msg_dump("msim_postprocess_outgoing_cb() got msg=%s\n", msg); |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2088 |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2089 /* Obtain userid from userinfo message. */ |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2090 body_str = msim_msg_get_string(userinfo, "body"); |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2091 g_return_if_fail(body_str != NULL); |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2092 body = msim_parse_body(body_str); |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2093 g_free(body_str); |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2094 |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2095 uid = g_strdup(g_hash_table_lookup(body, "UserID")); |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2096 g_hash_table_destroy(body); |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2097 |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2098 uid_field_name = msim_msg_get_string(msg, "_uid_field_name"); |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2099 uid_before = msim_msg_get_string(msg, "_uid_before"); |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2100 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2101 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, atol(uid)); |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2102 |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2103 /* Send */ |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2104 if (!msim_msg_send(session, msg)) |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2105 { |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2106 purple_debug_info("msim", "msim_postprocess_outgoing_cb: sending failed for message: %s\n", msg); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2107 } |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2108 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2109 |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2110 /* Free field names AFTER sending message, because MsimMessage does NOT copy |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2111 * field names - instead, treats them as static strings (which they usually are). |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2112 */ |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2113 g_free(uid_field_name); |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2114 g_free(uid_before); |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2115 |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2116 //msim_msg_free(msg); |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2117 } |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2118 |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2119 /** Postprocess and send a message. |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2120 * |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2121 * @param session |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2122 * @param msg Message to postprocess. Will NOT be freed. |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2123 * @param username Username to resolve. Assumed to be a static string (will not be freed or copied). |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2124 * @param uid_field_name Name of new field to add, containing uid of username. Static string. |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2125 * @param uid_before Name of existing field to insert username field before. Static string. |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2126 * |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2127 * @return Postprocessed message. |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2128 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2129 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2130 msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg, |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2131 const gchar *username, const gchar *uid_field_name, |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2132 const gchar *uid_before) |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2133 { |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2134 PurpleBuddy *buddy; |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2135 guint uid; |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2136 gboolean rc; |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2137 |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2138 /* Store information for msim_postprocess_outgoing_cb(). */ |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2139 purple_debug_info("msim", "msim_postprocess_outgoing(u=%s,ufn=%s,ub=%s)\n", |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2140 username, uid_field_name, uid_before); |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2141 msim_msg_dump("msim_postprocess_outgoing: msg before=%s\n", msg); |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2142 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2143 msg = msim_msg_append(msg, "_uid_field_name", MSIM_TYPE_STRING, g_strdup(uid_field_name)); |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2144 msg = msim_msg_append(msg, "_uid_before", MSIM_TYPE_STRING, g_strdup(uid_before)); |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2145 |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2146 /* First, try the most obvious. If numeric userid is given, use that directly. */ |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2147 if (msim_is_userid(username)) |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2148 { |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2149 uid = atol(username); |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2150 } else { |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2151 /* Next, see if on buddy list and know uid. */ |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2152 buddy = purple_find_buddy(session->account, username); |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2153 if (buddy) |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2154 { |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2155 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2156 } else { |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2157 uid = 0; |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2158 } |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2159 |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2160 if (!buddy || !uid) |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2161 { |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2162 /* Don't have uid offhand - need to ask for it, and wait until hear back before sending. */ |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2163 purple_debug_info("msim", ">>> msim_postprocess_outgoing: couldn't find username %s in blist\n", |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2164 username); |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2165 msim_msg_dump("msim_postprocess_outgoing - scheduling lookup, msg=%s\n", msg); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2166 /* TODO: where is cloned message freed? Should be in _cb. */ |
17311
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17310
diff
changeset
|
2167 msim_lookup_user(session, username, msim_postprocess_outgoing_cb, msim_msg_clone(msg)); |
17310
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2168 return TRUE; /* not sure of status yet - haven't sent! */ |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17309
diff
changeset
|
2169 } |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2170 } |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2171 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2172 /* Already have uid, postprocess and send msg immediately. */ |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2173 purple_debug_info("msim", "msim_postprocess_outgoing: found username %s has uid %d\n", |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2174 username, uid); |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2175 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2176 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, uid); |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2177 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2178 msim_msg_dump("msim_postprocess_outgoing: msg after (uid immediate)=%s\n", msg); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2179 |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2180 rc = msim_msg_send(session, msg); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2181 |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2182 //msim_msg_free(msg); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2183 |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2184 return rc; |
17309
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2185 } |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17308
diff
changeset
|
2186 |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2187 /** Remove a buddy from the user's buddy list. */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2188 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2189 msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2190 { |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2191 MsimSession *session; |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2192 MsimMessage *delbuddy_msg; |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2193 MsimMessage *persist_msg; |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2194 MsimMessage *blocklist_msg; |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2195 |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2196 session = (MsimSession *)gc->proto_data; |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2197 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2198 delbuddy_msg = msim_msg_new(TRUE, |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2199 "delbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
17297
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17296
diff
changeset
|
2200 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2201 /* 'delprofileid' with uid will be inserted here. */ |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2202 NULL); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2203 /* TODO: free msg */ |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2204 if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL)) |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2205 { |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2206 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed")); |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2207 return; |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2208 } |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2209 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2210 persist_msg = msim_msg_new(TRUE, |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2211 "persist", MSIM_TYPE_INTEGER, 1, |
17297
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17296
diff
changeset
|
2212 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2213 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE, |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2214 "dsn", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_DSN, |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2215 "lid", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_LID, |
17317
e9dfd3a5d4b6
Remove msim_get_own_uid{,_cb}() - it is not needed, since the login
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17316
diff
changeset
|
2216 "uid", MSIM_TYPE_INTEGER, session->userid, |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2217 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2218 /* <uid> will be replaced by postprocessing */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2219 "body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"), |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2220 NULL); |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2221 |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2222 /* TODO: free msg */ |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2223 if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL)) |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2224 { |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2225 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed")); |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2226 return; |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2227 } |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2228 |
17319
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2229 blocklist_msg = msim_msg_new(TRUE, |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2230 "blocklist", MSIM_TYPE_BOOLEAN, TRUE, |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2231 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2232 /* TODO: MsimMessage lists */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2233 "idlist", MSIM_TYPE_STRING, g_strdup("a-|<uid>|b-|<uid>"), |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2234 NULL); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2235 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2236 if (!msim_postprocess_outgoing(session, blocklist_msg, buddy->name, "idlist", NULL)) |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2237 { |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2238 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("blocklist command failed")); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2239 return; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17317
diff
changeset
|
2240 } |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2241 } |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2242 |
17324
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
2243 /** Return whether the buddy can be messaged while offline. |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
2244 * |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2245 * The protocol supports offline messages in just the same way as online |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2246 * messages. |
17324
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
2247 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2248 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2249 msim_offline_message(const PurpleBuddy *buddy) |
17324
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
2250 { |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
2251 return TRUE; |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
2252 } |
16394 | 2253 |
2254 /** | |
2255 * Callback when input available. | |
2256 * | |
16396 | 2257 * @param gc_uncasted A PurpleConnection pointer. |
16394 | 2258 * @param source File descriptor. |
16396 | 2259 * @param cond PURPLE_INPUT_READ |
16394 | 2260 * |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
2261 * Reads the input, and calls msim_preprocess_incoming() to handle it. |
16394 | 2262 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2263 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2264 msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond) |
16394 | 2265 { |
16396 | 2266 PurpleConnection *gc; |
2267 PurpleAccount *account; | |
16394 | 2268 MsimSession *session; |
2269 gchar *end; | |
2270 int n; | |
2271 | |
2272 g_return_if_fail(gc_uncasted != NULL); | |
2273 g_return_if_fail(source >= 0); /* Note: 0 is a valid fd */ | |
2274 | |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
2275 gc = (PurpleConnection *)(gc_uncasted); |
16396 | 2276 account = purple_connection_get_account(gc); |
16394 | 2277 session = gc->proto_data; |
2278 | |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
2279 g_return_if_fail(cond == PURPLE_INPUT_READ); |
17314
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
2280 g_return_if_fail(MSIM_SESSION_VALID(session)); |
16394 | 2281 |
17687
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
2282 /* Mark down that we got data, so don't timeout. */ |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
2283 session->last_comm = time(NULL); |
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
2284 |
16394 | 2285 /* Only can handle so much data at once... |
2286 * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE. | |
2287 * Should be large enough to hold the largest protocol message. | |
2288 */ | |
2289 if (session->rxoff == MSIM_READ_BUF_SIZE) | |
2290 { | |
16396 | 2291 purple_debug_error("msim", "msim_input_cb: %d-byte read buffer full!\n", |
16394 | 2292 MSIM_READ_BUF_SIZE); |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
2293 purple_connection_error(gc, _("Read buffer full")); |
16394 | 2294 return; |
2295 } | |
2296 | |
16396 | 2297 purple_debug_info("msim", "buffer at %d (max %d), reading up to %d\n", |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
2298 session->rxoff, MSIM_READ_BUF_SIZE, |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
2299 MSIM_READ_BUF_SIZE - session->rxoff); |
16394 | 2300 |
2301 /* Read into buffer. On Win32, need recv() not read(). session->fd also holds | |
2302 * the file descriptor, but it sometimes differs from the 'source' parameter. | |
2303 */ | |
2304 n = recv(session->fd, session->rxbuf + session->rxoff, MSIM_READ_BUF_SIZE - session->rxoff, 0); | |
2305 | |
2306 if (n < 0 && errno == EAGAIN) | |
2307 { | |
2308 return; | |
2309 } | |
2310 else if (n < 0) | |
2311 { | |
16396 | 2312 purple_debug_error("msim", "msim_input_cb: read error, ret=%d, " |
16394 | 2313 "error=%s, source=%d, fd=%d (%X))\n", |
2314 n, strerror(errno), source, session->fd, session->fd); | |
17663
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2315 purple_connection_error(gc, _("Read error")); |
16394 | 2316 return; |
2317 } | |
2318 else if (n == 0) | |
2319 { | |
16396 | 2320 purple_debug_info("msim", "msim_input_cb: server disconnected\n"); |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
2321 purple_connection_error(gc, _("Server has disconnected")); |
16394 | 2322 return; |
2323 } | |
2324 | |
2325 /* Null terminate */ | |
2326 session->rxbuf[session->rxoff + n] = 0; | |
2327 | |
17672
d43314277ccc
Remove check in msim_input_cb() for embedded nulls. May be causing #1990.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17670
diff
changeset
|
2328 #ifdef MSIM_CHECK_EMBEDDED_NULLS |
16394 | 2329 /* Check for embedded NULs. I don't handle them, and they shouldn't occur. */ |
2330 if (strlen(session->rxbuf + session->rxoff) != n) | |
2331 { | |
2332 /* Occurs after login, but it is not a null byte. */ | |
16396 | 2333 purple_debug_info("msim", "msim_input_cb: strlen=%d, but read %d bytes" |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
2334 "--null byte encountered?\n", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
2335 strlen(session->rxbuf + session->rxoff), n); |
16396 | 2336 //purple_connection_error(gc, "Invalid message - null byte on input"); |
16394 | 2337 return; |
2338 } | |
17672
d43314277ccc
Remove check in msim_input_cb() for embedded nulls. May be causing #1990.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17670
diff
changeset
|
2339 #endif |
16394 | 2340 |
2341 session->rxoff += n; | |
16396 | 2342 purple_debug_info("msim", "msim_input_cb: read=%d\n", n); |
16394 | 2343 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
2344 #ifdef MSIM_DEBUG_RXBUF |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
2345 purple_debug_info("msim", "buf=<%s>\n", session->rxbuf); |
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
2346 #endif |
16394 | 2347 |
2348 /* Look for \\final\\ end markers. If found, process message. */ | |
2349 while((end = strstr(session->rxbuf, MSIM_FINAL_STRING))) | |
2350 { | |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
2351 MsimMessage *msg; |
16394 | 2352 |
16725
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16723
diff
changeset
|
2353 #ifdef MSIM_DEBUG_RXBUF |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
2354 purple_debug_info("msim", "in loop: buf=<%s>\n", session->rxbuf); |
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
2355 #endif |
16394 | 2356 *end = 0; |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
2357 msg = msim_parse(g_strdup(session->rxbuf)); |
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
2358 if (!msg) |
16394 | 2359 { |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
2360 purple_debug_info("msim", "msim_input_cb: couldn't parse <%s>\n", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
2361 session->rxbuf); |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
2362 purple_connection_error(gc, _("Unparseable message")); |
16394 | 2363 } |
2364 else | |
2365 { | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
2366 /* Process message and then free it (processing function should |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
2367 * clone message if it wants to keep it afterwards.) */ |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
2368 if (!msim_preprocess_incoming(session, msg)) |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
2369 { |
17306
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17305
diff
changeset
|
2370 msim_msg_dump("msim_input_cb: preprocessing message failed on msg: %s\n", msg); |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
2371 } |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
2372 msim_msg_free(msg); |
16394 | 2373 } |
2374 | |
2375 /* Move remaining part of buffer to beginning. */ | |
2376 session->rxoff -= strlen(session->rxbuf) + strlen(MSIM_FINAL_STRING); | |
2377 memmove(session->rxbuf, end + strlen(MSIM_FINAL_STRING), | |
2378 MSIM_READ_BUF_SIZE - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf)); | |
2379 | |
2380 /* Clear end of buffer */ | |
2381 //memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf)); | |
2382 } | |
2383 } | |
2384 | |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2385 /* Setup a callback, to be called when a reply is received with the returned rid. |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2386 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2387 * @param cb The callback, an MSIM_USER_LOOKUP_CB. |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2388 * @param data Arbitrary user data to be passed to callback (probably an MsimMessage *). |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2389 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2390 * @return The request/reply ID, used to link replies with requests. Put the rid in your request. |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2391 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2392 * TODO: Make more generic and more specific: |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2393 * 1) MSIM_USER_LOOKUP_CB - make it for PERSIST_REPLY, not just user lookup |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2394 * 2) data - make it an MsimMessage? |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2395 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2396 guint |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2397 msim_new_reply_callback(MsimSession *session, MSIM_USER_LOOKUP_CB cb, |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2398 gpointer data) |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2399 { |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2400 guint rid; |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2401 |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2402 rid = session->next_rid++; |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2403 |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2404 g_hash_table_insert(session->user_lookup_cb, GUINT_TO_POINTER(rid), cb); |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2405 g_hash_table_insert(session->user_lookup_cb_data, GUINT_TO_POINTER(rid), data); |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2406 |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2407 return rid; |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2408 } |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2409 |
16394 | 2410 /** |
2411 * Callback when connected. Sets up input handlers. | |
2412 * | |
16396 | 2413 * @param data A PurpleConnection pointer. |
16394 | 2414 * @param source File descriptor. |
2415 * @param error_message | |
2416 */ | |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2417 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2418 msim_connect_cb(gpointer data, gint source, const gchar *error_message) |
16394 | 2419 { |
16396 | 2420 PurpleConnection *gc; |
16394 | 2421 MsimSession *session; |
2422 | |
2423 g_return_if_fail(data != NULL); | |
2424 | |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
2425 gc = (PurpleConnection *)data; |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2426 session = (MsimSession *)gc->proto_data; |
16394 | 2427 |
2428 if (source < 0) | |
2429 { | |
16728
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16727
diff
changeset
|
2430 purple_connection_error(gc, _("Couldn't connect to host")); |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
2431 purple_connection_error(gc, g_strdup_printf( |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
2432 _("Couldn't connect to host: %s (%d)"), |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
2433 error_message ? error_message : "no message given", |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
2434 source)); |
16394 | 2435 return; |
2436 } | |
2437 | |
2438 session->fd = source; | |
2439 | |
16396 | 2440 gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc); |
17670
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
2441 |
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
2442 |
16394 | 2443 } |
2444 | |
2445 /* Session methods */ | |
2446 | |
2447 /** | |
2448 * Create a new MSIM session. | |
2449 * | |
2450 * @param acct The account to create the session from. | |
2451 * | |
2452 * @return Pointer to a new session. Free with msim_session_destroy. | |
2453 */ | |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2454 MsimSession * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2455 msim_session_new(PurpleAccount *acct) |
16394 | 2456 { |
2457 MsimSession *session; | |
2458 | |
2459 g_return_val_if_fail(acct != NULL, NULL); | |
2460 | |
2461 session = g_new0(MsimSession, 1); | |
2462 | |
2463 session->magic = MSIM_SESSION_STRUCT_MAGIC; | |
2464 session->account = acct; | |
16396 | 2465 session->gc = purple_account_get_connection(acct); |
17670
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
2466 session->sesskey = 0; |
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
2467 session->userid = 0; |
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
2468 session->username = NULL; |
16394 | 2469 session->fd = -1; |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
2470 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
2471 /* TODO: Remove. */ |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
2472 session->user_lookup_cb = g_hash_table_new_full(g_direct_hash, |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
2473 g_direct_equal, NULL, NULL); /* do NOT free function pointers! (values) */ |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
2474 session->user_lookup_cb_data = g_hash_table_new_full(g_direct_hash, |
17303
ceba4fc06c41
Change msim_send_im_by_userid_cb() to msim_send_im_cb(), and remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17300
diff
changeset
|
2475 g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are, |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
2476 they could be integers inside gpointers |
17303
ceba4fc06c41
Change msim_send_im_by_userid_cb() to msim_send_im_cb(), and remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17300
diff
changeset
|
2477 or strings, so I don't freed them. |
17280
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17266
diff
changeset
|
2478 Figure this out, once free cache. */ |
16394 | 2479 session->rxoff = 0; |
2480 session->rxbuf = g_new0(gchar, MSIM_READ_BUF_SIZE); | |
16407
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
2481 session->next_rid = 1; |
17687
d0c8b7748065
Add msim_check_alive(), called every MSIM_KEEPALIVE_INTERVAL_CHECK milliseconds,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17686
diff
changeset
|
2482 session->last_comm = time(NULL); |
16394 | 2483 |
2484 return session; | |
2485 } | |
2486 | |
2487 /** | |
2488 * Free a session. | |
2489 * | |
2490 * @param session The session to destroy. | |
2491 */ | |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2492 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2493 msim_session_destroy(MsimSession *session) |
16394 | 2494 { |
2495 g_return_if_fail(MSIM_SESSION_VALID(session)); | |
17663
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2496 |
16394 | 2497 session->magic = -1; |
2498 | |
2499 g_free(session->rxbuf); | |
17670
7e4e3f6582d2
Add MSIM_FAKE_SELF_ONLINE preprocessor definition (which I define) to fake
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17669
diff
changeset
|
2500 g_free(session->username); |
16394 | 2501 |
17313
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
2502 /* TODO: Remove. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
2503 g_hash_table_destroy(session->user_lookup_cb); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
2504 g_hash_table_destroy(session->user_lookup_cb_data); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17312
diff
changeset
|
2505 |
16394 | 2506 g_free(session); |
2507 } | |
16405
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16404
diff
changeset
|
2508 |
16394 | 2509 /** |
2510 * Close the connection. | |
2511 * | |
2512 * @param gc The connection. | |
2513 */ | |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2514 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2515 msim_close(PurpleConnection *gc) |
16394 | 2516 { |
17314
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
2517 MsimSession *session; |
17293
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17291
diff
changeset
|
2518 |
17663
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2519 if (gc == NULL) |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2520 return; |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2521 |
17314
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
2522 session = (MsimSession *)gc->proto_data; |
17663
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2523 if (session == NULL) |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2524 return; |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2525 |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2526 gc->proto_data = NULL; |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2527 |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2528 if (!MSIM_SESSION_VALID(session)) |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2529 return; |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2530 |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2531 if (session->gc->inpa) |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2532 purple_input_remove(session->gc->inpa); |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17662
diff
changeset
|
2533 |
17314
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17313
diff
changeset
|
2534 msim_session_destroy(session); |
16394 | 2535 } |
2536 | |
2537 | |
2538 /** | |
2539 * Check if a string is a userid (all numeric). | |
2540 * | |
2541 * @param user The user id, email, or name. | |
2542 * | |
2543 * @return TRUE if is userid, FALSE if not. | |
2544 */ | |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2545 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2546 msim_is_userid(const gchar *user) |
16394 | 2547 { |
2548 g_return_val_if_fail(user != NULL, FALSE); | |
2549 | |
2550 return strspn(user, "0123456789") == strlen(user); | |
2551 } | |
2552 | |
2553 /** | |
2554 * Check if a string is an email address (contains an @). | |
2555 * | |
2556 * @param user The user id, email, or name. | |
2557 * | |
2558 * @return TRUE if is an email, FALSE if not. | |
2559 * | |
2560 * This function is not intended to be used as a generic | |
2561 * means of validating email addresses, but to distinguish | |
2562 * between a user represented by an email address from | |
2563 * other forms of identification. | |
2564 */ | |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2565 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2566 msim_is_email(const gchar *user) |
16394 | 2567 { |
2568 g_return_val_if_fail(user != NULL, FALSE); | |
2569 | |
2570 return strchr(user, '@') != NULL; | |
2571 } | |
2572 | |
2573 | |
2574 /** | |
2575 * Asynchronously lookup user information, calling callback when receive result. | |
2576 * | |
2577 * @param session | |
17656
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17655
diff
changeset
|
2578 * @param user The user id, email address, or username. Not freed. |
16394 | 2579 * @param cb Callback, called with user information when available. |
2580 * @param data An arbitray data pointer passed to the callback. | |
2581 */ | |
17299
c6305f8845d8
Add TODOs about username/email->userid resolution, use g_return_if_fail() in a few places.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17298
diff
changeset
|
2582 /* TODO: change to not use callbacks */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2583 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2584 msim_lookup_user(MsimSession *session, const gchar *user, |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2585 MSIM_USER_LOOKUP_CB cb, gpointer data) |
16394 | 2586 { |
2587 gchar *field_name; | |
2588 guint rid, cmd, dsn, lid; | |
2589 | |
2590 g_return_if_fail(MSIM_SESSION_VALID(session)); | |
2591 g_return_if_fail(user != NULL); | |
2592 g_return_if_fail(cb != NULL); | |
2593 | |
17266
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
2594 purple_debug_info("msim", "msim_lookup_userid: " |
16404
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16402
diff
changeset
|
2595 "asynchronously looking up <%s>\n", user); |
16394 | 2596 |
17312
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2597 msim_msg_dump("msim_lookup_user: data=%s\n", (MsimMessage *)data); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17311
diff
changeset
|
2598 |
16394 | 2599 /* Setup callback. Response will be associated with request using 'rid'. */ |
17316
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17315
diff
changeset
|
2600 rid = msim_new_reply_callback(session, cb, data); |
16394 | 2601 |
2602 /* Send request */ | |
2603 | |
17286
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2604 cmd = MSIM_CMD_GET; |
16394 | 2605 |
2606 if (msim_is_userid(user)) | |
2607 { | |
2608 field_name = "UserID"; | |
17286
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2609 dsn = MG_MYSPACE_INFO_BY_ID_DSN; |
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2610 lid = MG_MYSPACE_INFO_BY_ID_LID; |
16394 | 2611 } else if (msim_is_email(user)) { |
2612 field_name = "Email"; | |
17286
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2613 dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2614 lid = MG_MYSPACE_INFO_BY_STRING_LID; |
16394 | 2615 } else { |
2616 field_name = "UserName"; | |
17286
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2617 dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17285
diff
changeset
|
2618 lid = MG_MYSPACE_INFO_BY_STRING_LID; |
16394 | 2619 } |
2620 | |
2621 | |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
2622 g_return_if_fail(msim_send(session, |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2623 "persist", MSIM_TYPE_INTEGER, 1, |
17297
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17296
diff
changeset
|
2624 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2625 "cmd", MSIM_TYPE_INTEGER, 1, |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2626 "dsn", MSIM_TYPE_INTEGER, dsn, |
17317
e9dfd3a5d4b6
Remove msim_get_own_uid{,_cb}() - it is not needed, since the login
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17316
diff
changeset
|
2627 "uid", MSIM_TYPE_INTEGER, session->userid, |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2628 "lid", MSIM_TYPE_INTEGER, lid, |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2629 "rid", MSIM_TYPE_INTEGER, rid, |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2630 /* TODO: dictionary field type */ |
17676
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
2631 "body", MSIM_TYPE_STRING, |
e7612bd6835b
Be more defensive about null pointers, especially null strings in %s format
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17674
diff
changeset
|
2632 g_strdup_printf("%s=%s", field_name, user), |
17291
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17290
diff
changeset
|
2633 NULL)); |
16394 | 2634 } |
2635 | |
2636 | |
2637 /** | |
2638 * Obtain the status text for a buddy. | |
2639 * | |
2640 * @param buddy The buddy to obtain status text for. | |
2641 * | |
17326
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17325
diff
changeset
|
2642 * @return Status text, or NULL if error. Caller g_free()'s. |
16394 | 2643 * |
2644 */ | |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2645 char * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2646 msim_status_text(PurpleBuddy *buddy) |
16394 | 2647 { |
2648 MsimSession *session; | |
17332
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2649 const gchar *display_name, *headline; |
16394 | 2650 |
2651 g_return_val_if_fail(buddy != NULL, NULL); | |
2652 | |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
2653 session = (MsimSession *)buddy->account->gc->proto_data; |
16727
cd4a6bd9f69e
Use g_return_if_fail() instead of g_assert(), as to not crash the whole program.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16726
diff
changeset
|
2654 g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL); |
16394 | 2655 |
17332
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2656 display_name = headline = NULL; |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2657 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2658 /* Retrieve display name and/or headline, depending on user preference. */ |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2659 if (purple_account_get_bool(session->account, "show_display_name", TRUE)) |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2660 { |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2661 display_name = purple_blist_node_get_string(&buddy->node, "DisplayName"); |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2662 } |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2663 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2664 if (purple_account_get_bool(session->account, "show_headline", FALSE)) |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2665 { |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2666 headline = purple_blist_node_get_string(&buddy->node, "Headline"); |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2667 } |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2668 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2669 /* Return appropriate combination of display name and/or headline, or neither. */ |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2670 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2671 if (display_name && headline) |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2672 return g_strconcat(display_name, " ", headline, NULL); |
16394 | 2673 |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2674 if (display_name) |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2675 return g_strdup(display_name); |
17332
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2676 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2677 if (headline) |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2678 return g_strdup(headline); |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2679 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
2680 return NULL; |
16394 | 2681 } |
2682 | |
2683 /** | |
2684 * Obtain the tooltip text for a buddy. | |
2685 * | |
2686 * @param buddy Buddy to obtain tooltip text on. | |
2687 * @param user_info Variable modified to have the tooltip text. | |
2688 * @param full TRUE if should obtain full tooltip text. | |
2689 * | |
2690 */ | |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2691 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2692 msim_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2693 gboolean full) |
16394 | 2694 { |
17673
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2695 const gchar *str, *str2; |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2696 gint n; |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2697 |
16394 | 2698 g_return_if_fail(buddy != NULL); |
2699 g_return_if_fail(user_info != NULL); | |
2700 | |
16396 | 2701 if (PURPLE_BUDDY_IS_ONLINE(buddy)) |
16394 | 2702 { |
2703 MsimSession *session; | |
2704 | |
16738
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
2705 session = (MsimSession *)buddy->account->gc->proto_data; |
16394 | 2706 |
16727
cd4a6bd9f69e
Use g_return_if_fail() instead of g_assert(), as to not crash the whole program.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16726
diff
changeset
|
2707 g_return_if_fail(MSIM_SESSION_VALID(session)); |
16394 | 2708 |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2709 /* TODO: if (full), do something different */ |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2710 |
17673
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2711 /* Useful to identify the account the tooltip refers to. |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2712 * Other prpls show this. */ |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2713 str = purple_blist_node_get_string(&buddy->node, "UserName"); |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2714 if (str) |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2715 purple_notify_user_info_add_pair(user_info, _("User Name"), str); |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2716 |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2717 /* a/s/l...the vitals */ |
17673
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2718 n = purple_blist_node_get_int(&buddy->node, "Age"); |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2719 if (n) |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2720 purple_notify_user_info_add_pair(user_info, _("Age"), |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2721 g_strdup_printf("%d", n)); |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2722 |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2723 str = purple_blist_node_get_string(&buddy->node, "Gender"); |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2724 if (str) |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2725 purple_notify_user_info_add_pair(user_info, _("Gender"), str); |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2726 |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2727 str = purple_blist_node_get_string(&buddy->node, "Location"); |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2728 if (str) |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2729 purple_notify_user_info_add_pair(user_info, _("Location"), str); |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2730 |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2731 /* Other information */ |
17673
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2732 str = purple_blist_node_get_string(&buddy->node, "Headline"); |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2733 if (str) |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2734 purple_notify_user_info_add_pair(user_info, _("Headline"), str); |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2735 |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2736 str = purple_blist_node_get_string(&buddy->node, "BandName"); |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2737 str2 = purple_blist_node_get_string(&buddy->node, "SongName"); |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2738 if (str || str2) |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2739 purple_notify_user_info_add_pair(user_info, _("Song"), |
17323
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17322
diff
changeset
|
2740 g_strdup_printf("%s - %s", |
17673
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2741 str ? str : _("Unknown Artist"), |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2742 str2 ? str2 : _("Unknown Song"))); |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2743 |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2744 n = purple_blist_node_get_int(&buddy->node, "TotalFriends"); |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2745 if (n) |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2746 purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
d125c3562280
In msim_tooltip_text, do not try to display items with no value. In Linux,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17672
diff
changeset
|
2747 g_strdup_printf("%d", n)); |
17322
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17320
diff
changeset
|
2748 |
16394 | 2749 } |
2750 } | |
2751 | |
16396 | 2752 /** Callbacks called by Purple, to access this plugin. */ |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2753 PurplePluginProtocolInfo prpl_info = |
16394 | 2754 { |
17678
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
2755 /* options */ |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
2756 OPT_PROTO_USE_POINTSIZE /* specify font size in sane point size */ |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
2757 /* | OPT_PROTO_MAIL_CHECK - TODO: myspace will notify of mail */ |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
2758 /* | OPT_PROTO_IM_IMAGE - TODO: direct images. */ |
51f54868bbad
Fix typo to allow font face to be displayed correctly on incoming messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17677
diff
changeset
|
2759 , |
16394 | 2760 NULL, /* user_splits */ |
2761 NULL, /* protocol_options */ | |
2762 NO_BUDDY_ICONS, /* icon_spec - TODO: eventually should add this */ | |
2763 msim_list_icon, /* list_icon */ | |
2764 NULL, /* list_emblems */ | |
2765 msim_status_text, /* status_text */ | |
2766 msim_tooltip_text, /* tooltip_text */ | |
2767 msim_status_types, /* status_types */ | |
2768 NULL, /* blist_node_menu */ | |
2769 NULL, /* chat_info */ | |
2770 NULL, /* chat_info_defaults */ | |
2771 msim_login, /* login */ | |
2772 msim_close, /* close */ | |
2773 msim_send_im, /* send_im */ | |
2774 NULL, /* set_info */ | |
17290
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17289
diff
changeset
|
2775 msim_send_typing, /* send_typing */ |
17325
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17324
diff
changeset
|
2776 msim_get_info, /* get_info */ |
17679
608e4b47dfae
Allow setting status to away or online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17678
diff
changeset
|
2777 msim_set_status, /* set_status */ |
17686
87b77f1ea086
Add support for idle.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17685
diff
changeset
|
2778 msim_set_idle, /* set_idle */ |
16394 | 2779 NULL, /* change_passwd */ |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2780 msim_add_buddy, /* add_buddy */ |
16394 | 2781 NULL, /* add_buddies */ |
17296
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17293
diff
changeset
|
2782 msim_remove_buddy, /* remove_buddy */ |
16394 | 2783 NULL, /* remove_buddies */ |
2784 NULL, /* add_permit */ | |
2785 NULL, /* add_deny */ | |
2786 NULL, /* rem_permit */ | |
2787 NULL, /* rem_deny */ | |
2788 NULL, /* set_permit_deny */ | |
2789 NULL, /* join_chat */ | |
2790 NULL, /* reject chat invite */ | |
2791 NULL, /* get_chat_name */ | |
2792 NULL, /* chat_invite */ | |
2793 NULL, /* chat_leave */ | |
2794 NULL, /* chat_whisper */ | |
2795 NULL, /* chat_send */ | |
2796 NULL, /* keepalive */ | |
2797 NULL, /* register_user */ | |
2798 NULL, /* get_cb_info */ | |
2799 NULL, /* get_cb_away */ | |
2800 NULL, /* alias_buddy */ | |
2801 NULL, /* group_buddy */ | |
2802 NULL, /* rename_group */ | |
2803 NULL, /* buddy_free */ | |
2804 NULL, /* convo_closed */ | |
2805 NULL, /* normalize */ | |
2806 NULL, /* set_buddy_icon */ | |
2807 NULL, /* remove_group */ | |
2808 NULL, /* get_cb_real_name */ | |
2809 NULL, /* set_chat_topic */ | |
2810 NULL, /* find_blist_chat */ | |
2811 NULL, /* roomlist_get_list */ | |
2812 NULL, /* roomlist_cancel */ | |
2813 NULL, /* roomlist_expand_category */ | |
2814 NULL, /* can_receive_file */ | |
2815 NULL, /* send_file */ | |
2816 NULL, /* new_xfer */ | |
17324
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
2817 msim_offline_message, /* offline_message */ |
16394 | 2818 NULL, /* whiteboard_prpl_ops */ |
17660
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17659
diff
changeset
|
2819 msim_send_really_raw, /* send_raw */ |
16723
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2820 NULL, /* roomlist_room_serialize */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2821 NULL, /* _purple_reserved1 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2822 NULL, /* _purple_reserved2 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2823 NULL, /* _purple_reserved3 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2824 NULL /* _purple_reserved4 */ |
16394 | 2825 }; |
2826 | |
2827 | |
2828 | |
2829 /** Based on MSN's plugin info comments. */ | |
16736
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16735
diff
changeset
|
2830 PurplePluginInfo info = |
16394 | 2831 { |
16396 | 2832 PURPLE_PLUGIN_MAGIC, |
2833 PURPLE_MAJOR_VERSION, | |
2834 PURPLE_MINOR_VERSION, | |
17289
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
2835 PURPLE_PLUGIN_PROTOCOL, /**< type */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
2836 NULL, /**< ui_requirement */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
2837 0, /**< flags */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
2838 NULL, /**< dependencies */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17287
diff
changeset
|
2839 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
16394 | 2840 |
2841 "prpl-myspace", /**< id */ | |
2842 "MySpaceIM", /**< name */ | |
17685 | 2843 "0.10", /**< version */ |
16394 | 2844 /** summary */ |
2845 "MySpaceIM Protocol Plugin", | |
2846 /** description */ | |
2847 "MySpaceIM Protocol Plugin", | |
17680
d87916bd1d73
Fix email address.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17679
diff
changeset
|
2848 "Jeff Connelly <jeff2@soc.pidgin.im>", /**< author */ |
16394 | 2849 "http://developer.pidgin.im/wiki/MySpaceIM/", /**< homepage */ |
2850 | |
16726
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16725
diff
changeset
|
2851 msim_load, /**< load */ |
16394 | 2852 NULL, /**< unload */ |
2853 NULL, /**< destroy */ | |
2854 NULL, /**< ui_info */ | |
2855 &prpl_info, /**< extra_info */ | |
2856 NULL, /**< prefs_info */ | |
2857 | |
2858 /* msim_actions */ | |
16723
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2859 NULL, |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2860 |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2861 NULL, /**< reserved1 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2862 NULL, /**< reserved2 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2863 NULL, /**< reserved3 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16409
diff
changeset
|
2864 NULL /**< reserved4 */ |
16394 | 2865 }; |
2866 | |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2867 |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
2868 #ifdef MSIM_SELF_TEST |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2869 /** Test functions. |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2870 * Used to test or try out the internal workings of msimprpl. If you're reading |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2871 * this code for the first time, these functions can be instructive in how |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2872 * msimprpl is architected. |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2873 */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2874 void |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2875 msim_test_all(void) |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2876 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2877 guint failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2878 |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2879 |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2880 failures = 0; |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2881 failures += msim_test_xml(); |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2882 failures += msim_test_msg(); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2883 failures += msim_test_escaping(); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2884 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2885 if (failures) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2886 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2887 purple_debug_info("msim", "msim_test_all HAD FAILURES: %d\n", failures); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2888 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2889 else |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2890 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2891 purple_debug_info("msim", "msim_test_all - all tests passed!\n"); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2892 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2893 exit(0); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2894 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2895 |
17662
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2896 int |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2897 msim_test_xml(void) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2898 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2899 gchar *msg_text; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2900 xmlnode *root, *n; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2901 guint failures; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2902 char *s; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2903 int len; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2904 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2905 failures = 0; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2906 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2907 msg_text = "<p><f n=\"Arial\" h=\"12\">woo!</f>xxx<c v='black'>yyy</c></p>"; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2908 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2909 purple_debug_info("msim", "msim_test_xml: msg_text=%s\n", msg_text); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2910 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2911 root = xmlnode_from_str(msg_text, -1); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2912 if (!root) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2913 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2914 purple_debug_info("msim", "there is no root\n"); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2915 exit(0); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2916 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2917 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2918 purple_debug_info("msim", "root name=%s, child name=%s\n", root->name, |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2919 root->child->name); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2920 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2921 purple_debug_info("msim", "last child name=%s\n", root->lastchild->name); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2922 purple_debug_info("msim", "Root xml=%s\n", |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2923 xmlnode_to_str(root, &len)); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2924 purple_debug_info("msim", "Child xml=%s\n", |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2925 xmlnode_to_str(root->child, &len)); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2926 purple_debug_info("msim", "Lastchild xml=%s\n", |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2927 xmlnode_to_str(root->lastchild, &len)); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2928 purple_debug_info("msim", "Next xml=%s\n", |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2929 xmlnode_to_str(root->next, &len)); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2930 purple_debug_info("msim", "Next data=%s\n", |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2931 xmlnode_get_data(root->next)); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2932 purple_debug_info("msim", "Child->next xml=%s\n", |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2933 xmlnode_to_str(root->child->next, &len)); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2934 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2935 for (n = root->child; n; n = n->next) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2936 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2937 if (n->name) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2938 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2939 purple_debug_info("msim", " ** n=%s\n",n->name); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2940 } else { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2941 purple_debug_info("msim", " ** n data=%s\n", n->data); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2942 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2943 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2944 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2945 purple_debug_info("msim", "root data=%s, child data=%s, child 'h'=%s\n", |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2946 xmlnode_get_data(root), |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2947 xmlnode_get_data(root->child), |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2948 xmlnode_get_attrib(root->child, "h")); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2949 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2950 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2951 for (n = root->child; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2952 n != NULL; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2953 n = n->next) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2954 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2955 purple_debug_info("msim", "next name=%s\n", n->name); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2956 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2957 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2958 s = xmlnode_to_str(root, &len); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2959 s[len] = 0; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2960 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2961 purple_debug_info("msim", "str: %s\n", s); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2962 g_free(s); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2963 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2964 xmlnode_free(root); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2965 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2966 exit(0); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2967 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2968 return failures; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2969 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17661
diff
changeset
|
2970 |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2971 /** Test MsimMessage for basic functionality. */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2972 int |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
2973 msim_test_msg(void) |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2974 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2975 MsimMessage *msg, *msg_cloned; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2976 gchar *packed, *packed_expected, *packed_cloned; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2977 guint failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2978 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2979 failures = 0; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2980 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2981 purple_debug_info("msim", "\n\nTesting MsimMessage\n"); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2982 msg = msim_msg_new(FALSE); /* Create a new, empty message. */ |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2983 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2984 /* Append some new elements. */ |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2985 msg = msim_msg_append(msg, "bx", MSIM_TYPE_BINARY, g_string_new_len(g_strdup("XXX"), 3)); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2986 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v1")); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2987 msg = msim_msg_append(msg, "k1", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(42)); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2988 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v43")); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2989 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v52/xxx\\yyy")); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2990 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v7")); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2991 msim_msg_dump("msg debug str=%s\n", msg); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2992 packed = msim_msg_pack(msg); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2993 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2994 purple_debug_info("msim", "msg packed=%s\n", packed); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2995 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2996 packed_expected = "\\bx\\WFhY\\k1\\v1\\k1\\42\\k1" |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2997 "\\v43\\k1\\v52/1xxx/2yyy\\k1\\v7\\final\\"; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2998 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
2999 if (0 != strcmp(packed, packed_expected)) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3000 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3001 purple_debug_info("msim", "!!!(%d), msim_msg_pack not what expected: %s != %s\n", |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3002 ++failures, packed, packed_expected); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3003 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3004 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3005 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3006 msg_cloned = msim_msg_clone(msg); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3007 packed_cloned = msim_msg_pack(msg_cloned); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3008 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3009 purple_debug_info("msim", "msg cloned=%s\n", packed_cloned); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3010 if (0 != strcmp(packed, packed_cloned)) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3011 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3012 purple_debug_info("msim", "!!!(%d), msim_msg_pack on cloned message not equal to original: %s != %s\n", |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3013 ++failures, packed_cloned, packed); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3014 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3015 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3016 g_free(packed); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3017 g_free(packed_cloned); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3018 msim_msg_free(msg_cloned); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3019 msim_msg_free(msg); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3020 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3021 return failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3022 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3023 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3024 /** Test protocol-level escaping/unescaping. */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
3025 int |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
3026 msim_test_escaping(void) |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3027 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3028 guint failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3029 gchar *raw, *escaped, *unescaped, *expected; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3030 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3031 failures = 0; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3032 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3033 purple_debug_info("msim", "\n\nTesting escaping\n"); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3034 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3035 raw = "hello/world\\hello/world"; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3036 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3037 escaped = msim_escape(raw); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3038 purple_debug_info("msim", "msim_test_escaping: raw=%s, escaped=%s\n", raw, escaped); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3039 expected = "hello/1world/2hello/1world"; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3040 if (0 != strcmp(escaped, expected)) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3041 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3042 purple_debug_info("msim", "!!!(%d), msim_escape failed: %s != %s\n", |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3043 ++failures, escaped, expected); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3044 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3045 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3046 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3047 unescaped = msim_unescape(escaped); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3048 g_free(escaped); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3049 purple_debug_info("msim", "msim_test_escaping: unescaped=%s\n", unescaped); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3050 if (0 != strcmp(raw, unescaped)) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3051 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3052 purple_debug_info("msim", "!!!(%d), msim_unescape failed: %s != %s\n", |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3053 ++failures, raw, unescaped); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3054 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3055 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3056 return failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3057 } |
17651
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17650
diff
changeset
|
3058 #endif |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3059 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3060 /** Initialize plugin. */ |
17661
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
3061 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17660
diff
changeset
|
3062 init_plugin(PurplePlugin *plugin) |
16733
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
3063 { |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
3064 PurpleAccountOption *option; |
17648
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3065 #ifdef MSIM_SELF_TEST |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3066 msim_test_all(); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17647
diff
changeset
|
3067 #endif /* MSIM_SELF_TEST */ |
16733
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
3068 |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
3069 /* TODO: default to automatically try different ports. Make the user be |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
3070 * able to set the first port to try (like LastConnectedPort in Windows client). */ |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
3071 option = purple_account_option_string_new(_("Connect server"), "server", MSIM_SERVER); |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
3072 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
3073 |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
3074 option = purple_account_option_int_new(_("Connect port"), "port", MSIM_PORT); |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
3075 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
17332
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
3076 |
17681
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
3077 option = purple_account_option_bool_new(_("Sign on as hidden"), "hidden", FALSE); |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
3078 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
5e8c02259c81
Add option to sign on as hidden, or as not (previously, always signed on
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17680
diff
changeset
|
3079 |
17332
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
3080 option = purple_account_option_bool_new(_("Show display name in status text"), "show_display_name", TRUE); |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
3081 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
3082 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
3083 option = purple_account_option_bool_new(_("Show headline in status text"), "show_headline", TRUE); |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17331
diff
changeset
|
3084 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
16733
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16731
diff
changeset
|
3085 } |
16394 | 3086 |
16396 | 3087 PURPLE_INIT_PLUGIN(myspace, init_plugin, info); |