Wed, 20 Jun 2007 04:44:12 +0000
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
a bug when adding a buddy that already exists.
| 16322 | 1 | /* MySpaceIM Protocol Plugin |
| 2 | * | |
| 3 | * \author Jeff Connelly | |
| 4 | * | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
5 | * Copyright (C) 2007, Jeff Connelly <jeff2@homing.pidgin.im> |
| 16322 | 6 | * |
| 16324 | 7 | * Based on Purple's "C Plugin HOWTO" hello world example. |
| 16322 | 8 | * |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
9 | * Code also drawn from mockprpl: |
| 16324 | 10 | * http://snarfed.org/space/purple+mock+protocol+plugin |
| 16322 | 11 | * Copyright (C) 2004-2007, Ryan Barrett <mockprpl@ryanb.org> |
| 12 | * | |
| 16324 | 13 | * and some constructs also based on existing Purple plugins, which are: |
| 14 | * Copyright (C) 2003, Robbert Haarman <purple@inglorion.net> | |
| 16322 | 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 | ||
| 16324 | 34 | #define PURPLE_PLUGIN |
| 16322 | 35 | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
36 | #include "message.h" |
|
17930
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
37 | #include "persist.h" |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
38 | #include "myspace.h" |
| 16322 | 39 | |
|
17893
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
40 | /** |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
41 | * Load the plugin. |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
42 | */ |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
43 | gboolean msim_load(PurplePlugin *plugin) |
|
17893
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
44 | { |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
45 | #ifdef MSIM_USE_PURPLE_RC4 |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
46 | /* If compiled to use RC4 from libpurple, check if it is really there. */ |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
47 | if (!purple_ciphers_find_cipher("rc4")) |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
48 | { |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
49 | purple_debug_error("msim", "compiled with MSIM_USE_PURPLE_RC4 but rc4 not in libpurple - not loading MySpaceIM plugin!\n"); |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
50 | purple_notify_error(plugin, _("Missing Cipher"), |
|
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
51 | _("The RC4 cipher could not be found"), |
|
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
52 | _("Recompile without MSIM_USE_PURPLE_RC4, or upgrade " |
|
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
53 | "to a libpurple with RC4 support (>= 2.0.1). MySpaceIM " |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
54 | "plugin will not be loaded.")); |
|
17893
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
55 | return FALSE; |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
56 | } |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
57 | #endif |
|
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
58 | return TRUE; |
| 16322 | 59 | } |
| 60 | ||
| 61 | /** | |
| 62 | * Get possible user status types. Based on mockprpl. | |
| 63 | * | |
| 64 | * @return GList of status types. | |
| 65 | */ | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
66 | GList *msim_status_types(PurpleAccount *acct) |
| 16322 | 67 | { |
| 68 | GList *types; | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
69 | PurpleStatusType *status; |
| 16322 | 70 | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
71 | purple_debug_info("myspace", "returning status types\n"); |
| 16322 | 72 | |
| 73 | types = NULL; | |
| 74 | ||
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
75 | /* TODO: Fix these: |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
76 | * |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
77 | * g_log: purple_presence_get_active_status: assertion `presence != NULL' failed |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
78 | * g_log: purple_status_get_name: assertion `status != NULL' failed |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
79 | * [...] |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
80 | * |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
81 | * and |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
82 | * g_log: purple_presence_set_status_active: assertion `status != NULL' failed |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
83 | * [...] |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
84 | */ |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
85 | status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE, NULL, NULL, FALSE, TRUE, FALSE); |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
86 | types = g_list_append(types, status); |
| 16322 | 87 | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
88 | status = purple_status_type_new_full(PURPLE_STATUS_AWAY, NULL, NULL, FALSE, TRUE, FALSE); |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
89 | types = g_list_append(types, status); |
| 16322 | 90 | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
91 | status = purple_status_type_new_full(PURPLE_STATUS_OFFLINE, NULL, NULL, FALSE, TRUE, FALSE); |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
92 | types = g_list_append(types, status); |
| 16322 | 93 | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
94 | status = purple_status_type_new_full(PURPLE_STATUS_INVISIBLE, NULL, NULL, FALSE, TRUE, FALSE); |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
95 | types = g_list_append(types, status); |
| 16322 | 96 | |
| 97 | return types; | |
| 98 | } | |
| 99 | ||
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
100 | /** |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
101 | * Return the icon name for a buddy and account. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
102 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
103 | * @param acct The account to find the icon for, or NULL for protocol icon. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
104 | * @param buddy The buddy to find the icon for, or NULL for the account icon. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
105 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
106 | * @return The base icon name string. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
107 | */ |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
108 | const gchar *msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy) |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
109 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
110 | /* Use a MySpace icon submitted by hbons at |
|
17900
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
111 | * http://developer.pidgin.im/wiki/MySpaceIM. */ |
|
16334
ff6947265141
Add and use MySpaceIM icon uploaded by hbons (48x48 original and resized 22x22 and 16x16 versions).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16333
diff
changeset
|
112 | return "myspace"; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
113 | } |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
114 | |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
115 | /* Replacement codes to be replaced with associated replacement text, |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
116 | * used for protocol message escaping / unescaping. */ |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
117 | static gchar* msim_replacement_code[] = { "/1", "/2", NULL }; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
118 | static gchar* msim_replacement_text[] = { "/", "\\", NULL }; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
119 | |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
120 | /** |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
121 | * Unescape or escape a protocol message. |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
122 | * |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
123 | * @param msg The message to be unescaped or escaped. WILL BE FREED. |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
124 | * @param escape TRUE to escape, FALSE to unescape. |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
125 | * |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
126 | * @return The unescaped or escaped message. Caller must g_free(). |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
127 | */ |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
128 | gchar *msim_unescape_or_escape(gchar *msg, gboolean escape) |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
129 | { |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
130 | gchar *tmp, *code, *text; |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
131 | guint i; |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
132 | |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
133 | /* Replace each code in msim_replacement_code with |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
134 | * corresponding entry in msim_replacement_text. */ |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
135 | for (i = 0; (code = msim_replacement_code[i]) |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
136 | && (text = msim_replacement_text[i]); ++i) |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
137 | { |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
138 | if (escape) |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
139 | { |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
140 | tmp = str_replace(msg, text, code); |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
141 | } |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
142 | else |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
143 | { |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
144 | tmp = str_replace(msg, code, text); |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
145 | } |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
146 | g_free(msg); |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
147 | msg = tmp; |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
148 | } |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
149 | |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
150 | return msg; |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
151 | } |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
152 | |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
153 | /** |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
154 | * Escape a protocol message. |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
155 | * |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
156 | * @return The escaped message. Caller must g_free(). |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
157 | */ |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
158 | gchar *msim_escape(const gchar *msg) |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
159 | { |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
160 | return msim_unescape_or_escape(g_strdup(msg), TRUE); |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
161 | } |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
162 | |
|
17982
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
163 | gchar *msim_unescape(const gchar *msg) |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
164 | { |
|
7c2fe89250cd
Refactor msim_escape() & msim_unescape().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17981
diff
changeset
|
165 | return msim_unescape_or_escape(g_strdup(msg), FALSE); |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
166 | } |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
167 | |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
168 | /** |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
169 | * Replace 'old' with 'new' in 'str'. |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
170 | * |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
171 | * @param str The original string. |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
172 | * @param old The substring of 'str' to replace. |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
173 | * @param new The replacement for 'old' within 'str'. |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
174 | * |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
175 | * @return A _new_ string, based on 'str', with 'old' replaced |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
176 | * by 'new'. Must be g_free()'d by caller. |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
177 | * |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
178 | * This string replace method is based on |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
179 | * http://mail.gnome.org/archives/gtk-app-devel-list/2000-July/msg00201.html |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
180 | * |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
181 | */ |
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
182 | gchar *str_replace(const gchar *str, const gchar *old, const gchar *new) |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
183 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
184 | gchar **items; |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
185 | gchar *ret; |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
186 | |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
187 | items = g_strsplit(str, old, -1); |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
188 | ret = g_strjoinv(new, items); |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
189 | g_free(items); |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
190 | return ret; |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
191 | } |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
192 | |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
193 | |
|
17902
8e0b1d066efb
Add partial implementation of MsimMessage (not used anywhere yet).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17901
diff
changeset
|
194 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
195 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
196 | #ifdef MSIM_DEBUG_MSG |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
197 | void print_hash_item(gpointer key, gpointer value, gpointer user_data) |
| 16322 | 198 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
199 | purple_debug_info("msim", "%s=%s\n", (gchar *)key, (gchar *)value); |
| 16322 | 200 | } |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
201 | #endif |
| 16322 | 202 | |
| 203 | /** | |
|
17890
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
204 | * Send raw data to the server. |
| 16322 | 205 | * |
| 206 | * @param session | |
|
17890
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
207 | * @param msg The raw data to send. |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
208 | * |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
209 | * @return TRUE if succeeded, FALSE if not. |
| 16322 | 210 | * |
| 211 | */ | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
212 | gboolean msim_send_raw(MsimSession *session, const gchar *msg) |
| 16322 | 213 | { |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
214 | int total_bytes_sent, total_bytes; |
|
17897
8f844632f315
Implement msim_pack(), msim_sendh(), msim_send().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17896
diff
changeset
|
215 | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
216 | purple_debug_info("msim", "msim_send_raw: writing <%s>\n", msg); |
| 16322 | 217 | |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
218 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
219 | g_return_val_if_fail(msg != NULL, FALSE); |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
220 | |
| 16322 | 221 | |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
222 | /* Loop until all data is sent, or a failure occurs. */ |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
223 | total_bytes_sent = 0; |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
224 | total_bytes = strlen(msg); |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
225 | do |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
226 | { |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
227 | int bytes_sent; |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
228 | |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
229 | bytes_sent = send(session->fd, msg + total_bytes_sent, |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
230 | total_bytes - total_bytes_sent, 0); |
| 16322 | 231 | |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
232 | if (bytes_sent < 0) |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
233 | { |
|
17890
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
234 | purple_debug_info("msim", "msim_send_raw(%s): send() failed: %s\n", |
|
16337
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
235 | msg, g_strerror(errno)); |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
236 | return FALSE; |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
237 | } |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
238 | total_bytes_sent += bytes_sent; |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
239 | |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
240 | } while(total_bytes_sent < total_bytes); |
|
ba0ded418e6a
Add escaping and unescaping functions (for /1 and /2).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16335
diff
changeset
|
241 | return TRUE; |
| 16322 | 242 | } |
| 243 | ||
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
244 | /** |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
245 | * Start logging in to the MSIM servers. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
246 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
247 | * @param acct Account information to use to login. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
248 | */ |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
249 | void msim_login(PurpleAccount *acct) |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
250 | { |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
251 | PurpleConnection *gc; |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
252 | const gchar *host; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
253 | int port; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
254 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
255 | g_return_if_fail(acct != NULL); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
256 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
257 | purple_debug_info("myspace", "logging in %s\n", acct->username); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
258 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
259 | gc = purple_account_get_connection(acct); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
260 | gc->proto_data = msim_session_new(acct); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
261 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
262 | /* 1. connect to server */ |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
263 | purple_connection_update_progress(gc, _("Connecting"), |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
264 | 0, /* which connection step this is */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
265 | 4); /* total number of steps */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
266 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
267 | host = purple_account_get_string(acct, "server", MSIM_SERVER); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
268 | port = purple_account_get_int(acct, "port", MSIM_PORT); |
|
17900
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
269 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
270 | /* From purple.sf.net/api: |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
271 | * """Note that this function name can be misleading--although it is called |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
272 | * "proxy connect," it is used for establishing any outgoing TCP connection, |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
273 | * whether through a proxy or not.""" */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
274 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
275 | /* Calls msim_connect_cb when connected. */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
276 | if (purple_proxy_connect(gc, acct, host, port, msim_connect_cb, gc) == NULL) |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
277 | { |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
278 | /* TODO: try other ports if in auto mode, then save |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
279 | * working port and try that first next time. */ |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
280 | purple_connection_error(gc, _("Couldn't create socket")); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
281 | return; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
282 | } |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
283 | } |
| 16322 | 284 | /** |
| 285 | * Process a login challenge, sending a response. | |
| 286 | * | |
| 287 | * @param session | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
288 | * @param msg Login challenge message. |
| 16322 | 289 | * |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
290 | * @return TRUE if successful, FALSE if not |
| 16322 | 291 | */ |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
292 | gboolean msim_login_challenge(MsimSession *session, MsimMessage *msg) |
| 16322 | 293 | { |
| 16324 | 294 | PurpleAccount *account; |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
295 | const gchar *response; |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
296 | guint response_len; |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
297 | gchar *nc; |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
298 | gsize nc_len; |
| 16322 | 299 | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
300 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
301 | g_return_val_if_fail(msg != NULL, FALSE); |
| 16322 | 302 | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
303 | g_return_val_if_fail(msim_msg_get_binary(msg, "nc", &nc, &nc_len), FALSE); |
| 16322 | 304 | |
| 305 | account = session->account; | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
306 | |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
307 | g_return_val_if_fail(account != NULL, FALSE); |
| 16322 | 308 | |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
309 | purple_connection_update_progress(session->gc, _("Reading challenge"), 1, 4); |
| 16322 | 310 | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
311 | purple_debug_info("msim", "nc is %d bytes, decoded\n", nc_len); |
| 16322 | 312 | |
| 313 | if (nc_len != 0x40) | |
| 314 | { | |
| 16324 | 315 | purple_debug_info("msim", "bad nc length: %x != 0x40\n", nc_len); |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
316 | purple_connection_error(session->gc, _("Unexpected challenge length from server")); |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
317 | return FALSE; |
| 16322 | 318 | } |
| 319 | ||
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
320 | purple_connection_update_progress(session->gc, _("Logging in"), 2, 4); |
| 16322 | 321 | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
322 | response = msim_compute_login_response(nc, account->username, account->password, &response_len); |
| 16322 | 323 | |
| 324 | g_free(nc); | |
| 325 | ||
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
326 | return msim_send(session, |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
327 | "login2", MSIM_TYPE_INTEGER, MSIM_AUTH_ALGORITHM, |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
328 | /* This is actually user's email address. */ |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
329 | "username", MSIM_TYPE_STRING, g_strdup(account->username), |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
330 | /* GString and gchar * response will be freed in msim_msg_free() in msim_send(). */ |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
331 | "response", MSIM_TYPE_BINARY, g_string_new_len(response, response_len), |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
332 | "clientver", MSIM_TYPE_INTEGER, MSIM_CLIENT_VERSION, |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
333 | "reconn", MSIM_TYPE_INTEGER, 0, |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
334 | "status", MSIM_TYPE_INTEGER, 100, |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
335 | "id", MSIM_TYPE_INTEGER, 1, |
|
17898
d08d6d221276
Incomplete attempt at using msim_send() instead of msim_send_raw().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17897
diff
changeset
|
336 | NULL); |
| 16322 | 337 | } |
| 338 | ||
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
339 | #ifndef MSIM_USE_PURPLE_RC4 |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
340 | /* No RC4 in this version of libpurple, so bring our own. */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
341 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
342 | /* |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
343 | Unix SMB/CIFS implementation. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
344 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
345 | a partial implementation of RC4 designed for use in the |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
346 | SMB authentication protocol |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
347 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
348 | Copyright (C) Andrew Tridgell 1998 |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
349 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
350 | $Id: crypt-rc4.c 12116 2004-09-27 23:29:22Z guy $ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
351 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
352 | This program is free software; you can redistribute it and/or modify |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
353 | it under the terms of the GNU General Public License as published by |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
354 | the Free Software Foundation; either version 2 of the License, or |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
355 | (at your option) any later version. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
356 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
357 | This program is distributed in the hope that it will be useful, |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
358 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
359 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
360 | GNU General Public License for more details. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
361 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
362 | You should have received a copy of the GNU General Public License |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
363 | along with this program; if not, write to the Free Software |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
364 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
365 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
366 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
367 | Modified by Jeff Connelly for MySpaceIM Gaim plugin. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
368 | */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
369 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
370 | #include <glib.h> |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
371 | #include <string.h> |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
372 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
373 | /* Perform RC4 on a block of data using specified key. "data" is a pointer |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
374 | to the block to be processed. Output is written to same memory as input, |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
375 | so caller may need to make a copy before calling this function, since |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
376 | the input will be overwritten. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
377 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
378 | Taken from Samba source code. Modified to allow us to maintain state |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
379 | between calls to crypt_rc4. |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
380 | */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
381 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
382 | void crypt_rc4_init(rc4_state_struct *rc4_state, |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
383 | const guchar *key, int key_len) |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
384 | { |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
385 | int ind; |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
386 | unsigned gchar j = 0; |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
387 | unsigned gchar *s_box; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
388 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
389 | memset(rc4_state, 0, sizeof(rc4_state_struct)); |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
390 | s_box = rc4_state->s_box; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
391 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
392 | for (ind = 0; ind < 256; ind++) |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
393 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
394 | s_box[ind] = (guchar)ind; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
395 | } |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
396 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
397 | for( ind = 0; ind < 256; ind++) |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
398 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
399 | guchar tc; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
400 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
401 | j += (s_box[ind] + key[ind%key_len]); |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
402 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
403 | tc = s_box[ind]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
404 | s_box[ind] = s_box[j]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
405 | s_box[j] = tc; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
406 | } |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
407 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
408 | } |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
409 | |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
410 | void crypt_rc4(rc4_state_struct *rc4_state, guchar *data, int data_len) |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
411 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
412 | guchar *s_box; |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
413 | guchar index_i; |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
414 | guchar index_j; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
415 | int ind; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
416 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
417 | /* retrieve current state from the state struct (so we can resume where |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
418 | we left off) */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
419 | index_i = rc4_state->index_i; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
420 | index_j = rc4_state->index_j; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
421 | s_box = rc4_state->s_box; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
422 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
423 | for( ind = 0; ind < data_len; ind++) |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
424 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
425 | guchar tc; |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
426 | guchar t; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
427 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
428 | index_i++; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
429 | index_j += s_box[index_i]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
430 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
431 | tc = s_box[index_i]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
432 | s_box[index_i] = s_box[index_j]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
433 | s_box[index_j] = tc; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
434 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
435 | t = s_box[index_i] + s_box[index_j]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
436 | data[ind] = data[ind] ^ s_box[t]; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
437 | } |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
438 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
439 | /* Store the updated state */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
440 | rc4_state->index_i = index_i; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
441 | rc4_state->index_j = index_j; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
442 | } |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
443 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
444 | #endif /* !MSIM_USE_PURPLE_RC4 */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
445 | |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
446 | |
| 16322 | 447 | /** |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
448 | * Compute the base64'd login challenge response based on username, password, nonce, and IPs. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
449 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
450 | * @param nonce The base64 encoded nonce ('nc') field from the server. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
451 | * @param email User's email address (used as login name). |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
452 | * @param password User's cleartext password. |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
453 | * @param response_len Will be written with response length. |
| 16322 | 454 | * |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
455 | * @return Binary login challenge response, ready to send to the server. Must be g_free()'d |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
456 | * when finished. |
| 16322 | 457 | */ |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
458 | const gchar *msim_compute_login_response(const gchar nonce[2 * NONCE_SIZE], |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
459 | const gchar *email, const gchar *password, guint *response_len) |
| 16322 | 460 | { |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
461 | PurpleCipherContext *key_context; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
462 | PurpleCipher *sha1; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
463 | #ifdef MSIM_USE_PURPLE_RC4 |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
464 | PurpleCipherContext *rc4; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
465 | #else |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
466 | rc4_state_struct rc4; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
467 | #endif |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
468 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
469 | guchar hash_pw[HASH_SIZE]; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
470 | guchar key[HASH_SIZE]; |
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
471 | gchar *password_utf16le; |
|
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
472 | guchar *data; |
|
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
473 | guchar *data_out; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
474 | size_t data_len, data_out_len; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
475 | gsize conv_bytes_read, conv_bytes_written; |
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
476 | GError *conv_error; |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
477 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
478 | int i; |
|
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
479 | #endif |
| 16322 | 480 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
481 | /* Convert ASCII password to UTF16 little endian */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
482 | purple_debug_info("msim", "converting password to UTF-16LE\n"); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
483 | conv_error = NULL; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
484 | password_utf16le = g_convert(password, -1, "UTF-16LE", "UTF-8", |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
485 | &conv_bytes_read, &conv_bytes_written, &conv_error); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
486 | g_assert(conv_bytes_read == strlen(password)); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
487 | if (conv_error != NULL) |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
488 | { |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
489 | purple_debug_error("msim", |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
490 | "g_convert password UTF8->UTF16LE failed: %s", |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
491 | conv_error->message); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
492 | g_error_free(conv_error); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
493 | } |
| 16322 | 494 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
495 | /* Compute password hash */ |
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
496 | purple_cipher_digest_region("sha1", (guchar *)password_utf16le, |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
497 | conv_bytes_written, sizeof(hash_pw), hash_pw, NULL); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
498 | g_free(password_utf16le); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
499 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
500 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
501 | purple_debug_info("msim", "pwhash = "); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
502 | for (i = 0; i < sizeof(hash_pw); i++) |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
503 | purple_debug_info("msim", "%.2x ", hash_pw[i]); |
|
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
504 | purple_debug_info("msim", "\n"); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
505 | #endif |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
506 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
507 | /* key = sha1(sha1(pw) + nonce2) */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
508 | sha1 = purple_ciphers_find_cipher("sha1"); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
509 | key_context = purple_cipher_context_new(sha1, NULL); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
510 | purple_cipher_context_append(key_context, hash_pw, HASH_SIZE); |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
511 | purple_cipher_context_append(key_context, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
512 | purple_cipher_context_digest(key_context, sizeof(key), key, NULL); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
513 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
514 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
515 | purple_debug_info("msim", "key = "); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
516 | for (i = 0; i < sizeof(key); i++) |
| 16322 | 517 | { |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
518 | purple_debug_info("msim", "%.2x ", key[i]); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
519 | } |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
520 | purple_debug_info("msim", "\n"); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
521 | #endif |
| 16322 | 522 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
523 | #ifdef MSIM_USE_PURPLE_RC4 |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
524 | rc4 = purple_cipher_context_new_by_name("rc4", NULL); |
| 16322 | 525 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
526 | /* Note: 'key' variable is 0x14 bytes (from SHA-1 hash), |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
527 | * but only first 0x10 used for the RC4 key. */ |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
528 | purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
529 | purple_cipher_context_set_key(rc4, key); |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
530 | #endif |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
531 | |
|
17985
930a05d4e86f
Use constants for IP address list, defined in myspace.h.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17984
diff
changeset
|
532 | /* TODO: obtain IPs of network interfaces */ |
|
930a05d4e86f
Use constants for IP address list, defined in myspace.h.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17984
diff
changeset
|
533 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
534 | /* rc4 encrypt: |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
535 | * nonce1+email+IP list */ |
|
17985
930a05d4e86f
Use constants for IP address list, defined in myspace.h.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17984
diff
changeset
|
536 | |
|
930a05d4e86f
Use constants for IP address list, defined in myspace.h.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17984
diff
changeset
|
537 | data_len = NONCE_SIZE + strlen(email) + MSIM_LOGIN_IP_LIST_LEN; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
538 | data = g_new0(guchar, data_len); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
539 | memcpy(data, nonce, NONCE_SIZE); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
540 | memcpy(data + NONCE_SIZE, email, strlen(email)); |
|
17985
930a05d4e86f
Use constants for IP address list, defined in myspace.h.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17984
diff
changeset
|
541 | memcpy(data + NONCE_SIZE + strlen(email), MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
542 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
543 | #ifdef MSIM_USE_PURPLE_RC4 |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
544 | data_out = g_new0(guchar, data_len); |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
545 | |
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
546 | purple_cipher_context_encrypt(rc4, (const guchar *)data, |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
547 | data_len, data_out, &data_out_len); |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
548 | purple_cipher_context_destroy(rc4); |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
549 | #else |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
550 | /* Use our own RC4 code */ |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
551 | purple_debug_info("msim", "Using non-purple RC4 cipher code in this version\n"); |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
552 | crypt_rc4_init(&rc4, key, 0x10); |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
553 | crypt_rc4(&rc4, data, data_len); |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
554 | data_out_len = data_len; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
555 | data_out = data; |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
556 | #endif |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
557 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
558 | g_assert(data_out_len == data_len); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
559 | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
560 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
561 | purple_debug_info("msim", "response=<%s>\n", data_out); |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
562 | #endif |
|
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
563 | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
564 | *response_len = data_out_len; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
565 | |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
566 | return (const gchar *)data_out; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
567 | } |
| 16322 | 568 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
569 | /** |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
570 | * Schedule an IM to be sent once the user ID is looked up. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
571 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
572 | * @param gc Connection. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
573 | * @param who A user id, email, or username to send the message to. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
574 | * @param message Instant message text to send. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
575 | * @param flags Flags. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
576 | * |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
577 | * @return 1 if successful or postponed, -1 if failed |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
578 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
579 | * Allows sending to a user by username, email address, or userid. If |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
580 | * a username or email address is given, the userid must be looked up. |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
581 | * This function does that by calling msim_postprocess_outgoing(). |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
582 | */ |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
583 | int msim_send_im(PurpleConnection *gc, const gchar *who, |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
584 | const gchar *message, PurpleMessageFlags flags) |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
585 | { |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
586 | MsimSession *session; |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
587 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
588 | g_return_val_if_fail(gc != NULL, 0); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
589 | g_return_val_if_fail(who != NULL, 0); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
590 | g_return_val_if_fail(message != NULL, 0); |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
591 | |
|
17944
62750b952935
Remove 'flags' from send_im_cb_struct - it was never needed.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17943
diff
changeset
|
592 | /* 'flags' has many options, not used here. */ |
|
62750b952935
Remove 'flags' from send_im_cb_struct - it was never needed.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17943
diff
changeset
|
593 | |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
594 | session = gc->proto_data; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
595 | |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
596 | if (msim_send_bm(session, who, message, MSIM_BM_INSTANT)) |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
597 | { |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
598 | /* Return 1 to have Purple show this IM as being sent, 0 to not. I always |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
599 | * return 1 even if the message could not be sent, since I don't know if |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
600 | * it has failed yet--because the IM is only sent after the userid is |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
601 | * retrieved from the server (which happens after this function returns). |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
602 | */ |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
603 | return 1; |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
604 | } else { |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
605 | return -1; |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
606 | } |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
607 | /* |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
608 | * In MySpace, you login with your email address, but don't talk to other |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
609 | * users using their email address. So there is currently an asymmetry in the |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
610 | * IM windows when using this plugin: |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
611 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
612 | * you@example.com: hello |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
613 | * some_other_user: what's going on? |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
614 | * you@example.com: just coding a prpl |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
615 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
616 | * TODO: Make the sent IM's appear as from the user's username, instead of |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
617 | * their email address. Purple uses the login (in MSIM, the email)--change this. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
618 | */ |
| 16322 | 619 | } |
| 620 | ||
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
621 | /** Send a buddy message of a given type. |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
622 | * |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
623 | * @param session |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
624 | * @param who Username to send message to. |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
625 | * @param text Message text to send. Not freed; will be copied. |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
626 | * @param type A MSIM_BM_* constant. |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
627 | * |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
628 | * Buddy messages ('bm') include instant messages, action messages, status messages, etc. |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
629 | */ |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
630 | gboolean msim_send_bm(MsimSession *session, const gchar *who, const gchar *text, int type) |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
631 | { |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
632 | gboolean rc; |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
633 | MsimMessage *msg; |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
634 | const gchar *from_username; |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
635 | |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
636 | from_username = session->account->username; |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
637 | |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
638 | purple_debug_info("msim", "sending %d message from %s to %s: %s\n", |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
639 | type, from_username, who, text); |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
640 | |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
641 | msg = msim_msg_new(TRUE, |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
642 | "bm", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(type), |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
643 | "sesskey", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(session->sesskey), |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
644 | /* 't' will be inserted here */ |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
645 | "cv", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(MSIM_CLIENT_VERSION), |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
646 | "msg", MSIM_TYPE_STRING, g_strdup(text), |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
647 | NULL); |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
648 | |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
649 | rc = msim_postprocess_outgoing(session, msg, who, "t", "cv"); |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
650 | |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
651 | msim_msg_free(msg); |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
652 | |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
653 | return rc; |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
654 | } |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
655 | |
| 16322 | 656 | /** |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
657 | * Handle an incoming instant message. |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
658 | * |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
659 | * @param session The session |
|
17951
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
660 | * @param msg Message from the server, containing 'f' (userid from) and 'msg'. |
|
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
661 | * Should also contain username in _username from preprocessing. |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
662 | * |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
663 | * @return TRUE if successful. |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
664 | */ |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
665 | gboolean msim_incoming_im(MsimSession *session, MsimMessage *msg) |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
666 | { |
|
17951
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
667 | gchar *username; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
668 | |
|
17951
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
669 | username = msim_msg_get_string(msg, "_username"); |
|
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
670 | |
|
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
671 | serv_got_im(session->gc, username, msim_msg_get_string(msg, "msg"), PURPLE_MESSAGE_RECV, time(NULL)); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
672 | |
|
17951
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
673 | g_free(username); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
674 | |
|
17951
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
675 | return TRUE; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
676 | } |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
677 | |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
678 | /** |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
679 | * Handle an unrecognized message. |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
680 | */ |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
681 | void msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note) |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
682 | { |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
683 | /* TODO: Some more context, outwardly equivalent to a backtrace, for helping figure |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
684 | * out what this msg is for. But not too much information so that a user |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
685 | * posting this dump reveals confidential information. |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
686 | */ |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
687 | /* TODO: dump unknown msgs to file, so user can send them to me |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
688 | * if they wish, to help add support for new messages (inspired |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
689 | * by Alexandr Shutko, who maintains OSCAR protocol documentation). */ |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
690 | |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
691 | purple_debug_info("msim", "Unrecognized message on account for %s\n", session->account->username); |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
692 | if (note) |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
693 | { |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
694 | purple_debug_info("msim", "(Note: %s)\n", note); |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
695 | } |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
696 | |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
697 | msim_msg_dump("Unrecognized message dump: %s\n", msg); |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
698 | } |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
699 | |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
700 | /** |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
701 | * Handle an incoming action message. |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
702 | * |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
703 | * @param session |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
704 | * @param msg |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
705 | * |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
706 | * @return TRUE if successful. |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
707 | * |
|
17952
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
708 | * UNTESTED |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
709 | */ |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
710 | gboolean msim_incoming_action(MsimSession *session, MsimMessage *msg) |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
711 | { |
|
17952
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
712 | gchar *msg_text, *username; |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
713 | gboolean rc; |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
714 | |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
715 | msg_text = msim_msg_get_string(msg, "msg"); |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
716 | username = msim_msg_get_string(msg, "_username"); |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
717 | |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
718 | purple_debug_info("msim", "msim_incoming_action: action <%s> from <%d>\n", msg_text, username); |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
719 | |
|
17952
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
720 | if (strcmp(msg_text, "%typing%") == 0) |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
721 | { |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
722 | /* TODO: find out if msim repeatedly sends typing messages, so we can give it a timeout. |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
723 | * Right now, there does seem to be an inordinately amount of time between typing/ |
|
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
724 | * stopped-typing notifications. */ |
|
17952
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
725 | serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
726 | rc = TRUE; |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
727 | } else if (strcmp(msg_text, "%stoptyping%") == 0) { |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
728 | serv_got_typing_stopped(session->gc, username); |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
729 | rc = TRUE; |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
730 | } else { |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
731 | msim_unrecognized(session, msg, "got to msim_incoming_action but unrecognized value for 'msg'"); |
|
17952
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
732 | rc = FALSE; |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
733 | } |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
734 | |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
735 | |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
736 | g_free(msg_text); |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
737 | g_free(username); |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
738 | |
|
4f2723ecd15a
Add untested implementation of msim_incoming_action().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17951
diff
changeset
|
739 | return rc; |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
740 | } |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
741 | |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
742 | /** |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
743 | * Handle when our user starts or stops typing to another user. |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
744 | * |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
745 | * @param gc |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
746 | * @param name The buddy name to which our user is typing to |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
747 | * @param state PURPLE_TYPING, PURPLE_TYPED, PURPLE_NOT_TYPING |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
748 | * |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
749 | */ |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
750 | unsigned int msim_send_typing(PurpleConnection *gc, const gchar *name, PurpleTypingState state) |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
751 | { |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
752 | const gchar *typing_str; |
|
17959
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
753 | MsimSession *session; |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
754 | |
|
cfbe7f9e5200
Send typing notifications (tested).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17958
diff
changeset
|
755 | session = (MsimSession *)gc->proto_data; |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
756 | |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
757 | switch (state) |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
758 | { |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
759 | case PURPLE_TYPING: |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
760 | typing_str = "%typing%"; |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
761 | break; |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
762 | |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
763 | case PURPLE_TYPED: |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
764 | case PURPLE_NOT_TYPING: |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
765 | default: |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
766 | typing_str = "%stoptyping%"; |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
767 | break; |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
768 | } |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
769 | |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
770 | purple_debug_info("msim", "msim_send_typing(%s): %d (%s)\n", name, state, typing_str); |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
771 | msim_send_bm(session, name, typing_str, MSIM_BM_ACTION); |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
772 | return 0; |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
773 | } |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
774 | |
|
17969
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
775 | /** Retrieve a user's profile. */ |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
776 | void msim_get_info(PurpleConnection *gc, const gchar *name) |
|
17969
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
777 | { |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
778 | PurpleNotifyUserInfo *user_info; |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
779 | PurpleBuddy *buddy; |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
780 | MsimSession *session; |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
781 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
782 | session = (MsimSession *)gc->proto_data; |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
783 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
784 | user_info = purple_notify_user_info_new(); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
785 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
786 | buddy = purple_find_buddy(session->account, name); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
787 | if (!buddy) |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
788 | { |
|
17986
c3c06c30789c
Expand on a couple TODO comments. Current TODO counts:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17985
diff
changeset
|
789 | /* TODO: profile of buddies not on blist! Wouldn't be too hard, |
|
c3c06c30789c
Expand on a couple TODO comments. Current TODO counts:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17985
diff
changeset
|
790 | * just have to schedule a lookup, and when receive reply, |
|
c3c06c30789c
Expand on a couple TODO comments. Current TODO counts:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17985
diff
changeset
|
791 | * call purple_notify_userinfo() etc. |
|
c3c06c30789c
Expand on a couple TODO comments. Current TODO counts:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17985
diff
changeset
|
792 | */ |
|
17969
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
793 | purple_notify_user_info_add_pair(user_info, NULL, |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
794 | "Sorry, currently user information can only be retrieved from users on your buddy list."); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
795 | purple_notify_userinfo(gc, name, user_info, NULL, NULL); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
796 | purple_notify_user_info_destroy(user_info); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
797 | return; |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
798 | } |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
799 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
800 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
801 | /* Identification */ |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
802 | purple_notify_user_info_add_pair(user_info, "User Name", |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
803 | purple_blist_node_get_string(&buddy->node, "UserName")); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
804 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
805 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
806 | purple_notify_user_info_add_pair(user_info, "User ID", |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
807 | g_strdup_printf("%d", purple_blist_node_get_int(&buddy->node, "UserID"))); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
808 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
809 | purple_notify_user_info_add_pair(user_info, "Display Name", |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
810 | purple_blist_node_get_string(&buddy->node, "DisplayName")); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
811 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
812 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
813 | /* a/s/l...the vitals */ |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
814 | purple_notify_user_info_add_pair(user_info, "Age", |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
815 | g_strdup_printf("%d", purple_blist_node_get_int(&buddy->node, "Age"))); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
816 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
817 | purple_notify_user_info_add_pair(user_info, "Gender", |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
818 | purple_blist_node_get_string(&buddy->node, "Gender")); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
819 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
820 | purple_notify_user_info_add_pair(user_info, "Location", |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
821 | purple_blist_node_get_string(&buddy->node, "Location")); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
822 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
823 | /* Other information */ |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
824 | if (purple_blist_node_get_string(&buddy->node, "Headline")) |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
825 | purple_notify_user_info_add_pair(user_info, "Headline", |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
826 | purple_blist_node_get_string(&buddy->node, "Headline")); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
827 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
828 | purple_notify_user_info_add_pair(user_info, "Song", |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
829 | g_strdup_printf("%s - %s", |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
830 | purple_blist_node_get_string(&buddy->node, "BandName"), |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
831 | purple_blist_node_get_string(&buddy->node, "SongName"))); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
832 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
833 | purple_notify_user_info_add_pair(user_info, "Total Friends", |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
834 | g_strdup_printf("%d", purple_blist_node_get_int(&buddy->node, "TotalFriends"))); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
835 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
836 | |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
837 | purple_notify_userinfo(gc, name, user_info, NULL, NULL); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
838 | purple_notify_user_info_destroy(user_info); |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
839 | } |
|
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
840 | |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
841 | /** After a uid is resolved to username, tag it with the username and submit for processing. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
842 | * |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
843 | * @param session |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
844 | * @param userinfo Response messsage to resolving request. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
845 | * @param data MsimMessage *, the message to attach information to. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
846 | */ |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
847 | static void msim_incoming_resolved(MsimSession *session, MsimMessage *userinfo, gpointer data) |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
848 | { |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
849 | gchar *body_str; |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
850 | GHashTable *body; |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
851 | gchar *username; |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
852 | MsimMessage *msg; |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
853 | |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
854 | body_str = msim_msg_get_string(userinfo, "body"); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
855 | g_return_if_fail(body_str != NULL); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
856 | body = msim_parse_body(body_str); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
857 | g_return_if_fail(body != NULL); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
858 | g_free(body_str); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
859 | |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
860 | username = g_hash_table_lookup(body, "UserName"); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
861 | g_return_if_fail(username != NULL); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
862 | |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
863 | msg = (MsimMessage *)data; |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
864 | /* Special elements name beginning with '_', we'll use internally within the |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
865 | * program (did not come from the wire). */ |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
866 | msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
867 | |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
868 | msim_process(session, msg); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
869 | |
|
17951
313b994beb1d
Transition msim_incoming_im() to the callbackless infrastructure. Remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17950
diff
changeset
|
870 | /* TODO: Free copy cloned from msim_preprocess_incoming(). */ |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
871 | //XXX msim_msg_free(msg); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
872 | g_hash_table_destroy(body); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
873 | } |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
874 | |
|
17958
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
875 | #ifdef _MSIM_UID2USERNAME_WORKS |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
876 | /* Lookup a username by userid, from buddy list. |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
877 | * |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
878 | * @param wanted_uid |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
879 | * |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
880 | * @return Username of wanted_uid, if on blist, or NULL. Static string. |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
881 | * |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
882 | * XXX WARNING: UNKNOWN MEMORY CORRUPTION HERE! |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
883 | */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
884 | static const gchar *msim_uid2username_from_blist(MsimSession *session, guint wanted_uid) |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
885 | { |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
886 | GSList *buddies, *buddies_head; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
887 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
888 | for (buddies = buddies_head = purple_find_buddies(session->account, NULL); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
889 | buddies; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
890 | buddies = g_slist_next(buddies)) |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
891 | { |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
892 | PurpleBuddy *buddy; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
893 | guint uid; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
894 | gchar *name; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
895 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
896 | buddy = buddies->data; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
897 | |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
898 | uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
899 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
900 | /* name = buddy->name; */ /* crash */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
901 | /* name = PURPLE_BLIST_NODE_NAME(&buddy->node); */ /* crash */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
902 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
903 | /* XXX Is this right? Memory corruption here somehow. Happens only |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
904 | * when return one of these values. */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
905 | name = purple_buddy_get_name(buddy); /* crash */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
906 | /* return name; */ /* crash (with above) */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
907 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
908 | /* name = NULL; */ /* no crash */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
909 | /* return NULL; */ /* no crash (with anything) */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
910 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
911 | /* crash = |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
912 | *** glibc detected *** pidgin: realloc(): invalid pointer: 0x0000000000d2aec0 *** |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
913 | ======= Backtrace: ========= |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
914 | /lib/libc.so.6(__libc_realloc+0x323)[0x2b7bfc012e03] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
915 | /usr/lib/libglib-2.0.so.0(g_realloc+0x31)[0x2b7bfba79a41] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
916 | /usr/lib/libgtk-x11-2.0.so.0(gtk_tree_path_append_index+0x3a)[0x2b7bfa110d5a] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
917 | /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa1287dc] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
918 | /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128e56] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
919 | /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128efd] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
920 | /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x1b4)[0x2b7bfba72c84] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
921 | /usr/lib/libglib-2.0.so.0[0x2b7bfba75acd] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
922 | /usr/lib/libglib-2.0.so.0(g_main_loop_run+0x1ca)[0x2b7bfba75dda] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
923 | /usr/lib/libgtk-x11-2.0.so.0(gtk_main+0xa3)[0x2b7bfa0475f3] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
924 | pidgin(main+0x8be)[0x46b45e] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
925 | /lib/libc.so.6(__libc_start_main+0xf4)[0x2b7bfbfbf0c4] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
926 | pidgin(gtk_widget_grab_focus+0x39)[0x429ab9] |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
927 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
928 | or: |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
929 | *** glibc detected *** /usr/local/bin/pidgin: malloc(): memory corruption (fast): 0x0000000000c10076 *** |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
930 | (gdb) bt |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
931 | #0 0x00002b4074ecd47b in raise () from /lib/libc.so.6 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
932 | #1 0x00002b4074eceda0 in abort () from /lib/libc.so.6 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
933 | #2 0x00002b4074f0453b in __fsetlocking () from /lib/libc.so.6 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
934 | #3 0x00002b4074f0c810 in free () from /lib/libc.so.6 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
935 | #4 0x00002b4074f0d6dd in malloc () from /lib/libc.so.6 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
936 | #5 0x00002b4074974b5b in g_malloc () from /usr/lib/libglib-2.0.so.0 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
937 | #6 0x00002b40749868bf in g_strdup () from /usr/lib/libglib-2.0.so.0 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
938 | #7 0x00002b407810969f in msim_parse ( |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
939 | raw=0xd2a910 "\\bm\\100\\f\\3656574\\msg\\|s|0|ss|Offline") |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
940 | at message.c:648 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
941 | #8 0x00002b407810889c in msim_input_cb (gc_uncasted=0xcf92c0, |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
942 | source=<value optimized out>, cond=<value optimized out>) at myspace.c:1478 |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
943 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
944 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
945 | Why is it crashing in msim_parse()'s g_strdup()? |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
946 | */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
947 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
948 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
949 | purple_debug_info("msim", "msim_uid2username_from_blist: %s's uid=%d (want %d)\n", |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
950 | name, uid, wanted_uid); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
951 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
952 | if (uid == wanted_uid) |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
953 | { |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
954 | g_slist_free(buddies_head); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
955 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
956 | return name; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
957 | } |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
958 | } |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
959 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
960 | g_slist_free(buddies_head); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
961 | return NULL; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
962 | } |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
963 | |
|
17958
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
964 | #endif |
|
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
965 | |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
966 | /** Preprocess incoming messages, resolving as needed, calling msim_process() when ready to process. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
967 | * |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
968 | * @param session |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
969 | * @param msg MsimMessage *, freed by caller. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
970 | */ |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
971 | gboolean msim_preprocess_incoming(MsimSession *session, MsimMessage *msg) |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
972 | { |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
973 | if (msim_msg_get(msg, "bm") && msim_msg_get(msg, "f")) |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
974 | { |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
975 | guint uid; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
976 | const gchar *username; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
977 | |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
978 | /* 'f' = userid message is from, in buddy messages */ |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
979 | uid = msim_msg_get_integer(msg, "f"); |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
980 | |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
981 | /* TODO: Make caching work. Currently it is commented out because |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
982 | * it crashes for unknown reasons, memory realloc error. */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
983 | //#define _MSIM_UID2USERNAME_WORKS |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
984 | #ifdef _MSIM_UID2USERNAME_WORKS |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
985 | username = msim_uid2username_from_blist(session, uid); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
986 | #else |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
987 | username = NULL; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
988 | #endif |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
989 | |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
990 | if (username) |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
991 | { |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
992 | /* Know username already, use it. */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
993 | purple_debug_info("msim", "msim_preprocess_incoming: tagging with _username=%s\n", |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
994 | username); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
995 | msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
996 | return msim_process(session, msg); |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
997 | |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
998 | } else { |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
999 | /* Send lookup request. */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1000 | /* XXX: where is msim_msg_get_string() freed? make _strdup and _nonstrdup. */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1001 | purple_debug_info("msim", "msim_incoming: sending lookup, setting up callback\n"); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1002 | msim_lookup_user(session, msim_msg_get_string(msg, "f"), msim_incoming_resolved, msim_msg_clone(msg)); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1003 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1004 | /* indeterminate */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1005 | return TRUE; |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1006 | } |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1007 | } else { |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1008 | /* Nothing to resolve - send directly to processing. */ |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1009 | return msim_process(session, msg); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1010 | } |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1011 | } |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1012 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1013 | /** |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1014 | * Process a message. |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1015 | * |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1016 | * @param session |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1017 | * @param msg A message from the server, ready for processing (possibly with resolved username information attached). Caller frees. |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1018 | * |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1019 | * @return TRUE if successful. FALSE if processing failed. |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1020 | */ |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1021 | gboolean msim_process(MsimSession *session, MsimMessage *msg) |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1022 | { |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1023 | g_return_val_if_fail(session != NULL, -1); |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
1024 | g_return_val_if_fail(msg != NULL, -1); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1025 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
1026 | #ifdef MSIM_DEBUG_MSG |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
1027 | { |
|
17942
4d750e00cdae
Change msim_msg_debug_string() to msim_msg_dump(), which prints the string
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17941
diff
changeset
|
1028 | msim_msg_dump("ready to process: %s\n", msg); |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
1029 | } |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
1030 | #endif |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1031 | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1032 | if (msim_msg_get(msg, "nc")) |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1033 | { |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1034 | return msim_login_challenge(session, msg); |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1035 | } else if (msim_msg_get(msg, "sesskey")) { |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1036 | |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1037 | purple_connection_update_progress(session->gc, _("Connected"), 3, 4); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1038 | |
|
17941
cdc104d92cdf
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17940
diff
changeset
|
1039 | session->sesskey = msim_msg_get_integer(msg, "sesskey"); |
|
cdc104d92cdf
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17940
diff
changeset
|
1040 | purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1041 | |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1042 | /* Comes with: proof,profileid,userid,uniquenick -- all same values |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
1043 | * some of the time, but can vary. This is our own user ID. */ |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1044 | session->userid = msim_msg_get_integer(msg, "userid"); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1045 | |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
1046 | /* TODO: fake our own userid being online */ |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
1047 | |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1048 | purple_connection_set_state(session->gc, PURPLE_CONNECTED); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1049 | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1050 | return TRUE; |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1051 | } else if (msim_msg_get(msg, "bm")) { |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1052 | guint bm; |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1053 | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1054 | bm = msim_msg_get_integer(msg, "bm"); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1055 | switch (bm) |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1056 | { |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1057 | case MSIM_BM_STATUS: |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1058 | return msim_status(session, msg); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1059 | case MSIM_BM_INSTANT: |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1060 | return msim_incoming_im(session, msg); |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1061 | case MSIM_BM_ACTION: |
|
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1062 | return msim_incoming_action(session, msg); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1063 | default: |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1064 | /* Not really an IM, but show it for informational |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1065 | * purposes during development. */ |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1066 | return msim_incoming_im(session, msg); |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1067 | } |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1068 | } else if (msim_msg_get(msg, "rid")) { |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1069 | return msim_process_reply(session, msg); |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1070 | } else if (msim_msg_get(msg, "error")) { |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1071 | return msim_error(session, msg); |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1072 | } else if (msim_msg_get(msg, "ka")) { |
|
17983
ab605d563943
Add TODO for msimprpl to timeout (handling keep-alives).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17982
diff
changeset
|
1073 | /* TODO: Setup a timer, if keep-alive is not received within ~3 minutes, then |
|
ab605d563943
Add TODO for msimprpl to timeout (handling keep-alives).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17982
diff
changeset
|
1074 | * disconnect the user. As it stands, if Internet connection goes out (this |
|
ab605d563943
Add TODO for msimprpl to timeout (handling keep-alives).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17982
diff
changeset
|
1075 | * just happened here), msimprpl will appear to be connected forever, while |
|
ab605d563943
Add TODO for msimprpl to timeout (handling keep-alives).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17982
diff
changeset
|
1076 | * other plugins (oscar, etc.) will time out. Msimprpl should timeout too. */ |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1077 | purple_debug_info("msim", "msim_process: got keep alive\n"); |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1078 | return TRUE; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1079 | } else { |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
1080 | msim_unrecognized(session, msg, "in msim_process"); |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1081 | return FALSE; |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1082 | } |
|
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1083 | } |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
1084 | |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1085 | /** Store an field of information about a buddy. */ |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1086 | void msim_store_buddy_info_each(gpointer key, gpointer value, gpointer user_data) |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1087 | { |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1088 | PurpleBuddy *buddy; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1089 | gchar *key_str, *value_str; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1090 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1091 | buddy = (PurpleBuddy *)user_data; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1092 | key_str = (gchar *)key; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1093 | value_str = (gchar *)value; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1094 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1095 | if (strcmp(key_str, "UserID") == 0 || |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1096 | strcmp(key_str, "Age") == 0 || |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1097 | strcmp(key_str, "TotalFriends") == 0) |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1098 | { |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1099 | /* Certain fields get set as integers, instead of strings, for |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1100 | * convenience. May not be the best way to do it, but having at least |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1101 | * UserID as an integer is convenient...until it overflows! */ |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1102 | purple_blist_node_set_int(&buddy->node, key_str, atol(value_str)); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1103 | } else { |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1104 | purple_blist_node_set_string(&buddy->node, key_str, value_str); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1105 | } |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1106 | } |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1107 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1108 | /** Save buddy information to the buddy list from a user info reply message. |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1109 | * |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1110 | * @param session |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1111 | * @param msg The user information reply, with any amount of information. |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1112 | * |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1113 | * The information is saved to the buddy's blist node, which ends up in blist.xml. |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1114 | */ |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1115 | gboolean msim_store_buddy_info(MsimSession *session, MsimMessage *msg) |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1116 | { |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1117 | GHashTable *body; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1118 | gchar *username, *body_str, *uid; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1119 | PurpleBuddy *buddy; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1120 | guint rid; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1121 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1122 | rid = msim_msg_get_integer(msg, "rid"); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1123 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1124 | g_return_val_if_fail(rid != 0, FALSE); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1125 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1126 | body_str = msim_msg_get_string(msg, "body"); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1127 | g_return_val_if_fail(body_str != NULL, FALSE); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1128 | body = msim_parse_body(body_str); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1129 | g_free(body_str); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1130 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1131 | /* TODO: implement a better hash-like interface, and use it. */ |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1132 | username = g_hash_table_lookup(body, "UserName"); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1133 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1134 | if (!username) |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1135 | { |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1136 | purple_debug_info("msim", |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1137 | "msim_process_reply: not caching body, no UserName\n"); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1138 | return FALSE; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1139 | } |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1140 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1141 | uid = g_hash_table_lookup(body, "UserID"); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1142 | g_return_val_if_fail(uid, FALSE); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1143 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1144 | purple_debug_info("msim", "associating uid %d with username %s\n", uid, username); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1145 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1146 | buddy = purple_find_buddy(session->account, username); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1147 | if (buddy) |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1148 | { |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1149 | g_hash_table_foreach(body, msim_store_buddy_info_each, buddy); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1150 | } |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1151 | |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1152 | return TRUE; |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1153 | } |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1154 | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1155 | /** |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
1156 | * Process a persistance message reply from the server. |
| 16322 | 1157 | * |
| 1158 | * @param session | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1159 | * @param msg Message reply from server. |
| 16322 | 1160 | * |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1161 | * @return TRUE if successful. |
| 16322 | 1162 | */ |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1163 | gboolean msim_process_reply(MsimSession *session, MsimMessage *msg) |
| 16322 | 1164 | { |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1165 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1166 | g_return_val_if_fail(msg != NULL, FALSE); |
| 16322 | 1167 | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1168 | if (msim_msg_get(msg, "rid")) /* msim_lookup_user sets callback for here */ |
| 16322 | 1169 | { |
| 1170 | MSIM_USER_LOOKUP_CB cb; | |
| 1171 | gpointer data; | |
| 1172 | guint rid; | |
|
17958
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1173 | |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1174 | msim_store_buddy_info(session, msg); |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1175 | |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1176 | rid = msim_msg_get_integer(msg, "rid"); |
| 16322 | 1177 | |
| 1178 | /* If a callback is registered for this userid lookup, call it. */ | |
| 1179 | cb = g_hash_table_lookup(session->user_lookup_cb, GUINT_TO_POINTER(rid)); | |
| 1180 | data = g_hash_table_lookup(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); | |
| 1181 | ||
| 1182 | if (cb) | |
| 1183 | { | |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1184 | purple_debug_info("msim", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1185 | "msim_process_body: calling callback now\n"); |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1186 | /* Clone message, so that the callback 'cb' can use it (needs to free it also). */ |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1187 | cb(session, msim_msg_clone(msg), data); |
| 16322 | 1188 | g_hash_table_remove(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
| 1189 | g_hash_table_remove(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); | |
| 1190 | } else { | |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1191 | purple_debug_info("msim", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1192 | "msim_process_body: no callback for rid %d\n", rid); |
| 16322 | 1193 | } |
| 1194 | } | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1195 | |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1196 | return TRUE; |
| 16322 | 1197 | } |
| 1198 | ||
| 1199 | /** | |
| 1200 | * Handle an error from the server. | |
| 1201 | * | |
| 1202 | * @param session | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1203 | * @param msg The message. |
| 16322 | 1204 | * |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1205 | * @return TRUE if successfully reported error. |
| 16322 | 1206 | */ |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1207 | gboolean msim_error(MsimSession *session, MsimMessage *msg) |
| 16322 | 1208 | { |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1209 | gchar *errmsg, *full_errmsg; |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1210 | guint err; |
| 16322 | 1211 | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1212 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1213 | g_return_val_if_fail(msg != NULL, FALSE); |
| 16322 | 1214 | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1215 | err = msim_msg_get_integer(msg, "err"); |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1216 | errmsg = msim_msg_get_string(msg, "errmsg"); |
| 16322 | 1217 | |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1218 | full_errmsg = g_strdup_printf(_("Protocol error, code %d: %s"), err, errmsg); |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1219 | |
|
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1220 | g_free(errmsg); |
| 16322 | 1221 | |
| 16324 | 1222 | purple_debug_info("msim", "msim_error: %s\n", full_errmsg); |
| 16322 | 1223 | |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
1224 | purple_notify_error(session->account, g_strdup(_("MySpaceIM Error")), |
| 16322 | 1225 | full_errmsg, NULL); |
| 1226 | ||
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1227 | /* Destroy session if fatal. */ |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1228 | if (msim_msg_get(msg, "fatal")) |
| 16322 | 1229 | { |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1230 | purple_debug_info("msim", "fatal error, closing\n"); |
| 16324 | 1231 | purple_connection_error(session->gc, full_errmsg); |
|
17973
11491f81a0aa
Fix crash when re-logging in.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17970
diff
changeset
|
1232 | |
|
11491f81a0aa
Fix crash when re-logging in.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17970
diff
changeset
|
1233 | msim_close(session->gc); |
| 16322 | 1234 | } |
| 1235 | ||
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1236 | return TRUE; |
| 16322 | 1237 | } |
| 1238 | ||
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1239 | /** |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1240 | * Process incoming status messages. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1241 | * |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1242 | * @param session |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1243 | * @param msg Status update message. Caller frees. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1244 | * |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1245 | * @return TRUE if successful. |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1246 | */ |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1247 | gboolean msim_status(MsimSession *session, MsimMessage *msg) |
| 16322 | 1248 | { |
| 16324 | 1249 | PurpleBuddyList *blist; |
| 1250 | PurpleBuddy *buddy; | |
| 1251 | //PurpleStatus *status; | |
| 16322 | 1252 | gchar **status_array; |
| 1253 | GList *list; | |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1254 | gchar *status_headline; |
| 16322 | 1255 | gchar *status_str; |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1256 | gint i, status_code, purple_status_code; |
| 16322 | 1257 | gchar *username; |
| 1258 | ||
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1259 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1260 | g_return_val_if_fail(msg != NULL, FALSE); |
|
17949
a74745e42b2b
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17948
diff
changeset
|
1261 | |
|
a74745e42b2b
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17948
diff
changeset
|
1262 | status_str = msim_msg_get_string(msg, "msg"); |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1263 | g_return_val_if_fail(status_str != NULL, FALSE); |
| 16322 | 1264 | |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1265 | msim_msg_dump("msim_status msg=%s\n", msg); |
| 16322 | 1266 | |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1267 | /* Helpfully looked up by msim_incoming_resolve() for us. */ |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1268 | username = msim_msg_get_string(msg, "_username"); |
| 16322 | 1269 | /* Note: DisplayName doesn't seem to be resolvable. It could be displayed on |
| 1270 | * the buddy list, if the UserID was stored along with it. */ | |
| 1271 | ||
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1272 | if (username == NULL) |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1273 | { |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1274 | g_free(status_str); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1275 | g_return_val_if_fail(NULL, FALSE); |
|
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1276 | } |
| 16322 | 1277 | |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1278 | purple_debug_info("msim", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1279 | "msim_status_cb: updating status for <%s> to <%s>\n", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1280 | username, status_str); |
| 16322 | 1281 | |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1282 | /* TODO: generic functions to split into a GList, part of MsimMessage */ |
| 16322 | 1283 | status_array = g_strsplit(status_str, "|", 0); |
| 1284 | for (list = NULL, i = 0; | |
| 1285 | status_array[i]; | |
| 1286 | i++) | |
| 1287 | { | |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1288 | /* Note: this adds the 0th ordinal too, which might not be a value |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1289 | * at all (the 0 in the 0|1|2|3... status fields, but 0 always appears blank). |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1290 | */ |
| 16322 | 1291 | list = g_list_append(list, status_array[i]); |
| 1292 | } | |
| 1293 | ||
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1294 | /* Example fields: |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1295 | * |s|0|ss|Offline |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1296 | * |s|1|ss|:-)|ls||ip|0|p|0 |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1297 | * |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1298 | * TODO: write list support in MsimMessage, and use it here. |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1299 | */ |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1300 | |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1301 | status_code = atoi(g_list_nth_data(list, MSIM_STATUS_ORDINAL_ONLINE)); |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1302 | purple_debug_info("msim", "msim_status_cb: %s's status code = %d\n", username, status_code); |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1303 | status_headline = g_list_nth_data(list, MSIM_STATUS_ORDINAL_HEADLINE); |
| 16322 | 1304 | |
| 16324 | 1305 | blist = purple_get_blist(); |
| 16322 | 1306 | |
| 1307 | /* Add buddy if not found */ | |
| 16324 | 1308 | buddy = purple_find_buddy(session->account, username); |
| 16322 | 1309 | if (!buddy) |
| 1310 | { | |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1311 | purple_debug_info("msim", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1312 | "msim_status: making new buddy for %s\n", username); |
| 16324 | 1313 | buddy = purple_buddy_new(session->account, username, NULL); |
| 16322 | 1314 | |
| 16324 | 1315 | purple_blist_add_buddy(buddy, NULL, NULL, NULL); |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
1316 | |
|
17943
d33c1657f68b
Add TODOs about username/email->userid resolution, use g_return_if_fail() in a few places.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17942
diff
changeset
|
1317 | /* All buddies on list should have 'uid' integer associated with them. */ |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1318 | purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f")); |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
1319 | |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
1320 | msim_store_buddy_info(session, msg); |
| 16322 | 1321 | } else { |
| 16324 | 1322 | purple_debug_info("msim", "msim_status: found buddy %s\n", username); |
| 16322 | 1323 | } |
| 1324 | ||
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
1325 | purple_blist_node_set_string(&buddy->node, "Headline", status_headline); |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1326 | |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1327 | /* Set user status */ |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1328 | switch (status_code) |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1329 | { |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1330 | case 1: purple_status_code = PURPLE_STATUS_AVAILABLE; |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1331 | break; |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1332 | case 0: purple_status_code = PURPLE_STATUS_OFFLINE; |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1333 | break; |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1334 | default: |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1335 | purple_debug_info("msim", "msim_status_cb for %s, unknown status code %d\n", |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1336 | username, status_code); |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1337 | purple_status_code = PURPLE_STATUS_AVAILABLE; |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1338 | } |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
1339 | purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL); |
| 16322 | 1340 | |
| 1341 | g_strfreev(status_array); | |
|
17949
a74745e42b2b
msim_status_cb() now takes a MsimMessage *, just like msim_send_im_cb() and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17948
diff
changeset
|
1342 | g_free(status_str); |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1343 | g_free(username); |
| 16322 | 1344 | g_list_free(list); |
| 1345 | ||
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1346 | return TRUE; |
| 16322 | 1347 | } |
| 1348 | ||
|
17975
1404d3846cd4
Update several outdated TODO comments.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17974
diff
changeset
|
1349 | /** Add a buddy to user's buddy list. */ |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1350 | void msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1351 | { |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1352 | MsimSession *session; |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1353 | MsimMessage *msg; |
|
17987
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1354 | /* MsimMessage *msg_blocklist; */ |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1355 | |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1356 | session = (MsimSession *)gc->proto_data; |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1357 | purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n", buddy->name, |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1358 | group ? group->name : "(no group)"); |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1359 | |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1360 | msg = msim_msg_new(TRUE, |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1361 | "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
|
17941
cdc104d92cdf
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17940
diff
changeset
|
1362 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1363 | /* "newprofileid" will be inserted here with uid. */ |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1364 | "reason", MSIM_TYPE_STRING, g_strdup(""), |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1365 | NULL); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1366 | |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1367 | if (!msim_postprocess_outgoing(session, msg, buddy->name, "newprofileid", "reason")) |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1368 | { |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1369 | purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed.")); |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1370 | msim_msg_free(msg); |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1371 | return; |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1372 | } |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1373 | msim_msg_free(msg); |
|
17987
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1374 | |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1375 | /* TODO: if addbuddy fails ('error' message is returned), delete added buddy from |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1376 | * buddy list since Purple adds it locally. */ |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1377 | |
|
17987
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1378 | /* TODO: Update blocklist. */ |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1379 | #if 0 |
|
17987
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1380 | msg_blocklist = msim_msg_new(TRUE, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1381 | "persist", MSIM_TYPE_INTEGER, 1, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1382 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1383 | "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_PUT, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1384 | "dsn", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_DSN, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1385 | "lid", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_LID, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1386 | /* TODO: Use msim_new_reply_callback to get rid. */ |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1387 | "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1388 | "body", MSIM_TYPE_STRING, |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1389 | g_strdup_printf("ContactID=<uid>\034" |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1390 | "GroupName=%s\034" |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1391 | "Position=1000\034" |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1392 | "Visibility=1\034" |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1393 | "NickName=\034" |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1394 | "NameSelect=0", |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1395 | "Friends" /*group->name*/ )); |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1396 | |
|
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1397 | if (!msim_postprocess_outgoing(session, msg, buddy->name, "body", NULL)) |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1398 | { |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1399 | purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); |
|
17987
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1400 | msim_msg_free(msg_blocklist); |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1401 | return; |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1402 | } |
|
17987
a0baf4e80ee9
Rework addbuddy, but leave it commented-out (non-functional). Add TODO for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17986
diff
changeset
|
1403 | msim_msg_free(msg_blocklist); |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1404 | #endif |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1405 | } |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1406 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1407 | /** Perform actual postprocessing on a message, adding userid as specified. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1408 | * |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1409 | * @param msg The message to postprocess. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1410 | * @param uid_before Name of field where to insert new field before, or NULL for end. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1411 | * @param uid_field_name Name of field to add uid to. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1412 | * @param uid The userid to insert. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1413 | * |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1414 | * If the field named by uid_field_name already exists, then its string contents will |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1415 | * be used for the field, except "<uid>" will be replaced by the userid. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1416 | * |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1417 | * If the field named by uid_field_name does not exist, it will be added before the |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1418 | * field named by uid_before, as an integer, with the userid. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1419 | * |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1420 | * Does not handle sending, or scheduling userid lookup. For that, see msim_postprocess_outgoing(). |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1421 | */ |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
1422 | MsimMessage *msim_do_postprocessing(MsimMessage *msg, const gchar *uid_before, const gchar *uid_field_name, guint uid) |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1423 | { |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1424 | purple_debug_info("msim", "msim_do_postprocessing called with ufn=%s, ub=%s, uid=%d\n", |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1425 | uid_field_name, uid_before, uid); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1426 | msim_msg_dump("msim_do_postprocessing msg: %s\n", msg); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1427 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1428 | /* First, check - if the field already exists, treat it as a format string. */ |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1429 | if (msim_msg_get(msg, uid_field_name)) |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1430 | { |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1431 | MsimMessageElement *elem; |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1432 | gchar *fmt_string; |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1433 | gchar *uid_str; |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1434 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1435 | /* Warning: this probably violates the encapsulation of MsimMessage */ |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1436 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1437 | elem = msim_msg_get(msg, uid_field_name); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1438 | g_return_val_if_fail(elem->type == MSIM_TYPE_STRING, NULL); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1439 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1440 | /* Get the raw string, not with msim_msg_get_string() since that copies it. |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1441 | * Want the original string so can free it. */ |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1442 | fmt_string = (gchar *)(elem->data); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1443 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1444 | uid_str = g_strdup_printf("%d", uid); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1445 | elem->data = str_replace(fmt_string, "<uid>", uid_str); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1446 | g_free(uid_str); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1447 | g_free(fmt_string); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1448 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1449 | purple_debug_info("msim", "msim_postprocess_outgoing_cb: formatted new string, %s\n", |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1450 | elem->data); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1451 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1452 | } else { |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1453 | /* Otherwise, insert new field into outgoing message. */ |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1454 | msg = msim_msg_insert_before(msg, uid_before, uid_field_name, MSIM_TYPE_INTEGER, GUINT_TO_POINTER(uid)); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1455 | } |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1456 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1457 | return msg; |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1458 | } |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1459 | |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1460 | /** Callback for msim_postprocess_outgoing() to add a userid to a message, and send it (once receiving userid). |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1461 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1462 | * @param session |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1463 | * @param userinfo The user information reply message, containing the user ID |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1464 | * @param data The message to postprocess and send. |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1465 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1466 | * The data message should contain these fields: |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1467 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1468 | * _uid_field_name: string, name of field to add with userid from userinfo message |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1469 | * _uid_before: string, name of field before field to insert, or NULL for end |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1470 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1471 | * |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1472 | */ |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1473 | void msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, gpointer data) |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1474 | { |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1475 | gchar *body_str; |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1476 | GHashTable *body; |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1477 | gchar *uid, *uid_field_name, *uid_before; |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1478 | MsimMessage *msg; |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1479 | |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1480 | msg = (MsimMessage *)data; |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1481 | |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1482 | msim_msg_dump("msim_postprocess_outgoing_cb() got msg=%s\n", msg); |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1483 | |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1484 | /* Obtain userid from userinfo message. */ |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1485 | body_str = msim_msg_get_string(userinfo, "body"); |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1486 | g_return_if_fail(body_str != NULL); |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1487 | body = msim_parse_body(body_str); |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1488 | g_free(body_str); |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1489 | |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1490 | uid = g_strdup(g_hash_table_lookup(body, "UserID")); |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1491 | g_hash_table_destroy(body); |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1492 | |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1493 | uid_field_name = msim_msg_get_string(msg, "_uid_field_name"); |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1494 | uid_before = msim_msg_get_string(msg, "_uid_before"); |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1495 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1496 | msg = msim_do_postprocessing(msg, uid_before, uid_field_name, atol(uid)); |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1497 | |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1498 | /* Send */ |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1499 | if (!msim_msg_send(session, msg)) |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1500 | { |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1501 | purple_debug_info("msim", "msim_postprocess_outgoing_cb: sending failed for message: %s\n", msg); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1502 | } |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1503 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1504 | |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1505 | /* Free field names AFTER sending message, because MsimMessage does NOT copy |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1506 | * field names - instead, treats them as static strings (which they usually are). |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1507 | */ |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1508 | g_free(uid_field_name); |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1509 | g_free(uid_before); |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1510 | |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1511 | //msim_msg_free(msg); |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1512 | } |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1513 | |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1514 | /** Postprocess and send a message. |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1515 | * |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1516 | * @param session |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1517 | * @param msg Message to postprocess. Will NOT be freed. |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1518 | * @param username Username to resolve. Assumed to be a static string (will not be freed or copied). |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1519 | * @param uid_field_name Name of new field to add, containing uid of username. Static string. |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1520 | * @param uid_before Name of existing field to insert username field before. Static string. |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1521 | * |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1522 | * @return Postprocessed message. |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1523 | */ |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
1524 | gboolean msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg, const gchar *username, |
|
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
1525 | const gchar *uid_field_name, const gchar *uid_before) |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1526 | { |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1527 | PurpleBuddy *buddy; |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1528 | guint uid; |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1529 | gboolean rc; |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1530 | |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1531 | /* Store information for msim_postprocess_outgoing_cb(). */ |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1532 | purple_debug_info("msim", "msim_postprocess_outgoing(u=%s,ufn=%s,ub=%s)\n", |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1533 | username, uid_field_name, uid_before); |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1534 | msim_msg_dump("msim_postprocess_outgoing: msg before=%s\n", msg); |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1535 | msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1536 | msg = msim_msg_append(msg, "_uid_field_name", MSIM_TYPE_STRING, g_strdup(uid_field_name)); |
|
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1537 | msg = msim_msg_append(msg, "_uid_before", MSIM_TYPE_STRING, g_strdup(uid_before)); |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1538 | |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1539 | /* First, try the most obvious. If numeric userid is given, use that directly. */ |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1540 | if (msim_is_userid(username)) |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1541 | { |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1542 | uid = atol(username); |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1543 | } else { |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1544 | /* Next, see if on buddy list and know uid. */ |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1545 | buddy = purple_find_buddy(session->account, username); |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1546 | if (buddy) |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1547 | { |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
1548 | uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1549 | } else { |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1550 | uid = 0; |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1551 | } |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1552 | |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1553 | if (!buddy || !uid) |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1554 | { |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1555 | /* Don't have uid offhand - need to ask for it, and wait until hear back before sending. */ |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1556 | purple_debug_info("msim", ">>> msim_postprocess_outgoing: couldn't find username %s in blist\n", |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1557 | username); |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1558 | msim_msg_dump("msim_postprocess_outgoing - scheduling lookup, msg=%s\n", msg); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1559 | /* TODO: where is cloned message freed? Should be in _cb. */ |
|
17955
70cfe01b0466
Pass postprocessing parameters inside MsimMessage * instead of in a new struct.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17954
diff
changeset
|
1560 | msim_lookup_user(session, username, msim_postprocess_outgoing_cb, msim_msg_clone(msg)); |
|
17954
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1561 | return TRUE; /* not sure of status yet - haven't sent! */ |
|
b5d62ba24136
Change msim_send_im() to use msim_postprocess_outgoing(), eliminating the
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17953
diff
changeset
|
1562 | } |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1563 | } |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1564 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1565 | /* Already have uid, postprocess and send msg immediately. */ |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1566 | purple_debug_info("msim", "msim_postprocess_outgoing: found username %s has uid %d\n", |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1567 | username, uid); |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1568 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1569 | msg = msim_do_postprocessing(msg, uid_before, uid_field_name, uid); |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1570 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1571 | msim_msg_dump("msim_postprocess_outgoing: msg after (uid immediate)=%s\n", msg); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1572 | |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1573 | rc = msim_msg_send(session, msg); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1574 | |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1575 | //msim_msg_free(msg); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1576 | |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1577 | return rc; |
|
17953
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1578 | } |
|
c76e16c7cf0a
Add, but do not use, two new functions to postprocess outgoing messages
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17952
diff
changeset
|
1579 | |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1580 | /** Remove a buddy from the user's buddy list. */ |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1581 | void msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1582 | { |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1583 | MsimSession *session; |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1584 | MsimMessage *delbuddy_msg; |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1585 | MsimMessage *persist_msg; |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1586 | MsimMessage *blocklist_msg; |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1587 | |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1588 | session = (MsimSession *)gc->proto_data; |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1589 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1590 | delbuddy_msg = msim_msg_new(TRUE, |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1591 | "delbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
|
17941
cdc104d92cdf
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17940
diff
changeset
|
1592 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1593 | /* 'delprofileid' with uid will be inserted here. */ |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1594 | NULL); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1595 | /* TODO: free msg */ |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1596 | if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL)) |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1597 | { |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1598 | purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed")); |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1599 | return; |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1600 | } |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1601 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1602 | persist_msg = msim_msg_new(TRUE, |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1603 | "persist", MSIM_TYPE_INTEGER, 1, |
|
17941
cdc104d92cdf
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17940
diff
changeset
|
1604 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1605 | "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE, |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1606 | "dsn", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_DSN, |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1607 | "lid", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_LID, |
|
17961
16c5545a0a95
Remove msim_get_own_uid{,_cb}() - it is not needed, since the login
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17960
diff
changeset
|
1608 | "uid", MSIM_TYPE_INTEGER, session->userid, |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1609 | "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1610 | /* <uid> will be replaced by postprocessing */ |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1611 | "body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"), |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1612 | NULL); |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1613 | |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1614 | /* TODO: free msg */ |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1615 | if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL)) |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1616 | { |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1617 | purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed")); |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1618 | return; |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1619 | } |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1620 | |
|
17963
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1621 | blocklist_msg = msim_msg_new(TRUE, |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1622 | "blocklist", MSIM_TYPE_BOOLEAN, TRUE, |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1623 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1624 | /* TODO: MsimMessage lists */ |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1625 | "idlist", MSIM_TYPE_STRING, g_strdup("a-|<uid>|b-|<uid>"), |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1626 | NULL); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1627 | |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1628 | if (!msim_postprocess_outgoing(session, blocklist_msg, buddy->name, "idlist", NULL)) |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1629 | { |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1630 | purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("blocklist command failed")); |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1631 | return; |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1632 | } |
|
07e61fbc0abe
Make msim_remove_buddy() functional. It now sends the delbuddy, persist,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17961
diff
changeset
|
1633 | |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1634 | /* TODO: update blocklist */ |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1635 | } |
|
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
1636 | |
|
17968
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
1637 | /** Return whether the buddy can be messaged while offline. |
|
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
1638 | * |
|
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
1639 | * I always return TRUE, to allow sending to buddies whose status has not yet |
|
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
1640 | * been received. The protocol _does_ support offline messages, but not this plugin. |
|
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
1641 | * TODO: Real offline message support. |
|
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
1642 | */ |
|
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
1643 | gboolean msim_offline_message(const PurpleBuddy *buddy) |
|
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
1644 | { |
|
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
1645 | return TRUE; |
|
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
1646 | } |
| 16322 | 1647 | |
| 1648 | ||
| 1649 | /** | |
| 1650 | * Callback when input available. | |
| 1651 | * | |
| 16324 | 1652 | * @param gc_uncasted A PurpleConnection pointer. |
| 16322 | 1653 | * @param source File descriptor. |
| 16324 | 1654 | * @param cond PURPLE_INPUT_READ |
| 16322 | 1655 | * |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1656 | * Reads the input, and calls msim_preprocess_incoming() to handle it. |
| 16322 | 1657 | */ |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
1658 | void msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond) |
| 16322 | 1659 | { |
| 16324 | 1660 | PurpleConnection *gc; |
| 1661 | PurpleAccount *account; | |
| 16322 | 1662 | MsimSession *session; |
| 1663 | gchar *end; | |
| 1664 | int n; | |
| 1665 | ||
| 1666 | g_return_if_fail(gc_uncasted != NULL); | |
| 1667 | g_return_if_fail(source >= 0); /* Note: 0 is a valid fd */ | |
| 1668 | ||
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
1669 | gc = (PurpleConnection *)(gc_uncasted); |
| 16324 | 1670 | account = purple_connection_get_account(gc); |
| 16322 | 1671 | session = gc->proto_data; |
| 1672 | ||
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
1673 | g_return_if_fail(cond == PURPLE_INPUT_READ); |
|
17958
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1674 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
| 16322 | 1675 | |
| 1676 | /* Only can handle so much data at once... | |
| 1677 | * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE. | |
| 1678 | * Should be large enough to hold the largest protocol message. | |
| 1679 | */ | |
| 1680 | if (session->rxoff == MSIM_READ_BUF_SIZE) | |
| 1681 | { | |
| 16324 | 1682 | purple_debug_error("msim", "msim_input_cb: %d-byte read buffer full!\n", |
| 16322 | 1683 | MSIM_READ_BUF_SIZE); |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
1684 | purple_connection_error(gc, _("Read buffer full")); |
|
17973
11491f81a0aa
Fix crash when re-logging in.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17970
diff
changeset
|
1685 | |
|
11491f81a0aa
Fix crash when re-logging in.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17970
diff
changeset
|
1686 | msim_close(session->gc); |
| 16322 | 1687 | return; |
| 1688 | } | |
| 1689 | ||
| 16324 | 1690 | purple_debug_info("msim", "buffer at %d (max %d), reading up to %d\n", |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1691 | session->rxoff, MSIM_READ_BUF_SIZE, |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1692 | MSIM_READ_BUF_SIZE - session->rxoff); |
| 16322 | 1693 | |
| 1694 | /* Read into buffer. On Win32, need recv() not read(). session->fd also holds | |
| 1695 | * the file descriptor, but it sometimes differs from the 'source' parameter. | |
| 1696 | */ | |
| 1697 | n = recv(session->fd, session->rxbuf + session->rxoff, MSIM_READ_BUF_SIZE - session->rxoff, 0); | |
| 1698 | ||
| 1699 | if (n < 0 && errno == EAGAIN) | |
| 1700 | { | |
| 1701 | return; | |
| 1702 | } | |
| 1703 | else if (n < 0) | |
| 1704 | { | |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
1705 | purple_connection_error(gc, _("Read error")); |
| 16324 | 1706 | purple_debug_error("msim", "msim_input_cb: read error, ret=%d, " |
| 16322 | 1707 | "error=%s, source=%d, fd=%d (%X))\n", |
| 1708 | n, strerror(errno), source, session->fd, session->fd); | |
|
17973
11491f81a0aa
Fix crash when re-logging in.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17970
diff
changeset
|
1709 | |
|
11491f81a0aa
Fix crash when re-logging in.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17970
diff
changeset
|
1710 | msim_close(session->gc); |
| 16322 | 1711 | return; |
| 1712 | } | |
| 1713 | else if (n == 0) | |
| 1714 | { | |
| 16324 | 1715 | purple_debug_info("msim", "msim_input_cb: server disconnected\n"); |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
1716 | purple_connection_error(gc, _("Server has disconnected")); |
| 16322 | 1717 | return; |
| 1718 | } | |
| 1719 | ||
| 1720 | /* Null terminate */ | |
| 1721 | session->rxbuf[session->rxoff + n] = 0; | |
| 1722 | ||
| 1723 | /* Check for embedded NULs. I don't handle them, and they shouldn't occur. */ | |
| 1724 | if (strlen(session->rxbuf + session->rxoff) != n) | |
| 1725 | { | |
| 1726 | /* Occurs after login, but it is not a null byte. */ | |
| 16324 | 1727 | purple_debug_info("msim", "msim_input_cb: strlen=%d, but read %d bytes" |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1728 | "--null byte encountered?\n", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1729 | strlen(session->rxbuf + session->rxoff), n); |
| 16324 | 1730 | //purple_connection_error(gc, "Invalid message - null byte on input"); |
| 16322 | 1731 | return; |
| 1732 | } | |
| 1733 | ||
| 1734 | session->rxoff += n; | |
| 16324 | 1735 | purple_debug_info("msim", "msim_input_cb: read=%d\n", n); |
| 16322 | 1736 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
1737 | #ifdef MSIM_DEBUG_RXBUF |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
1738 | purple_debug_info("msim", "buf=<%s>\n", session->rxbuf); |
|
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
1739 | #endif |
| 16322 | 1740 | |
| 1741 | /* Look for \\final\\ end markers. If found, process message. */ | |
| 1742 | while((end = strstr(session->rxbuf, MSIM_FINAL_STRING))) | |
| 1743 | { | |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
1744 | MsimMessage *msg; |
| 16322 | 1745 | |
|
17892
66984c1aac79
Re-add RC4 code from Samba, whose use is enabled by not defining
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17890
diff
changeset
|
1746 | #ifdef MSIM_DEBUG_RXBUF |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
1747 | purple_debug_info("msim", "in loop: buf=<%s>\n", session->rxbuf); |
|
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
1748 | #endif |
| 16322 | 1749 | *end = 0; |
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
1750 | msg = msim_parse(g_strdup(session->rxbuf)); |
|
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
1751 | if (!msg) |
| 16322 | 1752 | { |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1753 | purple_debug_info("msim", "msim_input_cb: couldn't parse <%s>\n", |
|
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1754 | session->rxbuf); |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
1755 | purple_connection_error(gc, _("Unparseable message")); |
| 16322 | 1756 | } |
| 1757 | else | |
| 1758 | { | |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1759 | /* Process message and then free it (processing function should |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1760 | * clone message if it wants to keep it afterwards.) */ |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1761 | if (!msim_preprocess_incoming(session, msg)) |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1762 | { |
|
17950
c146721d0ca7
Add message preprocessing in msim_preprocess_incoming(), to resolve
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17949
diff
changeset
|
1763 | msim_msg_dump("msim_input_cb: preprocessing message failed on msg: %s\n", msg); |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1764 | } |
|
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
1765 | msim_msg_free(msg); |
| 16322 | 1766 | } |
| 1767 | ||
| 1768 | /* Move remaining part of buffer to beginning. */ | |
| 1769 | session->rxoff -= strlen(session->rxbuf) + strlen(MSIM_FINAL_STRING); | |
| 1770 | memmove(session->rxbuf, end + strlen(MSIM_FINAL_STRING), | |
| 1771 | MSIM_READ_BUF_SIZE - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf)); | |
| 1772 | ||
| 1773 | /* Clear end of buffer */ | |
| 1774 | //memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf)); | |
| 1775 | } | |
| 1776 | } | |
| 1777 | ||
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1778 | /* Setup a callback, to be called when a reply is received with the returned rid. |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1779 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1780 | * @param cb The callback, an MSIM_USER_LOOKUP_CB. |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1781 | * @param data Arbitrary user data to be passed to callback (probably an MsimMessage *). |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1782 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1783 | * @return The request/reply ID, used to link replies with requests. Put the rid in your request. |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1784 | * |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1785 | * TODO: Make more generic and more specific: |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1786 | * 1) MSIM_USER_LOOKUP_CB - make it for PERSIST_REPLY, not just user lookup |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1787 | * 2) data - make it an MsimMessage? |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1788 | */ |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1789 | guint msim_new_reply_callback(MsimSession *session, MSIM_USER_LOOKUP_CB cb, gpointer data) |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1790 | { |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1791 | guint rid; |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1792 | |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1793 | rid = session->next_rid++; |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1794 | |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1795 | g_hash_table_insert(session->user_lookup_cb, GUINT_TO_POINTER(rid), cb); |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1796 | g_hash_table_insert(session->user_lookup_cb_data, GUINT_TO_POINTER(rid), data); |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1797 | |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1798 | return rid; |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1799 | } |
|
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1800 | |
| 16322 | 1801 | /** |
| 1802 | * Callback when connected. Sets up input handlers. | |
| 1803 | * | |
| 16324 | 1804 | * @param data A PurpleConnection pointer. |
| 16322 | 1805 | * @param source File descriptor. |
| 1806 | * @param error_message | |
| 1807 | */ | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
1808 | void msim_connect_cb(gpointer data, gint source, const gchar *error_message) |
| 16322 | 1809 | { |
| 16324 | 1810 | PurpleConnection *gc; |
| 16322 | 1811 | MsimSession *session; |
| 1812 | ||
| 1813 | g_return_if_fail(data != NULL); | |
| 1814 | ||
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
1815 | gc = (PurpleConnection *)data; |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1816 | session = (MsimSession *)gc->proto_data; |
| 16322 | 1817 | |
| 1818 | if (source < 0) | |
| 1819 | { | |
|
17895
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
1820 | purple_connection_error(gc, _("Couldn't connect to host")); |
|
6c2facc6c33b
Use _ for translations in msimprpl. See #648.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17894
diff
changeset
|
1821 | purple_connection_error(gc, g_strdup_printf(_("Couldn't connect to host: %s (%d)"), |
| 16322 | 1822 | error_message, source)); |
| 1823 | return; | |
| 1824 | } | |
| 1825 | ||
| 1826 | session->fd = source; | |
| 1827 | ||
| 16324 | 1828 | gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc); |
| 16322 | 1829 | } |
| 1830 | ||
| 1831 | /* Session methods */ | |
| 1832 | ||
| 1833 | /** | |
| 1834 | * Create a new MSIM session. | |
| 1835 | * | |
| 1836 | * @param acct The account to create the session from. | |
| 1837 | * | |
| 1838 | * @return Pointer to a new session. Free with msim_session_destroy. | |
| 1839 | */ | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
1840 | MsimSession *msim_session_new(PurpleAccount *acct) |
| 16322 | 1841 | { |
| 1842 | MsimSession *session; | |
| 1843 | ||
| 1844 | g_return_val_if_fail(acct != NULL, NULL); | |
| 1845 | ||
| 1846 | session = g_new0(MsimSession, 1); | |
| 1847 | ||
| 1848 | session->magic = MSIM_SESSION_STRUCT_MAGIC; | |
| 1849 | session->account = acct; | |
| 16324 | 1850 | session->gc = purple_account_get_connection(acct); |
| 16322 | 1851 | session->fd = -1; |
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1852 | |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1853 | /* TODO: Remove. */ |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
1854 | session->user_lookup_cb = g_hash_table_new_full(g_direct_hash, |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1855 | g_direct_equal, NULL, NULL); /* do NOT free function pointers! (values) */ |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
1856 | session->user_lookup_cb_data = g_hash_table_new_full(g_direct_hash, |
|
17947
a423b14fda56
Change msim_send_im_by_userid_cb() to msim_send_im_cb(), and remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17944
diff
changeset
|
1857 | g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are, |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1858 | they could be integers inside gpointers |
|
17947
a423b14fda56
Change msim_send_im_by_userid_cb() to msim_send_im_cb(), and remove
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17944
diff
changeset
|
1859 | or strings, so I don't freed them. |
|
17924
191c78db42ae
Use MsimMessage for receiving messages everywhere, instead of GHashTable.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17910
diff
changeset
|
1860 | Figure this out, once free cache. */ |
| 16322 | 1861 | session->rxoff = 0; |
| 1862 | session->rxbuf = g_new0(gchar, MSIM_READ_BUF_SIZE); | |
|
16335
0c2b32acc27a
Replace printf() in MySpaceIM prpl with purple_debug_info().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16334
diff
changeset
|
1863 | session->next_rid = 1; |
| 16322 | 1864 | |
| 1865 | return session; | |
| 1866 | } | |
| 1867 | ||
| 1868 | /** | |
| 1869 | * Free a session. | |
| 1870 | * | |
| 1871 | * @param session The session to destroy. | |
| 1872 | */ | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
1873 | void msim_session_destroy(MsimSession *session) |
| 16322 | 1874 | { |
| 1875 | g_return_if_fail(MSIM_SESSION_VALID(session)); | |
| 1876 | ||
| 1877 | session->magic = -1; | |
| 1878 | ||
| 1879 | g_free(session->rxbuf); | |
| 1880 | ||
|
17957
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1881 | /* TODO: Remove. */ |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1882 | g_hash_table_destroy(session->user_lookup_cb); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1883 | g_hash_table_destroy(session->user_lookup_cb_data); |
|
bc5874ed7a09
Add msim_uid2username_from_blist() to lookup a username by userid, by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17956
diff
changeset
|
1884 | |
| 16322 | 1885 | g_free(session); |
| 1886 | } | |
|
16333
0fdea8ad21cb
Add MySpaceIM header file and reorganize functions.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16332
diff
changeset
|
1887 | |
| 16322 | 1888 | |
| 1889 | ||
| 1890 | /** | |
| 1891 | * Close the connection. | |
| 1892 | * | |
| 1893 | * @param gc The connection. | |
| 1894 | */ | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
1895 | void msim_close(PurpleConnection *gc) |
| 16322 | 1896 | { |
|
17958
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1897 | MsimSession *session; |
|
17937
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1898 | |
|
0f30d74fcd9c
Add incomplete msim_add_buddy() implementation.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17935
diff
changeset
|
1899 | purple_debug_info("msim", "msim_close: destroying session\n"); |
|
17958
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1900 | |
|
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1901 | session = (MsimSession *)gc->proto_data; |
|
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1902 | |
|
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1903 | g_return_if_fail(gc != NULL); |
|
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1904 | g_return_if_fail(session != NULL); |
|
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1905 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1906 | |
|
17973
11491f81a0aa
Fix crash when re-logging in.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17970
diff
changeset
|
1907 | purple_input_remove(session->gc->inpa); |
|
17958
9f809365230b
Add TODO in order to fix msim_tooltip_text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17957
diff
changeset
|
1908 | msim_session_destroy(session); |
| 16322 | 1909 | } |
| 1910 | ||
| 1911 | ||
| 1912 | /** | |
| 1913 | * Check if a string is a userid (all numeric). | |
| 1914 | * | |
| 1915 | * @param user The user id, email, or name. | |
| 1916 | * | |
| 1917 | * @return TRUE if is userid, FALSE if not. | |
| 1918 | */ | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
1919 | gboolean msim_is_userid(const gchar *user) |
| 16322 | 1920 | { |
| 1921 | g_return_val_if_fail(user != NULL, FALSE); | |
| 1922 | ||
| 1923 | return strspn(user, "0123456789") == strlen(user); | |
| 1924 | } | |
| 1925 | ||
| 1926 | /** | |
| 1927 | * Check if a string is an email address (contains an @). | |
| 1928 | * | |
| 1929 | * @param user The user id, email, or name. | |
| 1930 | * | |
| 1931 | * @return TRUE if is an email, FALSE if not. | |
| 1932 | * | |
| 1933 | * This function is not intended to be used as a generic | |
| 1934 | * means of validating email addresses, but to distinguish | |
| 1935 | * between a user represented by an email address from | |
| 1936 | * other forms of identification. | |
| 1937 | */ | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
1938 | gboolean msim_is_email(const gchar *user) |
| 16322 | 1939 | { |
| 1940 | g_return_val_if_fail(user != NULL, FALSE); | |
| 1941 | ||
| 1942 | return strchr(user, '@') != NULL; | |
| 1943 | } | |
| 1944 | ||
| 1945 | ||
| 1946 | /** | |
| 1947 | * Asynchronously lookup user information, calling callback when receive result. | |
| 1948 | * | |
| 1949 | * @param session | |
| 1950 | * @param user The user id, email address, or username. | |
| 1951 | * @param cb Callback, called with user information when available. | |
| 1952 | * @param data An arbitray data pointer passed to the callback. | |
| 1953 | */ | |
|
17943
d33c1657f68b
Add TODOs about username/email->userid resolution, use g_return_if_fail() in a few places.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17942
diff
changeset
|
1954 | /* TODO: change to not use callbacks */ |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
1955 | void msim_lookup_user(MsimSession *session, const gchar *user, MSIM_USER_LOOKUP_CB cb, gpointer data) |
| 16322 | 1956 | { |
| 1957 | gchar *field_name; | |
| 1958 | guint rid, cmd, dsn, lid; | |
| 1959 | ||
| 1960 | g_return_if_fail(MSIM_SESSION_VALID(session)); | |
| 1961 | g_return_if_fail(user != NULL); | |
| 1962 | g_return_if_fail(cb != NULL); | |
| 1963 | ||
|
17910
9bbfa75ba90b
(Incomplete - plugin does not load) Begin migrating protocol message receiving to MsimMessage.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17906
diff
changeset
|
1964 | purple_debug_info("msim", "msim_lookup_userid: " |
|
16332
f0e987f024e0
Use g_convert for UTF-16LE conversion instead of converting manually.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16330
diff
changeset
|
1965 | "asynchronously looking up <%s>\n", user); |
| 16322 | 1966 | |
|
17956
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1967 | msim_msg_dump("msim_lookup_user: data=%s\n", (MsimMessage *)data); |
|
0b3393767f6d
Use msim_postprocess_outgoing() to resolve uid for adding and deleting buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17955
diff
changeset
|
1968 | |
| 16322 | 1969 | /* TODO: check if this user's info was cached and fresh; if so return immediately */ |
| 1970 | #if 0 | |
| 1971 | /* If already know userid, then call callback immediately */ | |
| 1972 | cached_userid = g_hash_table_lookup(session->userid_cache, who); | |
| 1973 | if (cached_userid && !by_userid) | |
| 1974 | { | |
| 1975 | cb(cached_userid, NULL, NULL, data); | |
| 1976 | return; | |
| 1977 | } | |
| 1978 | #endif | |
| 1979 | ||
| 1980 | /* Setup callback. Response will be associated with request using 'rid'. */ | |
|
17960
0c7d41bbf8d7
Several small changes to work towards a working msim_remove_buddy():
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17959
diff
changeset
|
1981 | rid = msim_new_reply_callback(session, cb, data); |
| 16322 | 1982 | |
| 1983 | /* Send request */ | |
| 1984 | ||
|
17930
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
1985 | cmd = MSIM_CMD_GET; |
| 16322 | 1986 | |
| 1987 | if (msim_is_userid(user)) | |
| 1988 | { | |
| 1989 | field_name = "UserID"; | |
|
17930
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
1990 | dsn = MG_MYSPACE_INFO_BY_ID_DSN; |
|
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
1991 | lid = MG_MYSPACE_INFO_BY_ID_LID; |
| 16322 | 1992 | } else if (msim_is_email(user)) { |
| 1993 | field_name = "Email"; | |
|
17930
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
1994 | dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
|
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
1995 | lid = MG_MYSPACE_INFO_BY_STRING_LID; |
| 16322 | 1996 | } else { |
| 1997 | field_name = "UserName"; | |
|
17930
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
1998 | dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
|
d8908611bf64
Use symbolic constants for persist messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17929
diff
changeset
|
1999 | lid = MG_MYSPACE_INFO_BY_STRING_LID; |
| 16322 | 2000 | } |
| 2001 | ||
| 2002 | ||
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
2003 | g_return_if_fail(msim_send(session, |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2004 | "persist", MSIM_TYPE_INTEGER, 1, |
|
17941
cdc104d92cdf
Change MsimSession.sesskey to an integer (used to be a string), now that
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17940
diff
changeset
|
2005 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2006 | "cmd", MSIM_TYPE_INTEGER, 1, |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2007 | "dsn", MSIM_TYPE_INTEGER, dsn, |
|
17961
16c5545a0a95
Remove msim_get_own_uid{,_cb}() - it is not needed, since the login
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17960
diff
changeset
|
2008 | "uid", MSIM_TYPE_INTEGER, session->userid, |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2009 | "lid", MSIM_TYPE_INTEGER, lid, |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2010 | "rid", MSIM_TYPE_INTEGER, rid, |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2011 | /* TODO: dictionary field type */ |
|
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2012 | "body", MSIM_TYPE_STRING, g_strdup_printf("%s=%s", field_name, user), |
|
17935
a6a70c7213ab
Previously, the return value of the processing function and msim_process() told
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17934
diff
changeset
|
2013 | NULL)); |
| 16322 | 2014 | } |
| 2015 | ||
| 2016 | ||
| 2017 | /** | |
| 2018 | * Obtain the status text for a buddy. | |
| 2019 | * | |
| 2020 | * @param buddy The buddy to obtain status text for. | |
| 2021 | * | |
|
17970
3c92ce43ddae
Change to use const gchar * where appropriate.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17969
diff
changeset
|
2022 | * @return Status text, or NULL if error. Caller g_free()'s. |
| 16322 | 2023 | * |
| 2024 | */ | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2025 | char *msim_status_text(PurpleBuddy *buddy) |
| 16322 | 2026 | { |
| 2027 | MsimSession *session; | |
|
17976
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2028 | const gchar *display_name, *headline; |
| 16322 | 2029 | |
| 2030 | g_return_val_if_fail(buddy != NULL, NULL); | |
| 2031 | ||
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
2032 | session = (MsimSession *)buddy->account->gc->proto_data; |
|
17894
e9d07c821d6f
Use g_return_if_fail() instead of g_assert(), as to not crash the whole program.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17893
diff
changeset
|
2033 | g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL); |
| 16322 | 2034 | |
|
17976
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2035 | display_name = headline = NULL; |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2036 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2037 | /* Retrieve display name and/or headline, depending on user preference. */ |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2038 | if (purple_account_get_bool(session->account, "show_display_name", TRUE)) |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2039 | { |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2040 | display_name = purple_blist_node_get_string(&buddy->node, "DisplayName"); |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2041 | } |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2042 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2043 | if (purple_account_get_bool(session->account, "show_headline", FALSE)) |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2044 | { |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2045 | headline = purple_blist_node_get_string(&buddy->node, "Headline"); |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2046 | } |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2047 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2048 | /* Return appropriate combination of display name and/or headline, or neither. */ |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2049 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2050 | if (display_name && headline) |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2051 | return g_strconcat(display_name, " ", headline, NULL); |
| 16322 | 2052 | |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2053 | if (display_name) |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2054 | return g_strdup(display_name); |
|
17976
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2055 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2056 | if (headline) |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2057 | return g_strdup(headline); |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2058 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2059 | return NULL; |
| 16322 | 2060 | } |
| 2061 | ||
| 2062 | /** | |
| 2063 | * Obtain the tooltip text for a buddy. | |
| 2064 | * | |
| 2065 | * @param buddy Buddy to obtain tooltip text on. | |
| 2066 | * @param user_info Variable modified to have the tooltip text. | |
| 2067 | * @param full TRUE if should obtain full tooltip text. | |
| 2068 | * | |
| 2069 | */ | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2070 | void msim_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full) |
| 16322 | 2071 | { |
| 2072 | g_return_if_fail(buddy != NULL); | |
| 2073 | g_return_if_fail(user_info != NULL); | |
| 2074 | ||
| 16324 | 2075 | if (PURPLE_BUDDY_IS_ONLINE(buddy)) |
| 16322 | 2076 | { |
| 2077 | MsimSession *session; | |
| 2078 | ||
|
17906
f87472f223aa
Stylistic improvements - use type *name instead of type* name for pointers
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17903
diff
changeset
|
2079 | session = (MsimSession *)buddy->account->gc->proto_data; |
| 16322 | 2080 | |
|
17894
e9d07c821d6f
Use g_return_if_fail() instead of g_assert(), as to not crash the whole program.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17893
diff
changeset
|
2081 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
| 16322 | 2082 | |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2083 | /* TODO: if (full), do something different */ |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2084 | |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2085 | /* TODO: move to buddy profile |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2086 | purple_notify_user_info_add_pair(user_info, "User ID", |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2087 | g_strdup_printf("%d", purple_blist_node_get_int(&buddy->node, "UserID"))); |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2088 | */ |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2089 | |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2090 | /* Already shown in status text. |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2091 | purple_notify_user_info_add_pair(user_info, "Display Name", |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2092 | purple_blist_node_get_string(&buddy->node, "DisplayName")); */ |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2093 | |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2094 | /* Useful to identify the account the tooltip refers to. Other prpls show this. */ |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2095 | purple_notify_user_info_add_pair(user_info, "Account", |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2096 | purple_blist_node_get_string(&buddy->node, "UserName")); |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2097 | |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2098 | |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2099 | /* a/s/l...the vitals */ |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2100 | purple_notify_user_info_add_pair(user_info, "Age", |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2101 | g_strdup_printf("%d", purple_blist_node_get_int(&buddy->node, "Age"))); |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2102 | |
|
17967
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2103 | purple_notify_user_info_add_pair(user_info, "Gender", |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2104 | purple_blist_node_get_string(&buddy->node, "Gender")); |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2105 | |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2106 | purple_notify_user_info_add_pair(user_info, "Location", |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2107 | purple_blist_node_get_string(&buddy->node, "Location")); |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2108 | |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2109 | /* Other information */ |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2110 | if (purple_blist_node_get_string(&buddy->node, "Headline")) |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2111 | purple_notify_user_info_add_pair(user_info, "Headline", |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2112 | purple_blist_node_get_string(&buddy->node, "Headline")); |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2113 | |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2114 | purple_notify_user_info_add_pair(user_info, "Song", |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2115 | g_strdup_printf("%s - %s", |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2116 | purple_blist_node_get_string(&buddy->node, "BandName"), |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2117 | purple_blist_node_get_string(&buddy->node, "SongName"))); |
|
a16d7668ab43
Reorganize the tooltip text, to show more useful information.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17966
diff
changeset
|
2118 | |
|
17966
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2119 | purple_notify_user_info_add_pair(user_info, "Total Friends", |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2120 | g_strdup_printf("%d", purple_blist_node_get_int(&buddy->node, "TotalFriends"))); |
|
e2bdcbb55218
Show buddy information in tooltip text, and the display name for status text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17964
diff
changeset
|
2121 | |
| 16322 | 2122 | } |
| 2123 | } | |
| 2124 | ||
| 16324 | 2125 | /** Callbacks called by Purple, to access this plugin. */ |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2126 | PurplePluginProtocolInfo prpl_info = |
| 16322 | 2127 | { |
| 2128 | OPT_PROTO_MAIL_CHECK,/* options - TODO: myspace will notify of mail */ | |
| 2129 | NULL, /* user_splits */ | |
| 2130 | NULL, /* protocol_options */ | |
| 2131 | NO_BUDDY_ICONS, /* icon_spec - TODO: eventually should add this */ | |
| 2132 | msim_list_icon, /* list_icon */ | |
| 2133 | NULL, /* list_emblems */ | |
| 2134 | msim_status_text, /* status_text */ | |
| 2135 | msim_tooltip_text, /* tooltip_text */ | |
| 2136 | msim_status_types, /* status_types */ | |
| 2137 | NULL, /* blist_node_menu */ | |
| 2138 | NULL, /* chat_info */ | |
| 2139 | NULL, /* chat_info_defaults */ | |
| 2140 | msim_login, /* login */ | |
| 2141 | msim_close, /* close */ | |
| 2142 | msim_send_im, /* send_im */ | |
| 2143 | NULL, /* set_info */ | |
|
17934
d163dde3aff1
Add, but do not use, incomplete functions for using typing notifications.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17933
diff
changeset
|
2144 | msim_send_typing, /* send_typing */ |
|
17969
9a043ea6bc44
Implement msim_get_info() for users on the user's buddy list.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17968
diff
changeset
|
2145 | msim_get_info, /* get_info */ |
| 16322 | 2146 | NULL, /* set_away */ |
| 2147 | NULL, /* set_idle */ | |
| 2148 | NULL, /* change_passwd */ | |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2149 | msim_add_buddy, /* add_buddy */ |
| 16322 | 2150 | NULL, /* add_buddies */ |
|
17940
46246b04b219
Add (incomplete) msim_remove_buddy().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17937
diff
changeset
|
2151 | msim_remove_buddy, /* remove_buddy */ |
| 16322 | 2152 | NULL, /* remove_buddies */ |
| 2153 | NULL, /* add_permit */ | |
| 2154 | NULL, /* add_deny */ | |
| 2155 | NULL, /* rem_permit */ | |
| 2156 | NULL, /* rem_deny */ | |
| 2157 | NULL, /* set_permit_deny */ | |
| 2158 | NULL, /* join_chat */ | |
| 2159 | NULL, /* reject chat invite */ | |
| 2160 | NULL, /* get_chat_name */ | |
| 2161 | NULL, /* chat_invite */ | |
| 2162 | NULL, /* chat_leave */ | |
| 2163 | NULL, /* chat_whisper */ | |
| 2164 | NULL, /* chat_send */ | |
| 2165 | NULL, /* keepalive */ | |
| 2166 | NULL, /* register_user */ | |
| 2167 | NULL, /* get_cb_info */ | |
| 2168 | NULL, /* get_cb_away */ | |
| 2169 | NULL, /* alias_buddy */ | |
| 2170 | NULL, /* group_buddy */ | |
| 2171 | NULL, /* rename_group */ | |
| 2172 | NULL, /* buddy_free */ | |
| 2173 | NULL, /* convo_closed */ | |
| 2174 | NULL, /* normalize */ | |
| 2175 | NULL, /* set_buddy_icon */ | |
| 2176 | NULL, /* remove_group */ | |
| 2177 | NULL, /* get_cb_real_name */ | |
| 2178 | NULL, /* set_chat_topic */ | |
| 2179 | NULL, /* find_blist_chat */ | |
| 2180 | NULL, /* roomlist_get_list */ | |
| 2181 | NULL, /* roomlist_cancel */ | |
| 2182 | NULL, /* roomlist_expand_category */ | |
| 2183 | NULL, /* can_receive_file */ | |
| 2184 | NULL, /* send_file */ | |
| 2185 | NULL, /* new_xfer */ | |
|
17968
c29352b95fa6
Add msim_offline_message() for offline message status. Always return TRUE,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17967
diff
changeset
|
2186 | msim_offline_message, /* offline_message */ |
| 16322 | 2187 | NULL, /* whiteboard_prpl_ops */ |
| 2188 | NULL, /* send_raw */ | |
|
17890
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2189 | NULL, /* roomlist_room_serialize */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2190 | NULL, /* _purple_reserved1 */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2191 | NULL, /* _purple_reserved2 */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2192 | NULL, /* _purple_reserved3 */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2193 | NULL /* _purple_reserved4 */ |
| 16322 | 2194 | }; |
| 2195 | ||
| 2196 | ||
| 2197 | ||
| 2198 | /** Based on MSN's plugin info comments. */ | |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2199 | PurplePluginInfo info = |
| 16322 | 2200 | { |
| 16324 | 2201 | PURPLE_PLUGIN_MAGIC, |
| 2202 | PURPLE_MAJOR_VERSION, | |
| 2203 | PURPLE_MINOR_VERSION, | |
|
17933
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
2204 | PURPLE_PLUGIN_PROTOCOL, /**< type */ |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
2205 | NULL, /**< ui_requirement */ |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
2206 | 0, /**< flags */ |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
2207 | NULL, /**< dependencies */ |
|
03228b5c78b5
Show online buddies on buddy list as online.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17931
diff
changeset
|
2208 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 16322 | 2209 | |
| 2210 | "prpl-myspace", /**< id */ | |
| 2211 | "MySpaceIM", /**< name */ | |
|
17980
a455980c81a8
Add script to produce tarballs and zip archives for releases, for v0.8.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17976
diff
changeset
|
2212 | "0.8", /**< version */ |
| 16322 | 2213 | /** summary */ |
| 2214 | "MySpaceIM Protocol Plugin", | |
| 2215 | /** description */ | |
| 2216 | "MySpaceIM Protocol Plugin", | |
| 2217 | "Jeff Connelly <myspaceim@xyzzy.cjb.net>", /**< author */ | |
| 2218 | "http://developer.pidgin.im/wiki/MySpaceIM/", /**< homepage */ | |
| 2219 | ||
|
17893
308a27332b57
Check for RC4 in libpurple on plugin initialization.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17892
diff
changeset
|
2220 | msim_load, /**< load */ |
| 16322 | 2221 | NULL, /**< unload */ |
| 2222 | NULL, /**< destroy */ | |
| 2223 | NULL, /**< ui_info */ | |
| 2224 | &prpl_info, /**< extra_info */ | |
| 2225 | NULL, /**< prefs_info */ | |
| 2226 | ||
| 2227 | /* msim_actions */ | |
|
17890
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2228 | NULL, |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2229 | |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2230 | NULL, /**< reserved1 */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2231 | NULL, /**< reserved2 */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2232 | NULL, /**< reserved3 */ |
|
6926ed504a9a
Add initializers for reserved fields in plugin and prpl structures.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
16337
diff
changeset
|
2233 | NULL /**< reserved4 */ |
| 16322 | 2234 | }; |
| 2235 | ||
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2236 | |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
2237 | #ifdef MSIM_SELF_TEST |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2238 | /** Test functions. |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2239 | * Used to test or try out the internal workings of msimprpl. If you're reading |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2240 | * this code for the first time, these functions can be instructive in how |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2241 | * msimprpl is architected. |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2242 | */ |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
2243 | void msim_test_all(void) __attribute__((__noreturn__())); |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2244 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2245 | guint failures; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2246 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2247 | failures = 0; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2248 | failures += msim_test_msg(); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2249 | failures += msim_test_escaping(); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2250 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2251 | if (failures) |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2252 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2253 | purple_debug_info("msim", "msim_test_all HAD FAILURES: %d\n", failures); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2254 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2255 | else |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2256 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2257 | purple_debug_info("msim", "msim_test_all - all tests passed!\n"); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2258 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2259 | exit(0); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2260 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2261 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2262 | /** Test MsimMessage for basic functionality. */ |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2263 | int msim_test_msg(void) |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2264 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2265 | MsimMessage *msg, *msg_cloned; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2266 | gchar *packed, *packed_expected, *packed_cloned; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2267 | guint failures; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2268 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2269 | failures = 0; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2270 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2271 | purple_debug_info("msim", "\n\nTesting MsimMessage\n"); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2272 | msg = msim_msg_new(FALSE); /* Create a new, empty message. */ |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2273 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2274 | /* Append some new elements. */ |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2275 | msg = msim_msg_append(msg, "bx", MSIM_TYPE_BINARY, g_string_new_len(g_strdup("XXX"), 3)); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2276 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v1")); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2277 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(42)); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2278 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v43")); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2279 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v52/xxx\\yyy")); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2280 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v7")); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2281 | msim_msg_dump("msg debug str=%s\n", msg); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2282 | packed = msim_msg_pack(msg); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2283 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2284 | purple_debug_info("msim", "msg packed=%s\n", packed); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2285 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2286 | packed_expected = "\\bx\\WFhY\\k1\\v1\\k1\\42\\k1" |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2287 | "\\v43\\k1\\v52/1xxx/2yyy\\k1\\v7\\final\\"; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2288 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2289 | if (0 != strcmp(packed, packed_expected)) |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2290 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2291 | purple_debug_info("msim", "!!!(%d), msim_msg_pack not what expected: %s != %s\n", |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2292 | ++failures, packed, packed_expected); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2293 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2294 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2295 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2296 | msg_cloned = msim_msg_clone(msg); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2297 | packed_cloned = msim_msg_pack(msg_cloned); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2298 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2299 | purple_debug_info("msim", "msg cloned=%s\n", packed_cloned); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2300 | if (0 != strcmp(packed, packed_cloned)) |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2301 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2302 | purple_debug_info("msim", "!!!(%d), msim_msg_pack on cloned message not equal to original: %s != %s\n", |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2303 | ++failures, packed_cloned, packed); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2304 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2305 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2306 | g_free(packed); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2307 | g_free(packed_cloned); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2308 | msim_msg_free(msg_cloned); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2309 | msim_msg_free(msg); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2310 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2311 | return failures; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2312 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2313 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2314 | /** Test protocol-level escaping/unescaping. */ |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2315 | int msim_test_escaping(void) |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2316 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2317 | guint failures; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2318 | gchar *raw, *escaped, *unescaped, *expected; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2319 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2320 | failures = 0; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2321 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2322 | purple_debug_info("msim", "\n\nTesting escaping\n"); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2323 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2324 | raw = "hello/world\\hello/world"; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2325 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2326 | escaped = msim_escape(raw); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2327 | purple_debug_info("msim", "msim_test_escaping: raw=%s, escaped=%s\n", raw, escaped); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2328 | expected = "hello/1world/2hello/1world"; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2329 | if (0 != strcmp(escaped, expected)) |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2330 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2331 | purple_debug_info("msim", "!!!(%d), msim_escape failed: %s != %s\n", |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2332 | ++failures, escaped, expected); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2333 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2334 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2335 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2336 | unescaped = msim_unescape(escaped); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2337 | g_free(escaped); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2338 | purple_debug_info("msim", "msim_test_escaping: unescaped=%s\n", unescaped); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2339 | if (0 != strcmp(raw, unescaped)) |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2340 | { |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2341 | purple_debug_info("msim", "!!!(%d), msim_unescape failed: %s != %s\n", |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2342 | ++failures, raw, unescaped); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2343 | } |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2344 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2345 | return failures; |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2346 | } |
|
17984
9a53a8583bba
Add msim_unrecognized() to handle unhandled messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17983
diff
changeset
|
2347 | #endif |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2348 | |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2349 | /** Initialize plugin. */ |
|
17903
1c344d9266b8
Use MsimMessage via msim_send(), instead of msim_send_raw(). This is a more
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17902
diff
changeset
|
2350 | void init_plugin(PurplePlugin *plugin) |
|
17900
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2351 | { |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2352 | PurpleAccountOption *option; |
|
17981
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2353 | #ifdef MSIM_SELF_TEST |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2354 | msim_test_all(); |
|
2e330f731690
Add msim_test_all() and related procedures, to perform basic functionality
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17980
diff
changeset
|
2355 | #endif /* MSIM_SELF_TEST */ |
|
17900
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2356 | |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2357 | /* TODO: default to automatically try different ports. Make the user be |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2358 | * able to set the first port to try (like LastConnectedPort in Windows client). */ |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2359 | option = purple_account_option_string_new(_("Connect server"), "server", MSIM_SERVER); |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2360 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2361 | |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2362 | option = purple_account_option_int_new(_("Connect port"), "port", MSIM_PORT); |
|
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2363 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
17976
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2364 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2365 | option = purple_account_option_bool_new(_("Show display name in status text"), "show_display_name", TRUE); |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2366 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2367 | |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2368 | option = purple_account_option_bool_new(_("Show headline in status text"), "show_headline", TRUE); |
|
4fe92c2fa5af
Add two boolean options to account dialog, to allow displaying of
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17975
diff
changeset
|
2369 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
17900
402fdc925e30
Clean up a few TODO's.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
17898
diff
changeset
|
2370 | } |
| 16322 | 2371 | |
| 16324 | 2372 | PURPLE_INIT_PLUGIN(myspace, init_plugin, info); |