Mercurial > pidgin.yaz
annotate libpurple/protocols/myspace/myspace.c @ 17912:d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
(based on finch/gnthistory.c's looping over the buddy list), but leave it
commented out because it still causes the crash in msim_parse().
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Tue, 26 Jun 2007 05:33:00 +0000 |
parents | a014bcce5a5d |
children | 7e4e3f6582d2 |
rev | line source |
---|---|
16395 | 1 /* MySpaceIM Protocol Plugin |
2 * | |
3 * \author Jeff Connelly | |
4 * | |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
5 * Copyright (C) 2007, Jeff Connelly <jeff2@homing.pidgin.im> |
16395 | 6 * |
16397 | 7 * Based on Purple's "C Plugin HOWTO" hello world example. |
16395 | 8 * |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
9 * Code also drawn from mockprpl: |
16397 | 10 * http://snarfed.org/space/purple+mock+protocol+plugin |
16395 | 11 * Copyright (C) 2004-2007, Ryan Barrett <mockprpl@ryanb.org> |
12 * | |
16397 | 13 * and some constructs also based on existing Purple plugins, which are: |
14 * Copyright (C) 2003, Robbert Haarman <purple@inglorion.net> | |
16395 | 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 | |
16397 | 34 #define PURPLE_PLUGIN |
16395 | 35 |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
36 #include "message.h" |
17343
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17342
diff
changeset
|
37 #include "persist.h" |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
38 #include "myspace.h" |
16395 | 39 |
16737
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
40 /** |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
41 * Load the plugin. |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
42 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
43 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
44 msim_load(PurplePlugin *plugin) |
16737
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
45 { |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
46 #ifdef MSIM_USE_PURPLE_RC4 |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
47 /* 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:
16736
diff
changeset
|
48 if (!purple_ciphers_find_cipher("rc4")) |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
49 { |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
50 purple_debug_error("msim", "compiled with MSIM_USE_PURPLE_RC4 but rc4 not in libpurple - not loading MySpaceIM plugin!\n"); |
16739
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
51 purple_notify_error(plugin, _("Missing Cipher"), |
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
52 _("The RC4 cipher could not be found"), |
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
53 _("Recompile without MSIM_USE_PURPLE_RC4, or upgrade " |
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
54 "to a libpurple with RC4 support (>= 2.0.1). MySpaceIM " |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
55 "plugin will not be loaded.")); |
16737
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
56 return FALSE; |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
57 } |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
58 #endif |
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
59 return TRUE; |
16395 | 60 } |
61 | |
62 /** | |
63 * Get possible user status types. Based on mockprpl. | |
64 * | |
65 * @return GList of status types. | |
66 */ | |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
67 GList * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
68 msim_status_types(PurpleAccount *acct) |
16395 | 69 { |
70 GList *types; | |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
71 PurpleStatusType *status; |
16395 | 72 |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
73 purple_debug_info("myspace", "returning status types\n"); |
16395 | 74 |
75 types = NULL; | |
76 | |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
77 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:
16749
diff
changeset
|
78 types = g_list_append(types, status); |
16395 | 79 |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
80 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:
16749
diff
changeset
|
81 types = g_list_append(types, status); |
16395 | 82 |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
83 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:
16749
diff
changeset
|
84 types = g_list_append(types, status); |
16395 | 85 |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
86 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:
16749
diff
changeset
|
87 types = g_list_append(types, status); |
16395 | 88 |
89 return types; | |
90 } | |
91 | |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
92 /** |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
93 * Return the icon name for a buddy and account. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
94 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
95 * @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:
16405
diff
changeset
|
96 * @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:
16405
diff
changeset
|
97 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
98 * @return The base icon name string. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
99 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
100 const gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
101 msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy) |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
102 { |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
103 /* Use a MySpace icon submitted by hbons at |
16744
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16742
diff
changeset
|
104 * http://developer.pidgin.im/wiki/MySpaceIM. */ |
16407
f62023eddfc6
Add and use MySpaceIM icon uploaded by hbons (48x48 original and resized 22x22 and 16x16 versions).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16406
diff
changeset
|
105 return "myspace"; |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
106 } |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
107 |
17892
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
108 /* Replacement codes to be replaced with associated replacement text, |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
109 * used for protocol message escaping / unescaping. */ |
17891
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
110 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:
17890
diff
changeset
|
111 static gchar* msim_replacement_text[] = { "/", "\\", NULL }; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
112 |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
113 /** |
17892
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
114 * Unescape or escape a protocol message. |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
115 * |
17892
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
116 * @param msg The message to be unescaped or escaped. WILL BE FREED. |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
117 * @param escape TRUE to escape, FALSE to unescape. |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
118 * |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
119 * @return The unescaped or escaped message. Caller must g_free(). |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
120 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
121 gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
122 msim_unescape_or_escape(gchar *msg, gboolean escape) |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
123 { |
17892
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
124 gchar *tmp, *code, *text; |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
125 guint i; |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
126 |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
127 /* Replace each code in msim_replacement_code with |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
128 * corresponding entry in msim_replacement_text. */ |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
129 for (i = 0; (code = msim_replacement_code[i]) |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
130 && (text = msim_replacement_text[i]); ++i) |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
131 { |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
132 if (escape) |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
133 { |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
134 tmp = str_replace(msg, text, code); |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
135 } |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
136 else |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
137 { |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
138 tmp = str_replace(msg, code, text); |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
139 } |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
140 g_free(msg); |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
141 msg = tmp; |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
142 } |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
143 |
17892
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
144 return msg; |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
145 } |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
146 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
147 /** |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
148 * Escape a protocol message. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
149 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
150 * @return The escaped message. Caller must g_free(). |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
151 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
152 gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
153 msim_escape(const gchar *msg) |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
154 { |
17892
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
155 return msim_unescape_or_escape(g_strdup(msg), TRUE); |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
156 } |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
157 |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
158 gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
159 msim_unescape(const gchar *msg) |
17892
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
160 { |
9cb771adbdea
Refactor msim_escape() & msim_unescape().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17891
diff
changeset
|
161 return msim_unescape_or_escape(g_strdup(msg), FALSE); |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
162 } |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
163 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
164 /** |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
165 * Replace 'old' with 'new' in 'str'. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
166 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
167 * @param str The original string. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
168 * @param old The substring of 'str' to replace. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
169 * @param new The replacement for 'old' within 'str'. |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
170 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
171 * @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:
16408
diff
changeset
|
172 * 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:
16408
diff
changeset
|
173 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
174 * This string replace method is based on |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
175 * 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:
16408
diff
changeset
|
176 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
177 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
178 gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
179 str_replace(const gchar *str, const gchar *old, const gchar *new) |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
180 { |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
181 gchar **items; |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
182 gchar *ret; |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
183 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
184 items = g_strsplit(str, old, -1); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
185 ret = g_strjoinv(new, items); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
186 g_free(items); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
187 return ret; |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
188 } |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
189 |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
190 #ifdef MSIM_DEBUG_MSG |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
191 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
192 print_hash_item(gpointer key, gpointer value, gpointer user_data) |
16395 | 193 { |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
194 purple_debug_info("msim", "%s=%s\n", (gchar *)key, (gchar *)value); |
16395 | 195 } |
16408
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
196 #endif |
16395 | 197 |
198 /** | |
17903
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
199 * Send raw data (given as a NUL-terminated string) to the server. |
16395 | 200 * |
201 * @param session | |
17903
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
202 * @param msg The raw data to send, in a NUL-terminated string. |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
203 * |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
204 * @return TRUE if succeeded, FALSE if not. |
16395 | 205 * |
206 */ | |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
207 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
208 msim_send_raw(MsimSession *session, const gchar *msg) |
16395 | 209 { |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
210 purple_debug_info("msim", "msim_send_raw: writing <%s>\n", msg); |
16395 | 211 |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
212 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:
16408
diff
changeset
|
213 g_return_val_if_fail(msg != NULL, FALSE); |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
214 |
17903
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
215 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:
17902
diff
changeset
|
216 strlen(msg); |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
217 } |
16395 | 218 |
17903
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
219 /** 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:
17902
diff
changeset
|
220 * |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
221 * 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:
17902
diff
changeset
|
222 * 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:
17902
diff
changeset
|
223 * 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:
17902
diff
changeset
|
224 * |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
225 * @param gc PurpleConnection |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
226 * @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:
17902
diff
changeset
|
227 * @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:
17902
diff
changeset
|
228 * |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
229 * @return Bytes successfully sent. |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
230 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
231 int |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
232 msim_send_really_raw(PurpleConnection *gc, const char *buf, int total_bytes) |
17903
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
233 { |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
234 int total_bytes_sent; |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
235 |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
236 /* 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:
16408
diff
changeset
|
237 total_bytes_sent = 0; |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
238 do |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
239 { |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
240 int bytes_sent; |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
241 |
17903
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
242 bytes_sent = send(((MsimSession*)(gc->proto_data))->fd, |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
243 buf + total_bytes_sent, total_bytes - total_bytes_sent, 0); |
16395 | 244 |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
245 if (bytes_sent < 0) |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
246 { |
16734
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16410
diff
changeset
|
247 purple_debug_info("msim", "msim_send_raw(%s): send() failed: %s\n", |
17903
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
248 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:
17902
diff
changeset
|
249 return total_bytes_sent; |
16410
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
250 } |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
251 total_bytes_sent += bytes_sent; |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
252 |
1aa62f7368ca
Add escaping and unescaping functions (for /1 and /2).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16408
diff
changeset
|
253 } while(total_bytes_sent < total_bytes); |
17903
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
254 |
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
255 return total_bytes_sent; |
16395 | 256 } |
257 | |
17903
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
258 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
259 /** |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
260 * Start logging in to the MSIM servers. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
261 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
262 * @param acct Account information to use to login. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
263 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
264 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
265 msim_login(PurpleAccount *acct) |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
266 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
267 PurpleConnection *gc; |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
268 const gchar *host; |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
269 int port; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
270 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
271 g_return_if_fail(acct != NULL); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
272 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
273 purple_debug_info("myspace", "logging in %s\n", acct->username); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
274 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
275 gc = purple_account_get_connection(acct); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
276 gc->proto_data = msim_session_new(acct); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
277 |
17908
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
278 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:
17907
diff
changeset
|
279 { |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
280 gchar *str; |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
281 |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
282 |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
283 /* TODO: Find out why >8 is problematic. The web site lets you have |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
284 * long passwords, but reportedly the official IM client does not |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
285 * allow more than 8 characters to be entered. Just entering the first |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
286 * 8 does not, on first try, appear to work. */ |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
287 str = g_strdup_printf(_("Sorry, passwords over %d characters in length (yours is %d) are " |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
288 "currently not supported by the MySpaceIM plugin."), 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:
17907
diff
changeset
|
289 (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:
17907
diff
changeset
|
290 |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
291 /* 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:
17907
diff
changeset
|
292 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:
17907
diff
changeset
|
293 |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
294 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:
17907
diff
changeset
|
295 |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
296 g_free(str); |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
297 } |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
298 |
5c2720824798
Fail with our own error message if an entered password is greater than 8
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17907
diff
changeset
|
299 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
300 /* 1. connect to server */ |
16739
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
301 purple_connection_update_progress(gc, _("Connecting"), |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
302 0, /* which connection step this is */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
303 4); /* total number of steps */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
304 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
305 host = purple_account_get_string(acct, "server", MSIM_SERVER); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
306 port = purple_account_get_int(acct, "port", MSIM_PORT); |
16744
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16742
diff
changeset
|
307 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
308 /* From purple.sf.net/api: |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
309 * """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:
16405
diff
changeset
|
310 * "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:
16405
diff
changeset
|
311 * whether through a proxy or not.""" */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
312 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
313 /* Calls msim_connect_cb when connected. */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
314 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:
16405
diff
changeset
|
315 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
316 /* TODO: try other ports if in auto mode, then save |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
317 * working port and try that first next time. */ |
16739
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
318 purple_connection_error(gc, _("Couldn't create socket")); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
319 return; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
320 } |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
321 } |
17903
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
322 |
16395 | 323 /** |
324 * Process a login challenge, sending a response. | |
325 * | |
326 * @param session | |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
327 * @param msg Login challenge message. |
16395 | 328 * |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
329 * @return TRUE if successful, FALSE if not |
16395 | 330 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
331 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
332 msim_login_challenge(MsimSession *session, MsimMessage *msg) |
16395 | 333 { |
16397 | 334 PurpleAccount *account; |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
335 const gchar *response; |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
336 guint response_len; |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
337 gchar *nc; |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
338 gsize nc_len; |
16395 | 339 |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
340 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:
17347
diff
changeset
|
341 g_return_val_if_fail(msg != NULL, FALSE); |
16395 | 342 |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
343 g_return_val_if_fail(msim_msg_get_binary(msg, "nc", &nc, &nc_len), FALSE); |
16395 | 344 |
345 account = session->account; | |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
346 |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
347 g_return_val_if_fail(account != NULL, FALSE); |
16395 | 348 |
16739
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
349 purple_connection_update_progress(session->gc, _("Reading challenge"), 1, 4); |
16395 | 350 |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
351 purple_debug_info("msim", "nc is %d bytes, decoded\n", nc_len); |
16395 | 352 |
353 if (nc_len != 0x40) | |
354 { | |
16397 | 355 purple_debug_info("msim", "bad nc length: %x != 0x40\n", nc_len); |
16739
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
356 purple_connection_error(session->gc, _("Unexpected challenge length from server")); |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
357 return FALSE; |
16395 | 358 } |
359 | |
16739
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
360 purple_connection_update_progress(session->gc, _("Logging in"), 2, 4); |
16395 | 361 |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
362 response = msim_compute_login_response(nc, account->username, account->password, &response_len); |
16395 | 363 |
364 g_free(nc); | |
365 | |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
366 return msim_send(session, |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
367 "login2", MSIM_TYPE_INTEGER, MSIM_AUTH_ALGORITHM, |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
368 /* This is actually user's email address. */ |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
369 "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:
16746
diff
changeset
|
370 /* 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:
16746
diff
changeset
|
371 "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:
16746
diff
changeset
|
372 "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:
16746
diff
changeset
|
373 "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:
16746
diff
changeset
|
374 "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:
16746
diff
changeset
|
375 "id", MSIM_TYPE_INTEGER, 1, |
16742
2e0bd3e6f2c7
Incomplete attempt at using msim_send() instead of msim_send_raw().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16741
diff
changeset
|
376 NULL); |
16395 | 377 } |
378 | |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
379 #ifndef MSIM_USE_PURPLE_RC4 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
380 /* No RC4 in this version of libpurple, so bring our own. */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
381 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
382 /* |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
383 Unix SMB/CIFS implementation. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
384 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
385 a partial implementation of RC4 designed for use in the |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
386 SMB authentication protocol |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
387 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
388 Copyright (C) Andrew Tridgell 1998 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
389 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
390 $Id: crypt-rc4.c 12116 2004-09-27 23:29:22Z guy $ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
391 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
392 This program is free software; you can redistribute it and/or modify |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
393 it under the terms of the GNU General Public License as published by |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
394 the Free Software Foundation; either version 2 of the License, or |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
395 (at your option) any later version. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
396 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
397 This program is distributed in the hope that it will be useful, |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
398 but WITHOUT ANY WARRANTY; without even the implied warranty of |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
399 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
400 GNU General Public License for more details. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
401 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
402 You should have received a copy of the GNU General Public License |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
403 along with this program; if not, write to the Free Software |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
404 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
405 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
406 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
407 Modified by Jeff Connelly for MySpaceIM Gaim plugin. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
408 */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
409 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
410 #include <glib.h> |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
411 #include <string.h> |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
412 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
413 /* Perform RC4 on a block of data using specified key. "data" is a pointer |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
414 to the block to be processed. Output is written to same memory as input, |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
415 so caller may need to make a copy before calling this function, since |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
416 the input will be overwritten. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
417 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
418 Taken from Samba source code. Modified to allow us to maintain state |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
419 between calls to crypt_rc4. |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
420 */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
421 |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
422 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
423 crypt_rc4_init(rc4_state_struct *rc4_state, |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
424 const guchar *key, int key_len) |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
425 { |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
426 int ind; |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
427 unsigned gchar j = 0; |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
428 unsigned gchar *s_box; |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
429 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
430 memset(rc4_state, 0, sizeof(rc4_state_struct)); |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
431 s_box = rc4_state->s_box; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
432 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
433 for (ind = 0; ind < 256; ind++) |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
434 { |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
435 s_box[ind] = (guchar)ind; |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
436 } |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
437 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
438 for( ind = 0; ind < 256; ind++) |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
439 { |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
440 guchar tc; |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
441 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
442 j += (s_box[ind] + key[ind%key_len]); |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
443 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
444 tc = s_box[ind]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
445 s_box[ind] = s_box[j]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
446 s_box[j] = tc; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
447 } |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
448 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
449 } |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
450 |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
451 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
452 crypt_rc4(rc4_state_struct *rc4_state, guchar *data, int data_len) |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
453 { |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
454 guchar *s_box; |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
455 guchar index_i; |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
456 guchar index_j; |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
457 int ind; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
458 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
459 /* retrieve current state from the state struct (so we can resume where |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
460 we left off) */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
461 index_i = rc4_state->index_i; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
462 index_j = rc4_state->index_j; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
463 s_box = rc4_state->s_box; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
464 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
465 for( ind = 0; ind < data_len; ind++) |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
466 { |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
467 guchar tc; |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
468 guchar t; |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
469 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
470 index_i++; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
471 index_j += s_box[index_i]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
472 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
473 tc = s_box[index_i]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
474 s_box[index_i] = s_box[index_j]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
475 s_box[index_j] = tc; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
476 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
477 t = s_box[index_i] + s_box[index_j]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
478 data[ind] = data[ind] ^ s_box[t]; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
479 } |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
480 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
481 /* Store the updated state */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
482 rc4_state->index_i = index_i; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
483 rc4_state->index_j = index_j; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
484 } |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
485 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
486 #endif /* !MSIM_USE_PURPLE_RC4 */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
487 |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
488 |
16395 | 489 /** |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
490 * 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:
16405
diff
changeset
|
491 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
492 * @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:
16405
diff
changeset
|
493 * @param email User's email address (used as login name). |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
494 * @param password User's cleartext password. |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
495 * @param response_len Will be written with response length. |
16395 | 496 * |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
497 * @return Binary login challenge response, ready to send to the server. Must be g_free()'d |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
498 * when finished. |
16395 | 499 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
500 const gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
501 msim_compute_login_response(const gchar nonce[2 * NONCE_SIZE], |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
502 const gchar *email, const gchar *password, guint *response_len) |
16395 | 503 { |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
504 PurpleCipherContext *key_context; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
505 PurpleCipher *sha1; |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
506 #ifdef MSIM_USE_PURPLE_RC4 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
507 PurpleCipherContext *rc4; |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
508 #else |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
509 rc4_state_struct rc4; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
510 #endif |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
511 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
512 guchar hash_pw[HASH_SIZE]; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
513 guchar key[HASH_SIZE]; |
16749
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16747
diff
changeset
|
514 gchar *password_utf16le; |
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16747
diff
changeset
|
515 guchar *data; |
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16747
diff
changeset
|
516 guchar *data_out; |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
517 size_t data_len, data_out_len; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
518 gsize conv_bytes_read, conv_bytes_written; |
16749
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16747
diff
changeset
|
519 GError *conv_error; |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
520 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
16408
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
521 int i; |
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
522 #endif |
16395 | 523 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
524 /* Convert ASCII password to UTF16 little endian */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
525 purple_debug_info("msim", "converting password to UTF-16LE\n"); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
526 conv_error = NULL; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
527 password_utf16le = g_convert(password, -1, "UTF-16LE", "UTF-8", |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
528 &conv_bytes_read, &conv_bytes_written, &conv_error); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
529 g_assert(conv_bytes_read == strlen(password)); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
530 if (conv_error != NULL) |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
531 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
532 purple_debug_error("msim", |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
533 "g_convert password UTF8->UTF16LE failed: %s", |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
534 conv_error->message); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
535 g_error_free(conv_error); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
536 } |
16395 | 537 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
538 /* Compute password hash */ |
16749
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16747
diff
changeset
|
539 purple_cipher_digest_region("sha1", (guchar *)password_utf16le, |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
540 conv_bytes_written, sizeof(hash_pw), hash_pw, NULL); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
541 g_free(password_utf16le); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
542 |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
543 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
16408
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
544 purple_debug_info("msim", "pwhash = "); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
545 for (i = 0; i < sizeof(hash_pw); i++) |
16408
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
546 purple_debug_info("msim", "%.2x ", hash_pw[i]); |
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
547 purple_debug_info("msim", "\n"); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
548 #endif |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
549 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
550 /* key = sha1(sha1(pw) + nonce2) */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
551 sha1 = purple_ciphers_find_cipher("sha1"); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
552 key_context = purple_cipher_context_new(sha1, NULL); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
553 purple_cipher_context_append(key_context, hash_pw, HASH_SIZE); |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
554 purple_cipher_context_append(key_context, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
555 purple_cipher_context_digest(key_context, sizeof(key), key, NULL); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
556 |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
557 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
16408
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
558 purple_debug_info("msim", "key = "); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
559 for (i = 0; i < sizeof(key); i++) |
16395 | 560 { |
16408
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
561 purple_debug_info("msim", "%.2x ", key[i]); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
562 } |
16408
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
563 purple_debug_info("msim", "\n"); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
564 #endif |
16395 | 565 |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
566 #ifdef MSIM_USE_PURPLE_RC4 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
567 rc4 = purple_cipher_context_new_by_name("rc4", NULL); |
16395 | 568 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
569 /* Note: 'key' variable is 0x14 bytes (from SHA-1 hash), |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
570 * but only first 0x10 used for the RC4 key. */ |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
571 purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
572 purple_cipher_context_set_key(rc4, key); |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
573 #endif |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
574 |
17895
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17894
diff
changeset
|
575 /* TODO: obtain IPs of network interfaces */ |
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17894
diff
changeset
|
576 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
577 /* rc4 encrypt: |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
578 * nonce1+email+IP list */ |
17895
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17894
diff
changeset
|
579 |
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17894
diff
changeset
|
580 data_len = NONCE_SIZE + strlen(email) + MSIM_LOGIN_IP_LIST_LEN; |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
581 data = g_new0(guchar, data_len); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
582 memcpy(data, nonce, NONCE_SIZE); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
583 memcpy(data + NONCE_SIZE, email, strlen(email)); |
17895
06d60201e371
Use constants for IP address list, defined in myspace.h.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17894
diff
changeset
|
584 memcpy(data + NONCE_SIZE + strlen(email), MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
585 |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
586 #ifdef MSIM_USE_PURPLE_RC4 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
587 data_out = g_new0(guchar, data_len); |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
588 |
16749
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16747
diff
changeset
|
589 purple_cipher_context_encrypt(rc4, (const guchar *)data, |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
590 data_len, data_out, &data_out_len); |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
591 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:
16734
diff
changeset
|
592 #else |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
593 /* Use our own RC4 code */ |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
594 purple_debug_info("msim", "Using non-purple RC4 cipher code in this version\n"); |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
595 crypt_rc4_init(&rc4, key, 0x10); |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
596 crypt_rc4(&rc4, data, data_len); |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
597 data_out_len = data_len; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
598 data_out = data; |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
599 #endif |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
600 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
601 g_assert(data_out_len == data_len); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
602 |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
603 #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:
16746
diff
changeset
|
604 purple_debug_info("msim", "response=<%s>\n", data_out); |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
605 #endif |
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
606 |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
607 *response_len = data_out_len; |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
608 |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
609 return (const gchar *)data_out; |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
610 } |
16395 | 611 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
612 /** |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
613 * 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:
16405
diff
changeset
|
614 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
615 * @param gc Connection. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
616 * @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:
16405
diff
changeset
|
617 * @param message Instant message text to send. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
618 * @param flags Flags. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
619 * |
17367
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
620 * @return 1 if successful or postponed, -1 if failed |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
621 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
622 * 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:
16405
diff
changeset
|
623 * a username or email address is given, the userid must be looked up. |
17367
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
624 * This function does that by calling msim_postprocess_outgoing(). |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
625 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
626 int |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
627 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:
17903
diff
changeset
|
628 PurpleMessageFlags flags) |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
629 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
630 MsimSession *session; |
17372
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
631 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
632 g_return_val_if_fail(gc != NULL, 0); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
633 g_return_val_if_fail(who != NULL, 0); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
634 g_return_val_if_fail(message != NULL, 0); |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
635 |
17357
176b1ba4bafe
Remove 'flags' from send_im_cb_struct - it was never needed.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17356
diff
changeset
|
636 /* '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:
17356
diff
changeset
|
637 |
17372
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
638 session = gc->proto_data; |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
639 |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
640 if (msim_send_bm(session, who, message, MSIM_BM_INSTANT)) |
17367
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
641 { |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
642 /* 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:
17366
diff
changeset
|
643 * 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:
17366
diff
changeset
|
644 * 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:
17366
diff
changeset
|
645 * 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:
17366
diff
changeset
|
646 */ |
17372
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
647 return 1; |
17367
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
648 } else { |
17372
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
649 return -1; |
17367
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
650 } |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
651 /* |
17894
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
652 * In MySpace, you login with your email address, but don't talk to other |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
653 * 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:
16405
diff
changeset
|
654 * IM windows when using this plugin: |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
655 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
656 * you@example.com: hello |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
657 * some_other_user: what's going on? |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
658 * you@example.com: just coding a prpl |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
659 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
660 * 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:
16405
diff
changeset
|
661 * 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:
16405
diff
changeset
|
662 */ |
16395 | 663 } |
664 | |
17372
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
665 /** Send a buddy message of a given type. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
666 * |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
667 * @param session |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
668 * @param who Username to send message to. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
669 * @param text Message text to send. Not freed; will be copied. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
670 * @param type A MSIM_BM_* constant. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
671 * |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
672 * Buddy messages ('bm') include instant messages, action messages, status messages, etc. |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
673 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
674 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
675 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:
17903
diff
changeset
|
676 int type) |
17372
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
677 { |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
678 gboolean rc; |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
679 MsimMessage *msg; |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
680 const gchar *from_username; |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
681 |
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
682 from_username = session->account->username; |
17372
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
683 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
684 purple_debug_info("msim", "sending %d message from %s to %s: %s\n", |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
685 type, from_username, who, text); |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
686 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
687 msg = msim_msg_new(TRUE, |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
688 "bm", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(type), |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
689 "sesskey", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(session->sesskey), |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
690 /* 't' will be inserted here */ |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
691 "cv", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(MSIM_CLIENT_VERSION), |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
692 "msg", MSIM_TYPE_STRING, g_strdup(text), |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
693 NULL); |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
694 |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
695 rc = msim_postprocess_outgoing(session, msg, who, "t", "cv"); |
17372
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
696 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
697 msim_msg_free(msg); |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
698 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
699 return rc; |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
700 } |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
701 |
17905
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
702 /** Convert a font point size to purple's HTML font size. |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
703 * |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
704 * Based on 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:
17904
diff
changeset
|
705 */ |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
706 static guint |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
707 msim_font_size_to_purple(int size) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
708 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
709 if (size > 24) { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
710 return 7; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
711 } else if (size >= 21) { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
712 return 6; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
713 } else if (size >= 17) { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
714 return 5; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
715 } else if (size >= 14) { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
716 return 4; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
717 } else if (size >= 12) { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
718 return 3; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
719 } else if (size >= 10) { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
720 return 2; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
721 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
722 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
723 return 1; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
724 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
725 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
726 /** 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:
17904
diff
changeset
|
727 static guint |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
728 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:
17904
diff
changeset
|
729 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
730 /* 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:
17904
diff
changeset
|
731 * _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:
17904
diff
changeset
|
732 switch (height) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
733 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
734 case 11: return 8; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
735 case 12: return 9; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
736 case 13: return 10; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
737 case 14: |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
738 case 15: return 11; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
739 case 16: return 12; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
740 case 17: |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
741 case 18: return 13; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
742 case 19: return 14; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
743 case 20: return 15; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
744 case 21: return 16; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
745 default: return 12; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
746 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
747 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
748 |
17911
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
749 /** Convert the msim markup <f> (font) tag into HTML. */ |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
750 static void msim_markup_f_to_html(xmlnode *root, gchar **begin, gchar **end) |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
751 { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
752 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:
17908
diff
changeset
|
753 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:
17908
diff
changeset
|
754 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:
17908
diff
changeset
|
755 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
756 face = xmlnode_get_attrib(root, "n"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
757 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:
17908
diff
changeset
|
758 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:
17908
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:
17908
diff
changeset
|
760 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:
17908
diff
changeset
|
761 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:
17908
diff
changeset
|
762 else |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
763 height = 12; |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
764 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
765 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:
17908
diff
changeset
|
766 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:
17908
diff
changeset
|
767 else |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
768 decor = 0; |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
769 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
770 gs_begin = g_string_new(""); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
771 g_string_printf(gs_begin, "<font face='%s' size='%d'>", face, |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
772 msim_font_size_to_purple(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:
17908
diff
changeset
|
773 /* 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:
17908
diff
changeset
|
774 /* 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:
17908
diff
changeset
|
775 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:
17908
diff
changeset
|
776 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
777 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:
17908
diff
changeset
|
778 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
779 if (decor & 1) |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
780 { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
781 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:
17908
diff
changeset
|
782 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:
17908
diff
changeset
|
783 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
784 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
785 if (decor & 2) |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
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:
17908
diff
changeset
|
787 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:
17908
diff
changeset
|
788 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:
17908
diff
changeset
|
789 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
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:
17908
diff
changeset
|
791 if (decor & 4) |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
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:
17908
diff
changeset
|
793 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:
17908
diff
changeset
|
794 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:
17908
diff
changeset
|
795 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
796 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
797 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
798 *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:
17908
diff
changeset
|
799 *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:
17908
diff
changeset
|
800 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
801 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
802 /** Convert the msim markup <p> (paragraph) tag into HTML. */ |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
803 static void msim_markup_p_to_html(xmlnode *root, gchar **begin, gchar **end) |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
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:
17908
diff
changeset
|
805 /* Just pass through unchanged. |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
806 * |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
807 * 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:
17908
diff
changeset
|
808 *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:
17908
diff
changeset
|
809 *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:
17908
diff
changeset
|
810 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
811 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
812 /** Convert the msim markup <c> tag (text color) into HTML. TODO: Test */ |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
813 static void msim_markup_c_to_html(xmlnode *root, gchar **begin, gchar **end) |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
814 { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
815 const gchar *color; |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
816 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
817 color = xmlnode_get_attrib(root, "v"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
818 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
819 /* TODO: parse rgb(255,0,0) into #FF0000, etc. |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
820 * And do something about rgba (alpha) and transparent. |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
821 */ |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
822 /* *begin = g_strdup_printf("<font color='%s'>", color); */ |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
823 *begin = g_strdup_printf("<span style='color: %s'>", color); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
824 *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:
17908
diff
changeset
|
825 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
826 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
827 /** Convert the msim markup <b> tag (background color) into HTML. TODO: Test */ |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
828 static void msim_markup_b_to_html(xmlnode *root, gchar **begin, gchar **end) |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
829 { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
830 const gchar *color; |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
831 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
832 color = xmlnode_get_attrib(root, "v"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
833 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
834 /* TODO: parse color same as msim_markup_c_to_html(). */ |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
835 *begin = g_strdup_printf("<span style='background-color: %s'>", color); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
836 *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:
17908
diff
changeset
|
837 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
838 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
839 /** Convert the msim markup <i> tag (emoticon image) into HTML. TODO: Test */ |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
840 static void msim_markup_i_to_html(xmlnode *root, gchar **begin, gchar **end) |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
841 { |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
842 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:
17908
diff
changeset
|
843 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
844 name = xmlnode_get_attrib(root, "n"); |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
845 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
846 /* 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:
17908
diff
changeset
|
847 * |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
848 * 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:
17908
diff
changeset
|
849 * 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:
17908
diff
changeset
|
850 * 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:
17908
diff
changeset
|
851 */ |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
852 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
853 *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:
17908
diff
changeset
|
854 *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:
17908
diff
changeset
|
855 } |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
856 |
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
857 |
17905
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
858 /** 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:
17904
diff
changeset
|
859 * @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:
17904
diff
changeset
|
860 */ |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
861 static gchar *msim_markup_xmlnode_to_html(xmlnode *root) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
862 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
863 xmlnode *node; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
864 gchar *begin, *inner, *end; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
865 gchar *final; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
866 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
867 if (!root) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
868 return g_strdup(""); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
869 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
870 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:
17904
diff
changeset
|
871 root->name); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
872 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
873 begin = inner = end = NULL; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
874 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
875 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:
17904
diff
changeset
|
876 { |
17911
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
877 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:
17908
diff
changeset
|
878 } 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:
17908
diff
changeset
|
879 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:
17908
diff
changeset
|
880 } 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:
17908
diff
changeset
|
881 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:
17908
diff
changeset
|
882 } 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:
17908
diff
changeset
|
883 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:
17908
diff
changeset
|
884 } 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:
17908
diff
changeset
|
885 msim_markup_i_to_html(root, &begin, &end); |
17905
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
886 } else { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
887 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:
17904
diff
changeset
|
888 "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:
17904
diff
changeset
|
889 begin = g_strdup(""); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
890 end = g_strdup(""); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
891 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
892 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
893 /* 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:
17904
diff
changeset
|
894 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:
17904
diff
changeset
|
895 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
896 switch (node->type) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
897 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
898 case XMLNODE_TYPE_ATTRIB: |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
899 /* Attributes handled above. */ |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
900 break; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
901 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
902 case XMLNODE_TYPE_TAG: |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
903 /* 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:
17904
diff
changeset
|
904 inner = msim_markup_xmlnode_to_html(node); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
905 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
906 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:
17904
diff
changeset
|
907 break; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
908 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
909 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
910 case XMLNODE_TYPE_DATA: |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
911 /* Literal text. */ |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
912 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:
17904
diff
changeset
|
913 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:
17904
diff
changeset
|
914 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:
17904
diff
changeset
|
915 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
916 purple_debug_info("msim", " ** node data=%s (%s)\n", inner, |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
917 node->data); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
918 break; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
919 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
920 default: |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
921 purple_debug_info("msim", |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
922 "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:
17904
diff
changeset
|
923 inner = g_strdup(""); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
924 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
925 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
926 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
927 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:
17904
diff
changeset
|
928 g_free(begin); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
929 g_free(inner); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
930 g_free(end); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
931 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
932 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:
17904
diff
changeset
|
933 final); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
934 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
935 return final; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
936 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
937 |
17911
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
938 /** Convert MySpaceIM markup to Purple (HTML) markup. |
17905
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
939 * |
17911
a014bcce5a5d
Add (at least placeholder) functions to process p, f, c, b, and i markup tags
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17908
diff
changeset
|
940 * @return Purple markup string, must be g_free()'d. */ |
17905
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
941 gchar * |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
942 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:
17904
diff
changeset
|
943 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
944 xmlnode *root; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
945 gchar *str; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
946 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
947 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:
17904
diff
changeset
|
948 if (!root) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
949 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
950 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:
17904
diff
changeset
|
951 "%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:
17904
diff
changeset
|
952 return g_strdup(raw); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
953 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
954 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
955 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:
17904
diff
changeset
|
956 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:
17904
diff
changeset
|
957 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
958 xmlnode_free(root); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
959 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
960 return g_strdup(str); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
961 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
962 |
16395 | 963 /** |
17347
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
964 * Handle an incoming instant message. |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
965 * |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
966 * @param session The session |
17364
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17363
diff
changeset
|
967 * @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:
17363
diff
changeset
|
968 * Should also contain username in _username from preprocessing. |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
969 * |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
970 * @return TRUE if successful. |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
971 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
972 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
973 msim_incoming_im(MsimSession *session, MsimMessage *msg) |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
974 { |
17905
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
975 gchar *username, *msg_msim_markup, *msg_purple_markup; |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
976 |
17364
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17363
diff
changeset
|
977 username = msim_msg_get_string(msg, "_username"); |
17905
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
978 msg_msim_markup = msim_msg_get_string(msg, "msg"); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
979 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
980 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:
17904
diff
changeset
|
981 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:
17904
diff
changeset
|
982 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
983 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:
17904
diff
changeset
|
984 PURPLE_MESSAGE_RECV, time(NULL)); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
985 |
17364
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17363
diff
changeset
|
986 g_free(username); |
17905
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
987 g_free(msg_purple_markup); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
988 |
17364
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17363
diff
changeset
|
989 return TRUE; |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
990 } |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
991 |
17347
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
992 /** |
17894
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
993 * Handle an unrecognized message. |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
994 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
995 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
996 msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note) |
17894
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
997 { |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
998 /* TODO: Some more context, outwardly equivalent to a backtrace, for helping figure |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
999 * out what this msg is for. But not too much information so that a user |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1000 * posting this dump reveals confidential information. |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1001 */ |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1002 /* 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:
17893
diff
changeset
|
1003 * 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:
17893
diff
changeset
|
1004 * by Alexandr Shutko, who maintains OSCAR protocol documentation). */ |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1005 |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1006 purple_debug_info("msim", "Unrecognized message on account for %s\n", session->account->username); |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1007 if (note) |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1008 { |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1009 purple_debug_info("msim", "(Note: %s)\n", note); |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1010 } |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1011 |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1012 msim_msg_dump("Unrecognized message dump: %s\n", msg); |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1013 } |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1014 |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1015 /** |
17347
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1016 * Handle an incoming action message. |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1017 * |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1018 * @param session |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1019 * @param msg |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1020 * |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1021 * @return TRUE if successful. |
17347
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1022 * |
17365
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1023 * UNTESTED |
17347
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1024 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1025 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1026 msim_incoming_action(MsimSession *session, MsimMessage *msg) |
17347
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1027 { |
17365
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1028 gchar *msg_text, *username; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1029 gboolean rc; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1030 |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1031 msg_text = msim_msg_get_string(msg, "msg"); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1032 username = msim_msg_get_string(msg, "_username"); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1033 |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1034 purple_debug_info("msim", "msim_incoming_action: action <%s> from <%d>\n", msg_text, username); |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1035 |
17365
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1036 if (strcmp(msg_text, "%typing%") == 0) |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1037 { |
17894
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1038 /* TODO: find out if msim repeatedly sends typing messages, so we can give it a timeout. |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1039 * Right now, there does seem to be an inordinately amount of time between typing/ |
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1040 * stopped-typing notifications. */ |
17365
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1041 serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1042 rc = TRUE; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1043 } else if (strcmp(msg_text, "%stoptyping%") == 0) { |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1044 serv_got_typing_stopped(session->gc, username); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1045 rc = TRUE; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1046 } else { |
17894
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1047 msim_unrecognized(session, msg, "got to msim_incoming_action but unrecognized value for 'msg'"); |
17365
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1048 rc = FALSE; |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1049 } |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1050 |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1051 |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1052 g_free(msg_text); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1053 g_free(username); |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1054 |
1277a0f82304
Add untested implementation of msim_incoming_action().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17364
diff
changeset
|
1055 return rc; |
17347
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1056 } |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1057 |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1058 /** |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1059 * 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:
17346
diff
changeset
|
1060 * |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1061 * @param gc |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1062 * @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:
17346
diff
changeset
|
1063 * @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:
17346
diff
changeset
|
1064 * |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1065 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1066 unsigned int |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1067 msim_send_typing(PurpleConnection *gc, const gchar *name, PurpleTypingState state) |
17347
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1068 { |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
1069 const gchar *typing_str; |
17372
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
1070 MsimSession *session; |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
1071 |
d9aaccef8721
Send typing notifications (tested).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17371
diff
changeset
|
1072 session = (MsimSession *)gc->proto_data; |
17347
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1073 |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1074 switch (state) |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1075 { |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1076 case PURPLE_TYPING: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1077 typing_str = "%typing%"; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1078 break; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1079 |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1080 case PURPLE_TYPED: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1081 case PURPLE_NOT_TYPING: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1082 default: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1083 typing_str = "%stoptyping%"; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1084 break; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1085 } |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1086 |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1087 purple_debug_info("msim", "msim_send_typing(%s): %d (%s)\n", name, state, typing_str); |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
1088 msim_send_bm(session, name, typing_str, MSIM_BM_ACTION); |
17347
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1089 return 0; |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1090 } |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1091 |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1092 /** Callback for msim_get_info(), for when user info is received. */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1093 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1094 msim_get_info_cb(MsimSession *session, MsimMessage *user_info_msg, gpointer data) |
17382
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1095 { |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1096 GHashTable *body; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1097 gchar *body_str; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1098 MsimMessage *msg; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1099 gchar *user; |
17382
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1100 PurpleNotifyUserInfo *user_info; |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1101 PurpleBuddy *buddy; |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1102 gchar *song; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1103 |
17382
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1104 |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1105 /* Get user{name,id} from msim_get_info, passed as an MsimMessage for orthogonality. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1106 msg = (MsimMessage *)data; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1107 user = g_strdup(msim_msg_get_string(msg, "user")); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1108 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:
17898
diff
changeset
|
1109 msim_msg_free(msg); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1110 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1111 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1112 body_str = msim_msg_get_string(user_info_msg, "body"); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1113 body = msim_parse_body(body_str); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1114 g_free(body_str); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1115 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1116 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:
17898
diff
changeset
|
1117 /* Note: don't assume buddy is non-NULL; will be if lookup random user not on blist. */ |
17382
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1118 |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1119 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:
17381
diff
changeset
|
1120 |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1121 /* Identification */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1122 purple_notify_user_info_add_pair(user_info, _("User"), user); |
17382
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1123 |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1124 /* note: g_hash_table_lookup does not create a new string! */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1125 purple_notify_user_info_add_pair(user_info, _("User ID"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1126 g_strdup(g_hash_table_lookup(body, "UserID"))); |
17382
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1127 |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1128 /* a/s/l...the vitals */ |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1129 purple_notify_user_info_add_pair(user_info, _("Age"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1130 g_strdup(g_hash_table_lookup(body, "Age"))); |
17382
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1131 |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1132 purple_notify_user_info_add_pair(user_info, _("Gender"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1133 g_strdup(g_hash_table_lookup(body, "Gender"))); |
17382
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1134 |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1135 purple_notify_user_info_add_pair(user_info, _("Location"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1136 g_strdup(g_hash_table_lookup(body, "Location"))); |
17382
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1137 |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1138 /* Other information */ |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1139 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1140 /* Headline comes from buddy status messages */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1141 if (buddy && purple_blist_node_get_string(&buddy->node, "Headline")) |
17382
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1142 purple_notify_user_info_add_pair(user_info, "Headline", |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1143 purple_blist_node_get_string(&buddy->node, "Headline")); |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1144 |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1145 song = g_strdup_printf("%s - %s", |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1146 (gchar *)g_hash_table_lookup(body, "BandName"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1147 (gchar *)g_hash_table_lookup(body, "SongName")); |
17382
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1148 |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1149 |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1150 purple_notify_user_info_add_pair(user_info, _("Song"), song); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1151 /* Do not free song - used by user_info. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1152 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1153 /* Total friends only available if looked up by uid, not username. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1154 if (g_hash_table_lookup(body, "TotalFriends")) |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1155 purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1156 g_strdup(g_hash_table_lookup(body, "TotalFriends"))); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1157 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1158 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:
17898
diff
changeset
|
1159 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:
17898
diff
changeset
|
1160 //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:
17898
diff
changeset
|
1161 /* 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:
17898
diff
changeset
|
1162 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1163 //g_hash_table_destroy(body); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1164 } |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1165 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1166 /** Retrieve a user's profile. */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1167 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1168 msim_get_info(PurpleConnection *gc, const gchar *user) |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1169 { |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1170 PurpleBuddy *buddy; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1171 MsimSession *session; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1172 guint uid; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1173 gchar *user_to_lookup; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1174 MsimMessage *user_msg; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1175 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1176 session = (MsimSession *)gc->proto_data; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1177 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1178 /* Obtain uid of buddy. */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1179 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:
17898
diff
changeset
|
1180 if (buddy) |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1181 { |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1182 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:
17898
diff
changeset
|
1183 if (!uid) |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1184 { |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1185 PurpleNotifyUserInfo *user_info; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1186 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1187 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:
17898
diff
changeset
|
1188 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:
17898
diff
changeset
|
1189 _("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:
17898
diff
changeset
|
1190 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1191 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:
17898
diff
changeset
|
1192 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:
17898
diff
changeset
|
1193 return; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1194 } |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1195 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1196 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:
17898
diff
changeset
|
1197 } else { |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1198 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1199 /* 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:
17898
diff
changeset
|
1200 user_to_lookup = g_strdup(user); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1201 } |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1202 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1203 /* 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:
17898
diff
changeset
|
1204 * 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:
17898
diff
changeset
|
1205 * the username). |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1206 */ |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1207 user_msg = msim_msg_new(TRUE, |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1208 "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:
17898
diff
changeset
|
1209 NULL); |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1210 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:
17898
diff
changeset
|
1211 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1212 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:
17898
diff
changeset
|
1213 |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1214 g_free(user_to_lookup); |
17382
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1215 } |
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
1216 |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1217 /** 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:
17362
diff
changeset
|
1218 * |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1219 * @param session |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1220 * @param userinfo Response messsage to resolving request. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1221 * @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:
17362
diff
changeset
|
1222 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1223 static void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1224 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:
17903
diff
changeset
|
1225 gpointer data) |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1226 { |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1227 gchar *body_str; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1228 GHashTable *body; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1229 gchar *username; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1230 MsimMessage *msg; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1231 |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1232 body_str = msim_msg_get_string(userinfo, "body"); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1233 g_return_if_fail(body_str != NULL); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1234 body = msim_parse_body(body_str); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1235 g_return_if_fail(body != NULL); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1236 g_free(body_str); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1237 |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1238 username = g_hash_table_lookup(body, "UserName"); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1239 g_return_if_fail(username != NULL); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1240 |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1241 msg = (MsimMessage *)data; |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1242 /* 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:
17362
diff
changeset
|
1243 * program (did not come from the wire). */ |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1244 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:
17362
diff
changeset
|
1245 |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1246 msim_process(session, msg); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1247 |
17364
e64bcff3b674
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17363
diff
changeset
|
1248 /* TODO: Free copy cloned from msim_preprocess_incoming(). */ |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1249 //XXX msim_msg_free(msg); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1250 g_hash_table_destroy(body); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1251 } |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1252 |
17912
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1253 #if 0 |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1254 /* 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:
17369
diff
changeset
|
1255 * |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1256 * @param wanted_uid |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1257 * |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1258 * @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:
17369
diff
changeset
|
1259 * |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1260 * 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:
17369
diff
changeset
|
1261 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1262 static const gchar * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1263 msim_uid2username_from_blist(MsimSession *session, guint wanted_uid) |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1264 { |
17912
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1265 GSList *buddies, *cur; |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1266 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1267 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:
17911
diff
changeset
|
1268 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1269 if (!buddies) |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1270 { |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1271 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:
17911
diff
changeset
|
1272 return NULL; |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1273 } |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1274 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1275 for (cur = buddies; cur != NULL; cur = g_slist_next(cur)) |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1276 { |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1277 PurpleBuddy *buddy; |
17912
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1278 //PurpleBlistNode *node; |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1279 guint uid; |
17912
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1280 const gchar *name; |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1281 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1282 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1283 /* See finch/gnthistory.c */ |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1284 buddy = cur->data; |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1285 //node = cur->data; |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1286 |
17379
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1287 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
17912
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1288 //uid = purple_blist_node_get_int(node, "UserID"); |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1289 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1290 /* name = buddy->name; */ /* crash */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1291 /* 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:
17369
diff
changeset
|
1292 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1293 /* 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:
17369
diff
changeset
|
1294 * 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:
17369
diff
changeset
|
1295 name = purple_buddy_get_name(buddy); /* crash */ |
17912
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1296 //name = purple_buddy_get_name((PurpleBuddy *)node); /* crash */ |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1297 /* return name; */ /* crash (with above) */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1298 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1299 /* name = NULL; */ /* no crash */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1300 /* 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:
17369
diff
changeset
|
1301 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1302 /* crash = |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1303 *** 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:
17369
diff
changeset
|
1304 ======= Backtrace: ========= |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1305 /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:
17369
diff
changeset
|
1306 /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:
17369
diff
changeset
|
1307 /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:
17369
diff
changeset
|
1308 /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:
17369
diff
changeset
|
1309 /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:
17369
diff
changeset
|
1310 /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:
17369
diff
changeset
|
1311 /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:
17369
diff
changeset
|
1312 /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:
17369
diff
changeset
|
1313 /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:
17369
diff
changeset
|
1314 /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:
17369
diff
changeset
|
1315 pidgin(main+0x8be)[0x46b45e] |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1316 /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:
17369
diff
changeset
|
1317 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:
17369
diff
changeset
|
1318 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1319 or: |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1320 *** 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:
17369
diff
changeset
|
1321 (gdb) bt |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1322 #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:
17369
diff
changeset
|
1323 #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:
17369
diff
changeset
|
1324 #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:
17369
diff
changeset
|
1325 #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:
17369
diff
changeset
|
1326 #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:
17369
diff
changeset
|
1327 #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:
17369
diff
changeset
|
1328 #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:
17369
diff
changeset
|
1329 #7 0x00002b407810969f in msim_parse ( |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1330 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:
17369
diff
changeset
|
1331 at message.c:648 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1332 #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:
17369
diff
changeset
|
1333 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:
17369
diff
changeset
|
1334 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1335 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1336 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:
17369
diff
changeset
|
1337 */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1338 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:
17369
diff
changeset
|
1339 name, uid, wanted_uid); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1340 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1341 if (uid == wanted_uid) |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1342 { |
17912
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1343 gchar *ret; |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1344 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1345 ret = g_strdup(name); |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1346 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1347 g_slist_free(buddies); |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1348 |
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1349 return ret; |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1350 } |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1351 } |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1352 |
17912
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1353 g_slist_free(buddies); |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1354 return NULL; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1355 } |
17371
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17370
diff
changeset
|
1356 #endif |
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17370
diff
changeset
|
1357 |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1358 /** 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:
17362
diff
changeset
|
1359 * |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1360 * @param session |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1361 * @param msg MsimMessage *, freed by caller. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1362 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1363 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1364 msim_preprocess_incoming(MsimSession *session, MsimMessage *msg) |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1365 { |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1366 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:
17362
diff
changeset
|
1367 { |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1368 guint uid; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1369 const gchar *username; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1370 |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1371 /* 'f' = userid message is from, in buddy messages */ |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1372 uid = msim_msg_get_integer(msg, "f"); |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1373 |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1374 /* 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:
17369
diff
changeset
|
1375 * it crashes for unknown reasons, memory realloc error. */ |
17912
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1376 #if 0 |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1377 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:
17369
diff
changeset
|
1378 #else |
17912
d727fda5a8e1
Change around msim_uid2username_from_blist() to try to get it to work
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17911
diff
changeset
|
1379 username = NULL; |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1380 #endif |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1381 |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1382 if (username) |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1383 { |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1384 /* Know username already, use it. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1385 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:
17369
diff
changeset
|
1386 username); |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1387 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:
17369
diff
changeset
|
1388 return msim_process(session, msg); |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1389 |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1390 } else { |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1391 gchar *from; |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1392 |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1393 /* Send lookup request. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1394 /* 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:
17369
diff
changeset
|
1395 purple_debug_info("msim", "msim_incoming: sending lookup, setting up callback\n"); |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
1396 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:
17898
diff
changeset
|
1397 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:
17898
diff
changeset
|
1398 g_free(from); |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1399 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1400 /* indeterminate */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1401 return TRUE; |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1402 } |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1403 } else { |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1404 /* Nothing to resolve - send directly to processing. */ |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1405 return msim_process(session, msg); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1406 } |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1407 } |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1408 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1409 /** |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1410 * Process a message. |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1411 * |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1412 * @param session |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1413 * @param msg A message from the server, ready for processing (possibly with resolved username information attached). Caller frees. |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1414 * |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1415 * @return TRUE if successful. FALSE if processing failed. |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1416 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1417 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1418 msim_process(MsimSession *session, MsimMessage *msg) |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1419 { |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1420 g_return_val_if_fail(session != NULL, -1); |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
1421 g_return_val_if_fail(msg != NULL, -1); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1422 |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
1423 #ifdef MSIM_DEBUG_MSG |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
1424 { |
17355
9c5b1dc7404f
Change msim_msg_debug_string() to msim_msg_dump(), which prints the string
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17354
diff
changeset
|
1425 msim_msg_dump("ready to process: %s\n", msg); |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
1426 } |
16408
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
1427 #endif |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1428 |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1429 if (msim_msg_get(msg, "nc")) |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1430 { |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1431 return msim_login_challenge(session, msg); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1432 } else if (msim_msg_get(msg, "sesskey")) { |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1433 |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1434 purple_connection_update_progress(session->gc, _("Connected"), 3, 4); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1435 |
17354
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17353
diff
changeset
|
1436 session->sesskey = msim_msg_get_integer(msg, "sesskey"); |
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17353
diff
changeset
|
1437 purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1438 |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1439 /* Comes with: proof,profileid,userid,uniquenick -- all same values |
17380
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
1440 * some of the time, but can vary. This is our own user ID. */ |
17373
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
1441 session->userid = msim_msg_get_integer(msg, "userid"); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1442 |
17380
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
1443 /* TODO: fake our own userid being online */ |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
1444 |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1445 purple_connection_set_state(session->gc, PURPLE_CONNECTED); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1446 |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1447 return TRUE; |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1448 } else if (msim_msg_get(msg, "bm")) { |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1449 guint bm; |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1450 |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1451 bm = msim_msg_get_integer(msg, "bm"); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1452 switch (bm) |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1453 { |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1454 case MSIM_BM_STATUS: |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1455 return msim_status(session, msg); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1456 case MSIM_BM_INSTANT: |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1457 return msim_incoming_im(session, msg); |
17347
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1458 case MSIM_BM_ACTION: |
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1459 return msim_incoming_action(session, msg); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1460 default: |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1461 /* Not really an IM, but show it for informational |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1462 * purposes during development. */ |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1463 return msim_incoming_im(session, msg); |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1464 } |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1465 } else if (msim_msg_get(msg, "rid")) { |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1466 return msim_process_reply(session, msg); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1467 } else if (msim_msg_get(msg, "error")) { |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1468 return msim_error(session, msg); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1469 } else if (msim_msg_get(msg, "ka")) { |
17893
0d799da3b893
Add TODO for msimprpl to timeout (handling keep-alives).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17892
diff
changeset
|
1470 /* 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:
17892
diff
changeset
|
1471 * 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:
17892
diff
changeset
|
1472 * 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:
17892
diff
changeset
|
1473 * other plugins (oscar, etc.) will time out. Msimprpl should timeout too. */ |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1474 purple_debug_info("msim", "msim_process: got keep alive\n"); |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1475 return TRUE; |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1476 } else { |
17894
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
1477 msim_unrecognized(session, msg, "in msim_process"); |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1478 return FALSE; |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1479 } |
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1480 } |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
1481 |
17379
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1482 /** Store an field of information about a buddy. */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1483 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1484 msim_store_buddy_info_each(gpointer key, gpointer value, gpointer user_data) |
17379
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1485 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1486 PurpleBuddy *buddy; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1487 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:
17377
diff
changeset
|
1488 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1489 buddy = (PurpleBuddy *)user_data; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1490 key_str = (gchar *)key; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1491 value_str = (gchar *)value; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1492 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1493 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:
17377
diff
changeset
|
1494 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:
17377
diff
changeset
|
1495 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:
17377
diff
changeset
|
1496 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1497 /* 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:
17377
diff
changeset
|
1498 * 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:
17377
diff
changeset
|
1499 * 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:
17377
diff
changeset
|
1500 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:
17377
diff
changeset
|
1501 } else { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1502 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:
17377
diff
changeset
|
1503 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1504 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1505 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1506 /** 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:
17377
diff
changeset
|
1507 * |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1508 * @param session |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1509 * @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:
17377
diff
changeset
|
1510 * |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1511 * 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:
17377
diff
changeset
|
1512 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1513 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1514 msim_store_buddy_info(MsimSession *session, MsimMessage *msg) |
17379
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1515 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1516 GHashTable *body; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1517 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:
17377
diff
changeset
|
1518 PurpleBuddy *buddy; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1519 guint rid; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1520 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1521 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:
17377
diff
changeset
|
1522 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1523 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:
17377
diff
changeset
|
1524 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1525 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:
17377
diff
changeset
|
1526 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:
17377
diff
changeset
|
1527 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:
17377
diff
changeset
|
1528 g_free(body_str); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1529 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1530 /* 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:
17377
diff
changeset
|
1531 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:
17377
diff
changeset
|
1532 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1533 if (!username) |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1534 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1535 purple_debug_info("msim", |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1536 "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:
17377
diff
changeset
|
1537 return FALSE; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1538 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1539 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1540 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:
17377
diff
changeset
|
1541 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:
17377
diff
changeset
|
1542 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1543 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:
17377
diff
changeset
|
1544 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1545 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:
17377
diff
changeset
|
1546 if (buddy) |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1547 { |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1548 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:
17377
diff
changeset
|
1549 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1550 |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1551 return TRUE; |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1552 } |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1553 |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
1554 /** |
17347
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
1555 * Process a persistance message reply from the server. |
16395 | 1556 * |
1557 * @param session | |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1558 * @param msg Message reply from server. |
16395 | 1559 * |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1560 * @return TRUE if successful. |
16395 | 1561 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1562 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1563 msim_process_reply(MsimSession *session, MsimMessage *msg) |
16395 | 1564 { |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1565 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:
17347
diff
changeset
|
1566 g_return_val_if_fail(msg != NULL, FALSE); |
16395 | 1567 |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1568 if (msim_msg_get(msg, "rid")) /* msim_lookup_user sets callback for here */ |
16395 | 1569 { |
1570 MSIM_USER_LOOKUP_CB cb; | |
1571 gpointer data; | |
1572 guint rid; | |
17371
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17370
diff
changeset
|
1573 |
17379
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1574 msim_store_buddy_info(session, msg); |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
1575 |
17379
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1576 rid = msim_msg_get_integer(msg, "rid"); |
16395 | 1577 |
1578 /* If a callback is registered for this userid lookup, call it. */ | |
1579 cb = g_hash_table_lookup(session->user_lookup_cb, GUINT_TO_POINTER(rid)); | |
1580 data = g_hash_table_lookup(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); | |
1581 | |
1582 if (cb) | |
1583 { | |
16405
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
1584 purple_debug_info("msim", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
1585 "msim_process_body: calling callback now\n"); |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1586 /* 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:
17347
diff
changeset
|
1587 cb(session, msim_msg_clone(msg), data); |
16395 | 1588 g_hash_table_remove(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
1589 g_hash_table_remove(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); | |
1590 } else { | |
16405
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
1591 purple_debug_info("msim", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
1592 "msim_process_body: no callback for rid %d\n", rid); |
16395 | 1593 } |
1594 } | |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1595 |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1596 return TRUE; |
16395 | 1597 } |
1598 | |
1599 /** | |
1600 * Handle an error from the server. | |
1601 * | |
1602 * @param session | |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1603 * @param msg The message. |
16395 | 1604 * |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1605 * @return TRUE if successfully reported error. |
16395 | 1606 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1607 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1608 msim_error(MsimSession *session, MsimMessage *msg) |
16395 | 1609 { |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1610 gchar *errmsg, *full_errmsg; |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1611 guint err; |
16395 | 1612 |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1613 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:
17347
diff
changeset
|
1614 g_return_val_if_fail(msg != NULL, FALSE); |
16395 | 1615 |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1616 err = msim_msg_get_integer(msg, "err"); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1617 errmsg = msim_msg_get_string(msg, "errmsg"); |
16395 | 1618 |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1619 full_errmsg = g_strdup_printf(_("Protocol error, code %d: %s"), err, errmsg); |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1620 |
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1621 g_free(errmsg); |
16395 | 1622 |
16397 | 1623 purple_debug_info("msim", "msim_error: %s\n", full_errmsg); |
16395 | 1624 |
16739
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
1625 purple_notify_error(session->account, g_strdup(_("MySpaceIM Error")), |
16395 | 1626 full_errmsg, NULL); |
1627 | |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1628 /* Destroy session if fatal. */ |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
1629 if (msim_msg_get(msg, "fatal")) |
16395 | 1630 { |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
1631 purple_debug_info("msim", "fatal error, closing\n"); |
16397 | 1632 purple_connection_error(session->gc, full_errmsg); |
16395 | 1633 } |
1634 | |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1635 return TRUE; |
16395 | 1636 } |
1637 | |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1638 /** |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1639 * Process incoming status messages. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1640 * |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1641 * @param session |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1642 * @param msg Status update message. Caller frees. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1643 * |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1644 * @return TRUE if successful. |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1645 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1646 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1647 msim_status(MsimSession *session, MsimMessage *msg) |
16395 | 1648 { |
16397 | 1649 PurpleBuddyList *blist; |
1650 PurpleBuddy *buddy; | |
1651 //PurpleStatus *status; | |
16395 | 1652 gchar **status_array; |
1653 GList *list; | |
17346
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1654 gchar *status_headline; |
16395 | 1655 gchar *status_str; |
17346
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1656 gint i, status_code, purple_status_code; |
16395 | 1657 gchar *username; |
1658 | |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1659 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:
17362
diff
changeset
|
1660 g_return_val_if_fail(msg != NULL, FALSE); |
17362
6476a55a9542
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17361
diff
changeset
|
1661 |
6476a55a9542
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17361
diff
changeset
|
1662 status_str = msim_msg_get_string(msg, "msg"); |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1663 g_return_val_if_fail(status_str != NULL, FALSE); |
16395 | 1664 |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1665 msim_msg_dump("msim_status msg=%s\n", msg); |
16395 | 1666 |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1667 /* 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:
17362
diff
changeset
|
1668 username = msim_msg_get_string(msg, "_username"); |
16395 | 1669 /* Note: DisplayName doesn't seem to be resolvable. It could be displayed on |
1670 * the buddy list, if the UserID was stored along with it. */ | |
1671 | |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1672 if (username == NULL) |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1673 { |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1674 g_free(status_str); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1675 g_return_val_if_fail(NULL, FALSE); |
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1676 } |
16395 | 1677 |
16405
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
1678 purple_debug_info("msim", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
1679 "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:
16403
diff
changeset
|
1680 username, status_str); |
16395 | 1681 |
17346
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1682 /* TODO: generic functions to split into a GList, part of MsimMessage */ |
16395 | 1683 status_array = g_strsplit(status_str, "|", 0); |
1684 for (list = NULL, i = 0; | |
1685 status_array[i]; | |
1686 i++) | |
1687 { | |
17346
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1688 /* 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:
17344
diff
changeset
|
1689 * 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:
17344
diff
changeset
|
1690 */ |
16395 | 1691 list = g_list_append(list, status_array[i]); |
1692 } | |
1693 | |
17346
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1694 /* Example fields: |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1695 * |s|0|ss|Offline |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1696 * |s|1|ss|:-)|ls||ip|0|p|0 |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1697 * |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1698 * 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:
17344
diff
changeset
|
1699 */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1700 |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1701 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:
17344
diff
changeset
|
1702 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:
17344
diff
changeset
|
1703 status_headline = g_list_nth_data(list, MSIM_STATUS_ORDINAL_HEADLINE); |
16395 | 1704 |
16397 | 1705 blist = purple_get_blist(); |
16395 | 1706 |
1707 /* Add buddy if not found */ | |
16397 | 1708 buddy = purple_find_buddy(session->account, username); |
16395 | 1709 if (!buddy) |
1710 { | |
16405
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
1711 purple_debug_info("msim", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
1712 "msim_status: making new buddy for %s\n", username); |
16397 | 1713 buddy = purple_buddy_new(session->account, username, NULL); |
16395 | 1714 |
16397 | 1715 purple_blist_add_buddy(buddy, NULL, NULL, NULL); |
17380
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
1716 |
17356
c6305f8845d8
Add TODOs about username/email->userid resolution, use g_return_if_fail() in a few places.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17355
diff
changeset
|
1717 /* All buddies on list should have 'uid' integer associated with them. */ |
17379
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1718 purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f")); |
17380
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
1719 |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
1720 msim_store_buddy_info(session, msg); |
16395 | 1721 } else { |
16397 | 1722 purple_debug_info("msim", "msim_status: found buddy %s\n", username); |
16395 | 1723 } |
1724 | |
17380
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
1725 purple_blist_node_set_string(&buddy->node, "Headline", status_headline); |
17346
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1726 |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1727 /* Set user status */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1728 switch (status_code) |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1729 { |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1730 case 1: purple_status_code = PURPLE_STATUS_AVAILABLE; |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1731 break; |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1732 case 0: purple_status_code = PURPLE_STATUS_OFFLINE; |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1733 break; |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1734 default: |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1735 purple_debug_info("msim", "msim_status_cb for %s, unknown status code %d\n", |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1736 username, status_code); |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1737 purple_status_code = PURPLE_STATUS_AVAILABLE; |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1738 } |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
1739 purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL); |
16395 | 1740 |
1741 g_strfreev(status_array); | |
17362
6476a55a9542
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17361
diff
changeset
|
1742 g_free(status_str); |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
1743 g_free(username); |
16395 | 1744 g_list_free(list); |
1745 | |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
1746 return TRUE; |
16395 | 1747 } |
1748 | |
17388
b33a6f16356a
Update several outdated TODO comments.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17387
diff
changeset
|
1749 /** Add a buddy to user's buddy list. */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1750 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1751 msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
17350
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1752 { |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1753 MsimSession *session; |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1754 MsimMessage *msg; |
17897
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1755 /* MsimMessage *msg_blocklist; */ |
17350
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1756 |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1757 session = (MsimSession *)gc->proto_data; |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1758 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:
17348
diff
changeset
|
1759 group ? group->name : "(no group)"); |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1760 |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1761 msg = msim_msg_new(TRUE, |
17350
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1762 "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
17354
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17353
diff
changeset
|
1763 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1764 /* "newprofileid" will be inserted here with uid. */ |
17350
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1765 "reason", MSIM_TYPE_STRING, g_strdup(""), |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1766 NULL); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1767 |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1768 if (!msim_postprocess_outgoing(session, msg, buddy->name, "newprofileid", "reason")) |
17350
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1769 { |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1770 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed.")); |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1771 msim_msg_free(msg); |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
1772 return; |
17350
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1773 } |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1774 msim_msg_free(msg); |
17897
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1775 |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1776 /* 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:
17896
diff
changeset
|
1777 * buddy list since Purple adds it locally. */ |
17350
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1778 |
17897
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1779 /* TODO: Update blocklist. */ |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1780 #if 0 |
17897
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1781 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:
17896
diff
changeset
|
1782 "persist", MSIM_TYPE_INTEGER, 1, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1783 "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:
17896
diff
changeset
|
1784 "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:
17896
diff
changeset
|
1785 "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:
17896
diff
changeset
|
1786 "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:
17896
diff
changeset
|
1787 /* 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:
17896
diff
changeset
|
1788 "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:
17896
diff
changeset
|
1789 "body", MSIM_TYPE_STRING, |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1790 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:
17896
diff
changeset
|
1791 "GroupName=%s\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1792 "Position=1000\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1793 "Visibility=1\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1794 "NickName=\034" |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1795 "NameSelect=0", |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1796 "Friends" /*group->name*/ )); |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1797 |
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1798 if (!msim_postprocess_outgoing(session, msg, buddy->name, "body", NULL)) |
17350
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1799 { |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1800 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); |
17897
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1801 msim_msg_free(msg_blocklist); |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
1802 return; |
17350
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1803 } |
17897
72f0a6fc6024
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17896
diff
changeset
|
1804 msim_msg_free(msg_blocklist); |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1805 #endif |
17350
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1806 } |
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
1807 |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1808 /** 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:
17374
diff
changeset
|
1809 * |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1810 * @param msg The message to postprocess. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1811 * @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:
17374
diff
changeset
|
1812 * @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:
17374
diff
changeset
|
1813 * @param uid The userid to insert. |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1814 * |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1815 * 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:
17374
diff
changeset
|
1816 * 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:
17374
diff
changeset
|
1817 * |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1818 * 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:
17374
diff
changeset
|
1819 * 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:
17374
diff
changeset
|
1820 * |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1821 * 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:
17374
diff
changeset
|
1822 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1823 MsimMessage * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1824 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:
17903
diff
changeset
|
1825 const gchar *uid_field_name, guint uid) |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1826 { |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1827 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:
17374
diff
changeset
|
1828 uid_field_name, uid_before, uid); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1829 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:
17374
diff
changeset
|
1830 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1831 /* 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:
17374
diff
changeset
|
1832 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:
17374
diff
changeset
|
1833 { |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1834 MsimMessageElement *elem; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1835 gchar *fmt_string; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1836 gchar *uid_str; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1837 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1838 /* 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:
17374
diff
changeset
|
1839 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1840 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:
17374
diff
changeset
|
1841 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:
17374
diff
changeset
|
1842 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1843 /* 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:
17374
diff
changeset
|
1844 * 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:
17374
diff
changeset
|
1845 fmt_string = (gchar *)(elem->data); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1846 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1847 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:
17374
diff
changeset
|
1848 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:
17374
diff
changeset
|
1849 g_free(uid_str); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1850 g_free(fmt_string); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1851 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1852 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:
17374
diff
changeset
|
1853 elem->data); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1854 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1855 } else { |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1856 /* 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:
17374
diff
changeset
|
1857 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:
17374
diff
changeset
|
1858 } |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1859 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1860 return msg; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1861 } |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1862 |
17373
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
1863 /** 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:
17372
diff
changeset
|
1864 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
1865 * @param session |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
1866 * @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:
17372
diff
changeset
|
1867 * @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:
17372
diff
changeset
|
1868 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
1869 * 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:
17372
diff
changeset
|
1870 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
1871 * _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:
17372
diff
changeset
|
1872 * _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:
17372
diff
changeset
|
1873 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
1874 * |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1875 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1876 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1877 msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1878 { |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1879 gchar *body_str; |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1880 GHashTable *body; |
17368
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17367
diff
changeset
|
1881 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:
17367
diff
changeset
|
1882 MsimMessage *msg; |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1883 |
17368
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17367
diff
changeset
|
1884 msg = (MsimMessage *)data; |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17367
diff
changeset
|
1885 |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17367
diff
changeset
|
1886 msim_msg_dump("msim_postprocess_outgoing_cb() got msg=%s\n", msg); |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1887 |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1888 /* Obtain userid from userinfo message. */ |
17367
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1889 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:
17366
diff
changeset
|
1890 g_return_if_fail(body_str != NULL); |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1891 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:
17365
diff
changeset
|
1892 g_free(body_str); |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1893 |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1894 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:
17365
diff
changeset
|
1895 g_hash_table_destroy(body); |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1896 |
17368
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17367
diff
changeset
|
1897 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:
17367
diff
changeset
|
1898 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:
17367
diff
changeset
|
1899 |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1900 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, atol(uid)); |
17373
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
1901 |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1902 /* Send */ |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1903 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:
17368
diff
changeset
|
1904 { |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1905 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:
17368
diff
changeset
|
1906 } |
17368
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17367
diff
changeset
|
1907 |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1908 |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1909 /* 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:
17368
diff
changeset
|
1910 * 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:
17368
diff
changeset
|
1911 */ |
17368
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17367
diff
changeset
|
1912 g_free(uid_field_name); |
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17367
diff
changeset
|
1913 g_free(uid_before); |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1914 |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1915 //msim_msg_free(msg); |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1916 } |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1917 |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1918 /** Postprocess and send a message. |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1919 * |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1920 * @param session |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1921 * @param msg Message to postprocess. Will NOT be freed. |
17368
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17367
diff
changeset
|
1922 * @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:
17367
diff
changeset
|
1923 * @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:
17367
diff
changeset
|
1924 * @param uid_before Name of existing field to insert username field before. Static string. |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1925 * |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1926 * @return Postprocessed message. |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1927 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1928 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1929 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:
17903
diff
changeset
|
1930 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:
17903
diff
changeset
|
1931 const gchar *uid_before) |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1932 { |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1933 PurpleBuddy *buddy; |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1934 guint uid; |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1935 gboolean rc; |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1936 |
17368
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17367
diff
changeset
|
1937 /* 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:
17367
diff
changeset
|
1938 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:
17367
diff
changeset
|
1939 username, uid_field_name, uid_before); |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1940 msim_msg_dump("msim_postprocess_outgoing: msg before=%s\n", msg); |
17368
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17367
diff
changeset
|
1941 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:
17367
diff
changeset
|
1942 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:
17367
diff
changeset
|
1943 msg = msim_msg_append(msg, "_uid_before", MSIM_TYPE_STRING, g_strdup(uid_before)); |
17367
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1944 |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1945 /* 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:
17366
diff
changeset
|
1946 if (msim_is_userid(username)) |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1947 { |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1948 uid = atol(username); |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1949 } else { |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1950 /* 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:
17366
diff
changeset
|
1951 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:
17366
diff
changeset
|
1952 if (buddy) |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1953 { |
17379
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
1954 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
17367
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1955 } else { |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1956 uid = 0; |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1957 } |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1958 |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1959 if (!buddy || !uid) |
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1960 { |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1961 /* Don't have uid offhand - need to ask for it, and wait until hear back before sending. */ |
17367
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1962 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:
17366
diff
changeset
|
1963 username); |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1964 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:
17368
diff
changeset
|
1965 /* TODO: where is cloned message freed? Should be in _cb. */ |
17368
3720176bdac6
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17367
diff
changeset
|
1966 msim_lookup_user(session, username, msim_postprocess_outgoing_cb, msim_msg_clone(msg)); |
17367
05723949f75d
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17366
diff
changeset
|
1967 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:
17366
diff
changeset
|
1968 } |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1969 } |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1970 |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1971 /* Already have uid, postprocess and send msg immediately. */ |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1972 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:
17365
diff
changeset
|
1973 username, uid); |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1974 |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1975 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, uid); |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1976 |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1977 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:
17374
diff
changeset
|
1978 |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1979 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:
17368
diff
changeset
|
1980 |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1981 //msim_msg_free(msg); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1982 |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
1983 return rc; |
17366
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1984 } |
25a55b52855a
Add, but do not use, two new functions to postprocess outgoing messages
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17365
diff
changeset
|
1985 |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
1986 /** Remove a buddy from the user's buddy list. */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1987 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
1988 msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
1989 { |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
1990 MsimSession *session; |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1991 MsimMessage *delbuddy_msg; |
17373
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
1992 MsimMessage *persist_msg; |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1993 MsimMessage *blocklist_msg; |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
1994 |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
1995 session = (MsimSession *)gc->proto_data; |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
1996 |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
1997 delbuddy_msg = msim_msg_new(TRUE, |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
1998 "delbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
17354
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17353
diff
changeset
|
1999 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
2000 /* '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:
17368
diff
changeset
|
2001 NULL); |
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
2002 /* TODO: free msg */ |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2003 if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL)) |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2004 { |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2005 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed")); |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2006 return; |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2007 } |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2008 |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2009 persist_msg = msim_msg_new(TRUE, |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2010 "persist", MSIM_TYPE_INTEGER, 1, |
17354
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17353
diff
changeset
|
2011 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2012 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE, |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2013 "dsn", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_DSN, |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2014 "lid", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_LID, |
17374
e9dfd3a5d4b6
Remove msim_get_own_uid{,_cb}() - it is not needed, since the login
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17373
diff
changeset
|
2015 "uid", MSIM_TYPE_INTEGER, session->userid, |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2016 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2017 /* <uid> will be replaced by postprocessing */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2018 "body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"), |
17373
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2019 NULL); |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2020 |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2021 /* TODO: free msg */ |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2022 if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL)) |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2023 { |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2024 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed")); |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2025 return; |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2026 } |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2027 |
17376
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2028 blocklist_msg = msim_msg_new(TRUE, |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2029 "blocklist", MSIM_TYPE_BOOLEAN, TRUE, |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2030 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2031 /* TODO: MsimMessage lists */ |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2032 "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:
17374
diff
changeset
|
2033 NULL); |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2034 |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2035 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:
17374
diff
changeset
|
2036 { |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2037 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:
17374
diff
changeset
|
2038 return; |
4cb842e0649c
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17374
diff
changeset
|
2039 } |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2040 } |
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2041 |
17381
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17380
diff
changeset
|
2042 /** 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:
17380
diff
changeset
|
2043 * |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2044 * 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:
17903
diff
changeset
|
2045 * messages. |
17381
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17380
diff
changeset
|
2046 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2047 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2048 msim_offline_message(const PurpleBuddy *buddy) |
17381
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17380
diff
changeset
|
2049 { |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17380
diff
changeset
|
2050 return TRUE; |
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17380
diff
changeset
|
2051 } |
16395 | 2052 |
2053 /** | |
2054 * Callback when input available. | |
2055 * | |
16397 | 2056 * @param gc_uncasted A PurpleConnection pointer. |
16395 | 2057 * @param source File descriptor. |
16397 | 2058 * @param cond PURPLE_INPUT_READ |
16395 | 2059 * |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
2060 * Reads the input, and calls msim_preprocess_incoming() to handle it. |
16395 | 2061 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2062 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2063 msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond) |
16395 | 2064 { |
16397 | 2065 PurpleConnection *gc; |
2066 PurpleAccount *account; | |
16395 | 2067 MsimSession *session; |
2068 gchar *end; | |
2069 int n; | |
2070 | |
2071 g_return_if_fail(gc_uncasted != NULL); | |
2072 g_return_if_fail(source >= 0); /* Note: 0 is a valid fd */ | |
2073 | |
16749
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16747
diff
changeset
|
2074 gc = (PurpleConnection *)(gc_uncasted); |
16397 | 2075 account = purple_connection_get_account(gc); |
16395 | 2076 session = gc->proto_data; |
2077 | |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
2078 g_return_if_fail(cond == PURPLE_INPUT_READ); |
17371
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17370
diff
changeset
|
2079 g_return_if_fail(MSIM_SESSION_VALID(session)); |
16395 | 2080 |
2081 /* Only can handle so much data at once... | |
2082 * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE. | |
2083 * Should be large enough to hold the largest protocol message. | |
2084 */ | |
2085 if (session->rxoff == MSIM_READ_BUF_SIZE) | |
2086 { | |
16397 | 2087 purple_debug_error("msim", "msim_input_cb: %d-byte read buffer full!\n", |
16395 | 2088 MSIM_READ_BUF_SIZE); |
16739
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
2089 purple_connection_error(gc, _("Read buffer full")); |
16395 | 2090 return; |
2091 } | |
2092 | |
16397 | 2093 purple_debug_info("msim", "buffer at %d (max %d), reading up to %d\n", |
16405
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
2094 session->rxoff, MSIM_READ_BUF_SIZE, |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
2095 MSIM_READ_BUF_SIZE - session->rxoff); |
16395 | 2096 |
2097 /* Read into buffer. On Win32, need recv() not read(). session->fd also holds | |
2098 * the file descriptor, but it sometimes differs from the 'source' parameter. | |
2099 */ | |
2100 n = recv(session->fd, session->rxbuf + session->rxoff, MSIM_READ_BUF_SIZE - session->rxoff, 0); | |
2101 | |
2102 if (n < 0 && errno == EAGAIN) | |
2103 { | |
2104 return; | |
2105 } | |
2106 else if (n < 0) | |
2107 { | |
16397 | 2108 purple_debug_error("msim", "msim_input_cb: read error, ret=%d, " |
16395 | 2109 "error=%s, source=%d, fd=%d (%X))\n", |
2110 n, strerror(errno), source, session->fd, session->fd); | |
17906
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2111 purple_connection_error(gc, _("Read error")); |
16395 | 2112 return; |
2113 } | |
2114 else if (n == 0) | |
2115 { | |
16397 | 2116 purple_debug_info("msim", "msim_input_cb: server disconnected\n"); |
16739
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
2117 purple_connection_error(gc, _("Server has disconnected")); |
16395 | 2118 return; |
2119 } | |
2120 | |
2121 /* Null terminate */ | |
2122 session->rxbuf[session->rxoff + n] = 0; | |
2123 | |
2124 /* Check for embedded NULs. I don't handle them, and they shouldn't occur. */ | |
2125 if (strlen(session->rxbuf + session->rxoff) != n) | |
2126 { | |
2127 /* Occurs after login, but it is not a null byte. */ | |
16397 | 2128 purple_debug_info("msim", "msim_input_cb: strlen=%d, but read %d bytes" |
16405
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
2129 "--null byte encountered?\n", |
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
2130 strlen(session->rxbuf + session->rxoff), n); |
16397 | 2131 //purple_connection_error(gc, "Invalid message - null byte on input"); |
16395 | 2132 return; |
2133 } | |
2134 | |
2135 session->rxoff += n; | |
16397 | 2136 purple_debug_info("msim", "msim_input_cb: read=%d\n", n); |
16395 | 2137 |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
2138 #ifdef MSIM_DEBUG_RXBUF |
16408
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
2139 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:
16407
diff
changeset
|
2140 #endif |
16395 | 2141 |
2142 /* Look for \\final\\ end markers. If found, process message. */ | |
2143 while((end = strstr(session->rxbuf, MSIM_FINAL_STRING))) | |
2144 { | |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
2145 MsimMessage *msg; |
16395 | 2146 |
16736
58cd11fcd84f
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16734
diff
changeset
|
2147 #ifdef MSIM_DEBUG_RXBUF |
16408
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
2148 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:
16407
diff
changeset
|
2149 #endif |
16395 | 2150 *end = 0; |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
2151 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:
16749
diff
changeset
|
2152 if (!msg) |
16395 | 2153 { |
16405
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
2154 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:
16403
diff
changeset
|
2155 session->rxbuf); |
16739
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
2156 purple_connection_error(gc, _("Unparseable message")); |
16395 | 2157 } |
2158 else | |
2159 { | |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
2160 /* 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:
17347
diff
changeset
|
2161 * clone message if it wants to keep it afterwards.) */ |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
2162 if (!msim_preprocess_incoming(session, msg)) |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
2163 { |
17363
3a02e7db91c7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17362
diff
changeset
|
2164 msim_msg_dump("msim_input_cb: preprocessing message failed on msg: %s\n", msg); |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
2165 } |
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
2166 msim_msg_free(msg); |
16395 | 2167 } |
2168 | |
2169 /* Move remaining part of buffer to beginning. */ | |
2170 session->rxoff -= strlen(session->rxbuf) + strlen(MSIM_FINAL_STRING); | |
2171 memmove(session->rxbuf, end + strlen(MSIM_FINAL_STRING), | |
2172 MSIM_READ_BUF_SIZE - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf)); | |
2173 | |
2174 /* Clear end of buffer */ | |
2175 //memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf)); | |
2176 } | |
2177 } | |
2178 | |
17373
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2179 /* 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:
17372
diff
changeset
|
2180 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2181 * @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:
17372
diff
changeset
|
2182 * @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:
17372
diff
changeset
|
2183 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2184 * @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:
17372
diff
changeset
|
2185 * |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2186 * 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:
17372
diff
changeset
|
2187 * 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:
17372
diff
changeset
|
2188 * 2) data - make it an MsimMessage? |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2189 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2190 guint |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2191 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:
17903
diff
changeset
|
2192 gpointer data) |
17373
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2193 { |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2194 guint rid; |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2195 |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2196 rid = session->next_rid++; |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2197 |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2198 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:
17372
diff
changeset
|
2199 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:
17372
diff
changeset
|
2200 |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2201 return rid; |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2202 } |
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2203 |
16395 | 2204 /** |
2205 * Callback when connected. Sets up input handlers. | |
2206 * | |
16397 | 2207 * @param data A PurpleConnection pointer. |
16395 | 2208 * @param source File descriptor. |
2209 * @param error_message | |
2210 */ | |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2211 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2212 msim_connect_cb(gpointer data, gint source, const gchar *error_message) |
16395 | 2213 { |
16397 | 2214 PurpleConnection *gc; |
16395 | 2215 MsimSession *session; |
2216 | |
2217 g_return_if_fail(data != NULL); | |
2218 | |
16749
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16747
diff
changeset
|
2219 gc = (PurpleConnection *)data; |
17373
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2220 session = (MsimSession *)gc->proto_data; |
16395 | 2221 |
2222 if (source < 0) | |
2223 { | |
16739
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
2224 purple_connection_error(gc, _("Couldn't connect to host")); |
8f6dcd5e9298
Use _ for translations in msimprpl. See #648.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16738
diff
changeset
|
2225 purple_connection_error(gc, g_strdup_printf(_("Couldn't connect to host: %s (%d)"), |
16395 | 2226 error_message, source)); |
2227 return; | |
2228 } | |
2229 | |
2230 session->fd = source; | |
2231 | |
16397 | 2232 gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc); |
16395 | 2233 } |
2234 | |
2235 /* Session methods */ | |
2236 | |
2237 /** | |
2238 * Create a new MSIM session. | |
2239 * | |
2240 * @param acct The account to create the session from. | |
2241 * | |
2242 * @return Pointer to a new session. Free with msim_session_destroy. | |
2243 */ | |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2244 MsimSession * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2245 msim_session_new(PurpleAccount *acct) |
16395 | 2246 { |
2247 MsimSession *session; | |
2248 | |
2249 g_return_val_if_fail(acct != NULL, NULL); | |
2250 | |
2251 session = g_new0(MsimSession, 1); | |
2252 | |
2253 session->magic = MSIM_SESSION_STRUCT_MAGIC; | |
2254 session->account = acct; | |
16397 | 2255 session->gc = purple_account_get_connection(acct); |
16395 | 2256 session->fd = -1; |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
2257 |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
2258 /* TODO: Remove. */ |
16408
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
2259 session->user_lookup_cb = g_hash_table_new_full(g_direct_hash, |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
2260 g_direct_equal, NULL, NULL); /* do NOT free function pointers! (values) */ |
16408
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
2261 session->user_lookup_cb_data = g_hash_table_new_full(g_direct_hash, |
17360
ceba4fc06c41
Change msim_send_im_by_userid_cb() to msim_send_im_cb(), and remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17357
diff
changeset
|
2262 g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are, |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
2263 they could be integers inside gpointers |
17360
ceba4fc06c41
Change msim_send_im_by_userid_cb() to msim_send_im_cb(), and remove
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17357
diff
changeset
|
2264 or strings, so I don't freed them. |
17337
d3e17c9d16e9
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17323
diff
changeset
|
2265 Figure this out, once free cache. */ |
16395 | 2266 session->rxoff = 0; |
2267 session->rxbuf = g_new0(gchar, MSIM_READ_BUF_SIZE); | |
16408
bb649c52fc19
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16407
diff
changeset
|
2268 session->next_rid = 1; |
16395 | 2269 |
2270 return session; | |
2271 } | |
2272 | |
2273 /** | |
2274 * Free a session. | |
2275 * | |
2276 * @param session The session to destroy. | |
2277 */ | |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2278 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2279 msim_session_destroy(MsimSession *session) |
16395 | 2280 { |
2281 g_return_if_fail(MSIM_SESSION_VALID(session)); | |
17906
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2282 |
16395 | 2283 session->magic = -1; |
2284 | |
2285 g_free(session->rxbuf); | |
2286 | |
17370
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
2287 /* TODO: Remove. */ |
7a0061f4845d
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17369
diff
changeset
|
2288 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:
17369
diff
changeset
|
2289 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:
17369
diff
changeset
|
2290 |
16395 | 2291 g_free(session); |
2292 } | |
16406
8063f163f411
Add MySpaceIM header file and reorganize functions.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16405
diff
changeset
|
2293 |
16395 | 2294 /** |
2295 * Close the connection. | |
2296 * | |
2297 * @param gc The connection. | |
2298 */ | |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2299 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2300 msim_close(PurpleConnection *gc) |
16395 | 2301 { |
17371
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17370
diff
changeset
|
2302 MsimSession *session; |
17350
bfda36bd957a
Add incomplete msim_add_buddy() implementation.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17348
diff
changeset
|
2303 |
17906
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2304 if (gc == NULL) |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2305 return; |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2306 |
17371
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17370
diff
changeset
|
2307 session = (MsimSession *)gc->proto_data; |
17906
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2308 if (session == NULL) |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2309 return; |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2310 |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2311 gc->proto_data = NULL; |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2312 |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2313 if (!MSIM_SESSION_VALID(session)) |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2314 return; |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2315 |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2316 if (session->gc->inpa) |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2317 purple_input_remove(session->gc->inpa); |
814992cefc9c
Add a bunch of debugging to help fix #193.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17905
diff
changeset
|
2318 |
17371
948373cbba1c
Add TODO in order to fix msim_tooltip_text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17370
diff
changeset
|
2319 msim_session_destroy(session); |
16395 | 2320 } |
2321 | |
2322 | |
2323 /** | |
2324 * Check if a string is a userid (all numeric). | |
2325 * | |
2326 * @param user The user id, email, or name. | |
2327 * | |
2328 * @return TRUE if is userid, FALSE if not. | |
2329 */ | |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2330 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2331 msim_is_userid(const gchar *user) |
16395 | 2332 { |
2333 g_return_val_if_fail(user != NULL, FALSE); | |
2334 | |
2335 return strspn(user, "0123456789") == strlen(user); | |
2336 } | |
2337 | |
2338 /** | |
2339 * Check if a string is an email address (contains an @). | |
2340 * | |
2341 * @param user The user id, email, or name. | |
2342 * | |
2343 * @return TRUE if is an email, FALSE if not. | |
2344 * | |
2345 * This function is not intended to be used as a generic | |
2346 * means of validating email addresses, but to distinguish | |
2347 * between a user represented by an email address from | |
2348 * other forms of identification. | |
2349 */ | |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2350 gboolean |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2351 msim_is_email(const gchar *user) |
16395 | 2352 { |
2353 g_return_val_if_fail(user != NULL, FALSE); | |
2354 | |
2355 return strchr(user, '@') != NULL; | |
2356 } | |
2357 | |
2358 | |
2359 /** | |
2360 * Asynchronously lookup user information, calling callback when receive result. | |
2361 * | |
2362 * @param session | |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
2363 * @param user The user id, email address, or username. Not freed. |
16395 | 2364 * @param cb Callback, called with user information when available. |
2365 * @param data An arbitray data pointer passed to the callback. | |
2366 */ | |
17356
c6305f8845d8
Add TODOs about username/email->userid resolution, use g_return_if_fail() in a few places.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17355
diff
changeset
|
2367 /* TODO: change to not use callbacks */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2368 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2369 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:
17903
diff
changeset
|
2370 MSIM_USER_LOOKUP_CB cb, gpointer data) |
16395 | 2371 { |
2372 gchar *field_name; | |
2373 guint rid, cmd, dsn, lid; | |
2374 | |
2375 g_return_if_fail(MSIM_SESSION_VALID(session)); | |
2376 g_return_if_fail(user != NULL); | |
2377 g_return_if_fail(cb != NULL); | |
2378 | |
17323
793301c04e3a
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16749
diff
changeset
|
2379 purple_debug_info("msim", "msim_lookup_userid: " |
16405
47e07438f01c
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16403
diff
changeset
|
2380 "asynchronously looking up <%s>\n", user); |
16395 | 2381 |
17369
962edb051146
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17368
diff
changeset
|
2382 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:
17368
diff
changeset
|
2383 |
16395 | 2384 /* Setup callback. Response will be associated with request using 'rid'. */ |
17373
2aff11bb5e72
Several small changes to work towards a working msim_remove_buddy():
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17372
diff
changeset
|
2385 rid = msim_new_reply_callback(session, cb, data); |
16395 | 2386 |
2387 /* Send request */ | |
2388 | |
17343
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17342
diff
changeset
|
2389 cmd = MSIM_CMD_GET; |
16395 | 2390 |
2391 if (msim_is_userid(user)) | |
2392 { | |
2393 field_name = "UserID"; | |
17343
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17342
diff
changeset
|
2394 dsn = MG_MYSPACE_INFO_BY_ID_DSN; |
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17342
diff
changeset
|
2395 lid = MG_MYSPACE_INFO_BY_ID_LID; |
16395 | 2396 } else if (msim_is_email(user)) { |
2397 field_name = "Email"; | |
17343
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17342
diff
changeset
|
2398 dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17342
diff
changeset
|
2399 lid = MG_MYSPACE_INFO_BY_STRING_LID; |
16395 | 2400 } else { |
2401 field_name = "UserName"; | |
17343
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17342
diff
changeset
|
2402 dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
58b4d103a5b8
Use symbolic constants for persist messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17342
diff
changeset
|
2403 lid = MG_MYSPACE_INFO_BY_STRING_LID; |
16395 | 2404 } |
2405 | |
2406 | |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
2407 g_return_if_fail(msim_send(session, |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
2408 "persist", MSIM_TYPE_INTEGER, 1, |
17354
c2208b64bffb
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17353
diff
changeset
|
2409 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
2410 "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:
16746
diff
changeset
|
2411 "dsn", MSIM_TYPE_INTEGER, dsn, |
17374
e9dfd3a5d4b6
Remove msim_get_own_uid{,_cb}() - it is not needed, since the login
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17373
diff
changeset
|
2412 "uid", MSIM_TYPE_INTEGER, session->userid, |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
2413 "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:
16746
diff
changeset
|
2414 "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:
16746
diff
changeset
|
2415 /* TODO: dictionary field type */ |
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
2416 "body", MSIM_TYPE_STRING, g_strdup_printf("%s=%s", field_name, user), |
17348
d8903e1320a9
Previously, the return value of the processing function and msim_process() told
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17347
diff
changeset
|
2417 NULL)); |
16395 | 2418 } |
2419 | |
2420 | |
2421 /** | |
2422 * Obtain the status text for a buddy. | |
2423 * | |
2424 * @param buddy The buddy to obtain status text for. | |
2425 * | |
17383
f057837085b0
Change to use const gchar * where appropriate.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17382
diff
changeset
|
2426 * @return Status text, or NULL if error. Caller g_free()'s. |
16395 | 2427 * |
2428 */ | |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2429 char * |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2430 msim_status_text(PurpleBuddy *buddy) |
16395 | 2431 { |
2432 MsimSession *session; | |
17389
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2433 const gchar *display_name, *headline; |
16395 | 2434 |
2435 g_return_val_if_fail(buddy != NULL, NULL); | |
2436 | |
16749
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16747
diff
changeset
|
2437 session = (MsimSession *)buddy->account->gc->proto_data; |
16738
cd4a6bd9f69e
Use g_return_if_fail() instead of g_assert(), as to not crash the whole program.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16737
diff
changeset
|
2438 g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL); |
16395 | 2439 |
17389
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2440 display_name = headline = NULL; |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2441 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2442 /* 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:
17388
diff
changeset
|
2443 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:
17388
diff
changeset
|
2444 { |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2445 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:
17388
diff
changeset
|
2446 } |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2447 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2448 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:
17388
diff
changeset
|
2449 { |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2450 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:
17388
diff
changeset
|
2451 } |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2452 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2453 /* 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:
17388
diff
changeset
|
2454 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2455 if (display_name && headline) |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2456 return g_strconcat(display_name, " ", headline, NULL); |
16395 | 2457 |
17379
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
2458 if (display_name) |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
2459 return g_strdup(display_name); |
17389
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2460 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2461 if (headline) |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2462 return g_strdup(headline); |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2463 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2464 return NULL; |
16395 | 2465 } |
2466 | |
2467 /** | |
2468 * Obtain the tooltip text for a buddy. | |
2469 * | |
2470 * @param buddy Buddy to obtain tooltip text on. | |
2471 * @param user_info Variable modified to have the tooltip text. | |
2472 * @param full TRUE if should obtain full tooltip text. | |
2473 * | |
2474 */ | |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2475 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2476 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:
17903
diff
changeset
|
2477 gboolean full) |
16395 | 2478 { |
2479 g_return_if_fail(buddy != NULL); | |
2480 g_return_if_fail(user_info != NULL); | |
2481 | |
16397 | 2482 if (PURPLE_BUDDY_IS_ONLINE(buddy)) |
16395 | 2483 { |
2484 MsimSession *session; | |
2485 | |
16749
0fa4a3e9b318
Stylistic improvements - use type *name instead of type* name for pointers
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16747
diff
changeset
|
2486 session = (MsimSession *)buddy->account->gc->proto_data; |
16395 | 2487 |
16738
cd4a6bd9f69e
Use g_return_if_fail() instead of g_assert(), as to not crash the whole program.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16737
diff
changeset
|
2488 g_return_if_fail(MSIM_SESSION_VALID(session)); |
16395 | 2489 |
17379
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
2490 /* TODO: if (full), do something different */ |
17380
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2491 |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2492 /* Useful to identify the account the tooltip refers to. Other prpls show this. */ |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
2493 purple_notify_user_info_add_pair(user_info, _("User Name"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
2494 (purple_blist_node_get_string(&buddy->node, "UserName"))); |
17380
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2495 |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2496 /* a/s/l...the vitals */ |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
2497 purple_notify_user_info_add_pair(user_info, _("Age"), |
17380
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2498 g_strdup_printf("%d", purple_blist_node_get_int(&buddy->node, "Age"))); |
17379
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
2499 |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
2500 purple_notify_user_info_add_pair(user_info, _("Gender"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
2501 (purple_blist_node_get_string(&buddy->node, "Gender"))); |
17380
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2502 |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
2503 purple_notify_user_info_add_pair(user_info, _("Location"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
2504 (purple_blist_node_get_string(&buddy->node, "Location"))); |
17380
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2505 |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2506 /* Other information */ |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2507 if (purple_blist_node_get_string(&buddy->node, "Headline")) |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
2508 purple_notify_user_info_add_pair(user_info, _("Headline"), |
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
2509 (purple_blist_node_get_string(&buddy->node, "Headline"))); |
17380
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2510 |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
2511 purple_notify_user_info_add_pair(user_info, _("Song"), |
17380
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2512 g_strdup_printf("%s - %s", |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2513 purple_blist_node_get_string(&buddy->node, "BandName"), |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2514 purple_blist_node_get_string(&buddy->node, "SongName"))); |
fc2ccac8d826
Reorganize the tooltip text, to show more useful information.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17379
diff
changeset
|
2515 |
17899
61f0b36b9891
Retrieve information for profile ("Get Info") from server, instead of from
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17898
diff
changeset
|
2516 purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
17379
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
2517 g_strdup_printf("%d", purple_blist_node_get_int(&buddy->node, "TotalFriends"))); |
6fa345a01dd8
Show buddy information in tooltip text, and the display name for status text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17377
diff
changeset
|
2518 |
16395 | 2519 } |
2520 } | |
2521 | |
16397 | 2522 /** Callbacks called by Purple, to access this plugin. */ |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
2523 PurplePluginProtocolInfo prpl_info = |
16395 | 2524 { |
2525 OPT_PROTO_MAIL_CHECK,/* options - TODO: myspace will notify of mail */ | |
2526 NULL, /* user_splits */ | |
2527 NULL, /* protocol_options */ | |
2528 NO_BUDDY_ICONS, /* icon_spec - TODO: eventually should add this */ | |
2529 msim_list_icon, /* list_icon */ | |
2530 NULL, /* list_emblems */ | |
2531 msim_status_text, /* status_text */ | |
2532 msim_tooltip_text, /* tooltip_text */ | |
2533 msim_status_types, /* status_types */ | |
2534 NULL, /* blist_node_menu */ | |
2535 NULL, /* chat_info */ | |
2536 NULL, /* chat_info_defaults */ | |
2537 msim_login, /* login */ | |
2538 msim_close, /* close */ | |
2539 msim_send_im, /* send_im */ | |
2540 NULL, /* set_info */ | |
17347
aa8e70fa1edc
Add, but do not use, incomplete functions for using typing notifications.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17346
diff
changeset
|
2541 msim_send_typing, /* send_typing */ |
17382
1a26b36889dc
Implement msim_get_info() for users on the user's buddy list.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17381
diff
changeset
|
2542 msim_get_info, /* get_info */ |
16395 | 2543 NULL, /* set_away */ |
2544 NULL, /* set_idle */ | |
2545 NULL, /* change_passwd */ | |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2546 msim_add_buddy, /* add_buddy */ |
16395 | 2547 NULL, /* add_buddies */ |
17353
1905859d7a3b
Add (incomplete) msim_remove_buddy().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17350
diff
changeset
|
2548 msim_remove_buddy, /* remove_buddy */ |
16395 | 2549 NULL, /* remove_buddies */ |
2550 NULL, /* add_permit */ | |
2551 NULL, /* add_deny */ | |
2552 NULL, /* rem_permit */ | |
2553 NULL, /* rem_deny */ | |
2554 NULL, /* set_permit_deny */ | |
2555 NULL, /* join_chat */ | |
2556 NULL, /* reject chat invite */ | |
2557 NULL, /* get_chat_name */ | |
2558 NULL, /* chat_invite */ | |
2559 NULL, /* chat_leave */ | |
2560 NULL, /* chat_whisper */ | |
2561 NULL, /* chat_send */ | |
2562 NULL, /* keepalive */ | |
2563 NULL, /* register_user */ | |
2564 NULL, /* get_cb_info */ | |
2565 NULL, /* get_cb_away */ | |
2566 NULL, /* alias_buddy */ | |
2567 NULL, /* group_buddy */ | |
2568 NULL, /* rename_group */ | |
2569 NULL, /* buddy_free */ | |
2570 NULL, /* convo_closed */ | |
2571 NULL, /* normalize */ | |
2572 NULL, /* set_buddy_icon */ | |
2573 NULL, /* remove_group */ | |
2574 NULL, /* get_cb_real_name */ | |
2575 NULL, /* set_chat_topic */ | |
2576 NULL, /* find_blist_chat */ | |
2577 NULL, /* roomlist_get_list */ | |
2578 NULL, /* roomlist_cancel */ | |
2579 NULL, /* roomlist_expand_category */ | |
2580 NULL, /* can_receive_file */ | |
2581 NULL, /* send_file */ | |
2582 NULL, /* new_xfer */ | |
17381
df93e8773981
Add msim_offline_message() for offline message status. Always return TRUE,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17380
diff
changeset
|
2583 msim_offline_message, /* offline_message */ |
16395 | 2584 NULL, /* whiteboard_prpl_ops */ |
17903
cbda7f26d27d
Add a send_raw function, msim_send_really_raw, into the prpl_info struct,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17902
diff
changeset
|
2585 msim_send_really_raw, /* send_raw */ |
16734
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16410
diff
changeset
|
2586 NULL, /* roomlist_room_serialize */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16410
diff
changeset
|
2587 NULL, /* _purple_reserved1 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16410
diff
changeset
|
2588 NULL, /* _purple_reserved2 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16410
diff
changeset
|
2589 NULL, /* _purple_reserved3 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16410
diff
changeset
|
2590 NULL /* _purple_reserved4 */ |
16395 | 2591 }; |
2592 | |
2593 | |
2594 | |
2595 /** Based on MSN's plugin info comments. */ | |
16747
496855295bd7
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16746
diff
changeset
|
2596 PurplePluginInfo info = |
16395 | 2597 { |
16397 | 2598 PURPLE_PLUGIN_MAGIC, |
2599 PURPLE_MAJOR_VERSION, | |
2600 PURPLE_MINOR_VERSION, | |
17346
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
2601 PURPLE_PLUGIN_PROTOCOL, /**< type */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
2602 NULL, /**< ui_requirement */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
2603 0, /**< flags */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
2604 NULL, /**< dependencies */ |
73720427b132
Show online buddies on buddy list as online.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17344
diff
changeset
|
2605 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
16395 | 2606 |
2607 "prpl-myspace", /**< id */ | |
2608 "MySpaceIM", /**< name */ | |
17890
04a00333546a
Add script to produce tarballs and zip archives for releases, for v0.8.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17389
diff
changeset
|
2609 "0.8", /**< version */ |
16395 | 2610 /** summary */ |
2611 "MySpaceIM Protocol Plugin", | |
2612 /** description */ | |
2613 "MySpaceIM Protocol Plugin", | |
17898
60f614824207
Update author email address.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17897
diff
changeset
|
2614 "Jeff Connelly <jeff2@homing.pidgin.im>", /**< author */ |
16395 | 2615 "http://developer.pidgin.im/wiki/MySpaceIM/", /**< homepage */ |
2616 | |
16737
fc80e7b2540d
Check for RC4 in libpurple on plugin initialization.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16736
diff
changeset
|
2617 msim_load, /**< load */ |
16395 | 2618 NULL, /**< unload */ |
2619 NULL, /**< destroy */ | |
2620 NULL, /**< ui_info */ | |
2621 &prpl_info, /**< extra_info */ | |
2622 NULL, /**< prefs_info */ | |
2623 | |
2624 /* msim_actions */ | |
16734
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16410
diff
changeset
|
2625 NULL, |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16410
diff
changeset
|
2626 |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16410
diff
changeset
|
2627 NULL, /**< reserved1 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16410
diff
changeset
|
2628 NULL, /**< reserved2 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16410
diff
changeset
|
2629 NULL, /**< reserved3 */ |
3b5037a93807
Add initializers for reserved fields in plugin and prpl structures.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16410
diff
changeset
|
2630 NULL /**< reserved4 */ |
16395 | 2631 }; |
2632 | |
17891
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2633 |
17894
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
2634 #ifdef MSIM_SELF_TEST |
17891
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2635 /** Test functions. |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2636 * 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:
17890
diff
changeset
|
2637 * 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:
17890
diff
changeset
|
2638 * msimprpl is architected. |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2639 */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2640 void |
17905
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2641 msim_test_all(void) |
17891
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2642 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2643 guint failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2644 |
17905
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2645 |
17891
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2646 failures = 0; |
17905
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2647 failures += msim_test_xml(); |
17891
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2648 failures += msim_test_msg(); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2649 failures += msim_test_escaping(); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2650 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2651 if (failures) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2652 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2653 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:
17890
diff
changeset
|
2654 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2655 else |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2656 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2657 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:
17890
diff
changeset
|
2658 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2659 exit(0); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2660 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2661 |
17905
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2662 int |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2663 msim_test_xml(void) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2664 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2665 gchar *msg_text; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2666 xmlnode *root, *n; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2667 guint failures; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2668 char *s; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2669 int len; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2670 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2671 failures = 0; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2672 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2673 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:
17904
diff
changeset
|
2674 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2675 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:
17904
diff
changeset
|
2676 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2677 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:
17904
diff
changeset
|
2678 if (!root) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2679 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2680 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:
17904
diff
changeset
|
2681 exit(0); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2682 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2683 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2684 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:
17904
diff
changeset
|
2685 root->child->name); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2686 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2687 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:
17904
diff
changeset
|
2688 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:
17904
diff
changeset
|
2689 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:
17904
diff
changeset
|
2690 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:
17904
diff
changeset
|
2691 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:
17904
diff
changeset
|
2692 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:
17904
diff
changeset
|
2693 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:
17904
diff
changeset
|
2694 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:
17904
diff
changeset
|
2695 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:
17904
diff
changeset
|
2696 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:
17904
diff
changeset
|
2697 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:
17904
diff
changeset
|
2698 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:
17904
diff
changeset
|
2699 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:
17904
diff
changeset
|
2700 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2701 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:
17904
diff
changeset
|
2702 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2703 if (n->name) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2704 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2705 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:
17904
diff
changeset
|
2706 } else { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2707 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:
17904
diff
changeset
|
2708 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2709 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2710 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2711 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:
17904
diff
changeset
|
2712 xmlnode_get_data(root), |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2713 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:
17904
diff
changeset
|
2714 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:
17904
diff
changeset
|
2715 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2716 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2717 for (n = root->child; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2718 n != NULL; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2719 n = n->next) |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2720 { |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2721 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:
17904
diff
changeset
|
2722 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2723 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2724 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:
17904
diff
changeset
|
2725 s[len] = 0; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2726 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2727 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:
17904
diff
changeset
|
2728 g_free(s); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2729 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2730 xmlnode_free(root); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2731 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2732 exit(0); |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2733 |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2734 return failures; |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2735 } |
7b890c79aabf
Add msim_markup_to_html() to convert MySpaceIM-style markup to Purple-compatible
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17904
diff
changeset
|
2736 |
17891
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2737 /** Test MsimMessage for basic functionality. */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2738 int |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2739 msim_test_msg(void) |
17891
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2740 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2741 MsimMessage *msg, *msg_cloned; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2742 gchar *packed, *packed_expected, *packed_cloned; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2743 guint failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2744 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2745 failures = 0; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2746 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2747 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:
17890
diff
changeset
|
2748 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:
17890
diff
changeset
|
2749 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2750 /* Append some new elements. */ |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2751 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:
17890
diff
changeset
|
2752 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:
17890
diff
changeset
|
2753 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:
17890
diff
changeset
|
2754 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:
17890
diff
changeset
|
2755 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:
17890
diff
changeset
|
2756 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:
17890
diff
changeset
|
2757 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:
17890
diff
changeset
|
2758 packed = msim_msg_pack(msg); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2759 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2760 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:
17890
diff
changeset
|
2761 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2762 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:
17890
diff
changeset
|
2763 "\\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:
17890
diff
changeset
|
2764 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2765 if (0 != strcmp(packed, packed_expected)) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2766 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2767 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:
17890
diff
changeset
|
2768 ++failures, packed, packed_expected); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2769 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2770 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2771 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2772 msg_cloned = msim_msg_clone(msg); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2773 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:
17890
diff
changeset
|
2774 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2775 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:
17890
diff
changeset
|
2776 if (0 != strcmp(packed, packed_cloned)) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2777 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2778 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:
17890
diff
changeset
|
2779 ++failures, packed_cloned, packed); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2780 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2781 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2782 g_free(packed); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2783 g_free(packed_cloned); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2784 msim_msg_free(msg_cloned); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2785 msim_msg_free(msg); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2786 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2787 return failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2788 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2789 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2790 /** Test protocol-level escaping/unescaping. */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2791 int |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2792 msim_test_escaping(void) |
17891
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2793 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2794 guint failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2795 gchar *raw, *escaped, *unescaped, *expected; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2796 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2797 failures = 0; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2798 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2799 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:
17890
diff
changeset
|
2800 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2801 raw = "hello/world\\hello/world"; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2802 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2803 escaped = msim_escape(raw); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2804 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:
17890
diff
changeset
|
2805 expected = "hello/1world/2hello/1world"; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2806 if (0 != strcmp(escaped, expected)) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2807 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2808 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:
17890
diff
changeset
|
2809 ++failures, escaped, expected); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2810 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2811 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2812 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2813 unescaped = msim_unescape(escaped); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2814 g_free(escaped); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2815 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:
17890
diff
changeset
|
2816 if (0 != strcmp(raw, unescaped)) |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2817 { |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2818 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:
17890
diff
changeset
|
2819 ++failures, raw, unescaped); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2820 } |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2821 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2822 return failures; |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2823 } |
17894
333fe6ac1046
Add msim_unrecognized() to handle unhandled messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17893
diff
changeset
|
2824 #endif |
17891
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2825 |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2826 /** Initialize plugin. */ |
17904
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2827 void |
38030f1a2e56
Split return type and function name + arguments on to separate lines, to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17903
diff
changeset
|
2828 init_plugin(PurplePlugin *plugin) |
16744
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16742
diff
changeset
|
2829 { |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16742
diff
changeset
|
2830 PurpleAccountOption *option; |
17891
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2831 #ifdef MSIM_SELF_TEST |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2832 msim_test_all(); |
23f57d36cb65
Add msim_test_all() and related procedures, to perform basic functionality
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17890
diff
changeset
|
2833 #endif /* MSIM_SELF_TEST */ |
16744
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16742
diff
changeset
|
2834 |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16742
diff
changeset
|
2835 /* TODO: default to automatically try different ports. Make the user be |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16742
diff
changeset
|
2836 * 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:
16742
diff
changeset
|
2837 option = purple_account_option_string_new(_("Connect server"), "server", MSIM_SERVER); |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16742
diff
changeset
|
2838 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:
16742
diff
changeset
|
2839 |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16742
diff
changeset
|
2840 option = purple_account_option_int_new(_("Connect port"), "port", MSIM_PORT); |
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16742
diff
changeset
|
2841 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
17389
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2842 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2843 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:
17388
diff
changeset
|
2844 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:
17388
diff
changeset
|
2845 |
d198d62c5ff5
Add two boolean options to account dialog, to allow displaying of
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17388
diff
changeset
|
2846 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:
17388
diff
changeset
|
2847 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
16744
a8e8482a2dc6
Clean up a few TODO's.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
16742
diff
changeset
|
2848 } |
16395 | 2849 |
16397 | 2850 PURPLE_INIT_PLUGIN(myspace, init_plugin, info); |