Tue, 07 Aug 2007 03:06:43 +0000
Use a list when updating the blocklist when removing the buddy, since
msim_postprocess_outgoing() can now replace uids in MSIM_TYPE_LISTs.
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1 | /* MySpaceIM Protocol Plugin |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3 | * \author Jeff Connelly |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
4 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
5 | * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im> |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
6 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
7 | * Based on Purple's "C Plugin HOWTO" hello world example. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
8 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
9 | * Code also drawn from mockprpl: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
10 | * http://snarfed.org/space/purple+mock+protocol+plugin |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
11 | * Copyright (C) 2004-2007, Ryan Barrett <mockprpl@ryanb.org> |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
12 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
13 | * and some constructs also based on existing Purple plugins, which are: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
14 | * Copyright (C) 2003, Robbert Haarman <purple@inglorion.net> |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
15 | * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
16 | * Copyright (C) 2000-2003, Rob Flynn <rob@tgflinux.com> |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
17 | * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
18 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
19 | * This program is free software; you can redistribute it and/or modify |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
20 | * it under the terms of the GNU General Public License as published by |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
21 | * the Free Software Foundation; either version 2 of the License, or |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
22 | * (at your option) any later version. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
23 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
24 | * This program is distributed in the hope that it will be useful, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
27 | * GNU General Public License for more details. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
28 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
29 | * You should have received a copy of the GNU General Public License |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
30 | * along with this program; if not, write to the Free Software |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
31 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
32 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
33 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
34 | #define PURPLE_PLUGIN |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
35 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
36 | #include "message.h" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
37 | #include "persist.h" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
38 | #include "myspace.h" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
39 | |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
40 | |
|
18050
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
41 | /* Loosely based on Miranda plugin by Scott Ellis, formatting.cpp, |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
42 | * https://server.scottellis.com.au/websvn/filedetails.php?repname=Miranda+Plugins&path=%2FMySpace%2Fformatting.cpp&rev=0&sc=0 */ |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
43 | |
|
18050
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
44 | /* The names in in emoticon_names (for <i n=whatever>) map to corresponding |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
45 | * entries in emoticon_symbols (for the ASCII representation of the emoticon). |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
46 | */ |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
47 | static const char *emoticon_names[] = { |
|
18050
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
48 | "bigsmile", "growl", "growl", "mad", "scared", "scared", "tongue", "tongue", |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
49 | "devil", "devil", "happy", "happy", "happi", |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
50 | "messed", "sidefrown", "upset", |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
51 | "frazzled", "heart", "heart", "nerd", "sinister", "wink", "winc", |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
52 | "geek", "laugh", "laugh", "oops", "smirk", "worried", "worried", |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
53 | "googles", "mohawk", "pirate", "straight", "kiss", |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
54 | NULL}; |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
55 | |
|
18050
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
56 | /* Multiple emoticon symbols in Pidgin can map to one name. List the |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
57 | * canonical form, as inserted by the "Smile!" dialog, first. For example, |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
58 | * :) comes before :-), because although both are recognized as 'happy', |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
59 | * the first is inserted by the smiley button. |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
60 | * |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
61 | * Note that symbols are case-sensitive in Pidgin -- :-X is not :-x. */ |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
62 | static const char *emoticon_symbols[] = { |
|
18050
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
63 | ":D", ">:o", ">:O", ":-[", "=-O", "=-o", ":P", ":p", |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
64 | "O:-)", "o:-)", ":)", ":-)", ":-)", |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
65 | "8-)", ":-$", ":-$", |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
66 | ":-/", ";-)", ";)", "8-)" /*:)*/, ":-D", ";-)", ";-)", |
|
3ac6d13d25cd
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18049
diff
changeset
|
67 | ":-X", ":-D", ":-d", ":'(", "8-)", ":-(", ":(", |
|
18049
134389a07f86
Fix emoticon symbols to match those generated by Pidgin.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18048
diff
changeset
|
68 | "8-)", ":-X", ":-)", ":-!", ":-*", |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
69 | NULL}; |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
70 | |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
71 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
72 | /* Internal functions */ |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
73 | static void msim_send_zap(PurpleBlistNode *node, gpointer zap_num_ptr); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
74 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
75 | #ifdef MSIM_DEBUG_MSG |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
76 | static void print_hash_item(gpointer key, gpointer value, gpointer user_data); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
77 | #endif |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
78 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
79 | static int msim_send_really_raw(PurpleConnection *gc, const char *buf, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
80 | int total_bytes); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
81 | static gboolean msim_login_challenge(MsimSession *session, MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
82 | static const gchar *msim_compute_login_response( |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
83 | const gchar nonce[2 * NONCE_SIZE], const gchar *email, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
84 | const gchar *password, guint *response_len); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
85 | static gboolean msim_send_bm(MsimSession *session, const gchar *who, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
86 | const gchar *text, int type); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
87 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
88 | static guint msim_point_to_purple_size(MsimSession *session, guint point); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
89 | static guint msim_purple_size_to_point(MsimSession *session, guint size); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
90 | static guint msim_height_to_point(MsimSession *session, guint height); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
91 | static guint msim_point_to_height(MsimSession *session, guint point); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
92 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
93 | static void msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
94 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
95 | static void msim_markup_tag_to_html(MsimSession *, xmlnode *root, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
96 | gchar **begin, gchar **end); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
97 | static void html_tag_to_msim_markup(MsimSession *, xmlnode *root, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
98 | gchar **begin, gchar **end); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
99 | static gchar *msim_convert_xml(MsimSession *, const gchar *raw, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
100 | MSIM_XMLNODE_CONVERT f); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
101 | static gchar *msim_convert_smileys_to_markup(gchar *before); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
102 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
103 | /* High-level msim markup <=> html conversion functions. */ |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
104 | static gchar *msim_markup_to_html(MsimSession *, const gchar *raw); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
105 | static gchar *html_to_msim_markup(MsimSession *, const gchar *raw); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
106 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
107 | static gboolean msim_incoming_bm_record_cv(MsimSession *session, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
108 | MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
109 | static gboolean msim_incoming_bm(MsimSession *session, MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
110 | static gboolean msim_incoming_status(MsimSession *session, MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
111 | static gboolean msim_incoming_im(MsimSession *session, MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
112 | static gboolean msim_incoming_zap(MsimSession *session, MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
113 | static gboolean msim_incoming_action(MsimSession *session, MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
114 | static gboolean msim_incoming_media(MsimSession *session, MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
115 | static gboolean msim_incoming_unofficial_client(MsimSession *session, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
116 | MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
117 | |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
118 | #ifdef MSIM_SEND_CLIENT_VERSION |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
119 | static gboolean msim_send_unofficial_client(MsimSession *session, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
120 | gchar *username); |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
121 | #endif |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
122 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
123 | static void msim_get_info_cb(MsimSession *session, MsimMessage *userinfo, gpointer data); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
124 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
125 | static void msim_set_status_code(MsimSession *session, guint code, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
126 | gchar *statstring); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
127 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
128 | static void msim_store_buddy_info_each(gpointer key, gpointer value, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
129 | gpointer user_data); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
130 | static gboolean msim_store_buddy_info(MsimSession *session, MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
131 | static gboolean msim_process_server_info(MsimSession *session, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
132 | MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
133 | static gboolean msim_web_challenge(MsimSession *session, MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
134 | static gboolean msim_process_reply(MsimSession *session, MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
135 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
136 | static gboolean msim_preprocess_incoming(MsimSession *session,MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
137 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
138 | #ifdef MSIM_USE_KEEPALIVE |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
139 | static gboolean msim_check_alive(gpointer data); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
140 | #endif |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
141 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
142 | static gboolean msim_we_are_logged_on(MsimSession *session, MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
143 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
144 | static gboolean msim_process(MsimSession *session, MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
145 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
146 | static MsimMessage *msim_do_postprocessing(MsimMessage *msg, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
147 | const gchar *uid_field_name, const gchar *uid_before, guint uid); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
148 | static void msim_postprocess_outgoing_cb(MsimSession *session, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
149 | MsimMessage *userinfo, gpointer data); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
150 | static gboolean msim_postprocess_outgoing(MsimSession *session, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
151 | MsimMessage *msg, const gchar *username, const gchar *uid_field_name, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
152 | const gchar *uid_before); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
153 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
154 | static gboolean msim_error(MsimSession *session, MsimMessage *msg); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
155 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
156 | static void msim_check_inbox_cb(MsimSession *session, MsimMessage *userinfo, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
157 | gpointer data); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
158 | static gboolean msim_check_inbox(gpointer data); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
159 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
160 | static void msim_input_cb(gpointer gc_uncasted, gint source, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
161 | PurpleInputCondition cond); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
162 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
163 | static guint msim_new_reply_callback(MsimSession *session, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
164 | MSIM_USER_LOOKUP_CB cb, gpointer data); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
165 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
166 | static void msim_connect_cb(gpointer data, gint source, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
167 | const gchar *error_message); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
168 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
169 | static gboolean msim_is_userid(const gchar *user); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
170 | static gboolean msim_is_email(const gchar *user); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
171 | |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
172 | static void msim_lookup_user(MsimSession *session, const gchar *user, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
173 | MSIM_USER_LOOKUP_CB cb, gpointer data); |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
174 | |
|
18061
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
175 | #ifndef round |
|
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
176 | double round(double round); |
|
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
177 | |
|
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
178 | /* round is part of C99, but sometimes is unavailable before then. |
|
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
179 | * Based on http://forums.belution.com/en/cpp/000/050/13.shtml |
|
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
180 | */ |
|
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
181 | double round(double value) |
|
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
182 | { |
|
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
183 | if (value < 0) |
|
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
184 | return -(floor(-value + 0.5)); |
|
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
185 | else |
|
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
186 | return floor( value + 0.5); |
|
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
187 | } |
|
76e936ec829e
Implement round() if it is not available, using floor().
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18059
diff
changeset
|
188 | #endif |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
189 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
190 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
191 | * Load the plugin. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
192 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
193 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
194 | msim_load(PurplePlugin *plugin) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
195 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
196 | /* If compiled to use RC4 from libpurple, check if it is really there. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
197 | if (!purple_ciphers_find_cipher("rc4")) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
198 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
199 | purple_debug_error("msim", "rc4 not in libpurple, but it is required - not loading MySpaceIM plugin!\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
200 | purple_notify_error(plugin, _("Missing Cipher"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
201 | _("The RC4 cipher could not be found"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
202 | _("Upgrade " |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
203 | "to a libpurple with RC4 support (>= 2.0.1). MySpaceIM " |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
204 | "plugin will not be loaded.")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
205 | return FALSE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
206 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
207 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
208 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
209 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
210 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
211 | * Get possible user status types. Based on mockprpl. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
212 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
213 | * @return GList of status types. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
214 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
215 | GList * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
216 | msim_status_types(PurpleAccount *acct) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
217 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
218 | GList *types; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
219 | PurpleStatusType *status; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
220 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
221 | purple_debug_info("myspace", "returning status types\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
222 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
223 | types = NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
224 | |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
225 | /* Statuses are almost all the same. Define a macro to reduce code repetition. */ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
226 | #define _MSIM_ADD_NEW_STATUS(prim) status = \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
227 | purple_status_type_new_with_attrs( \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
228 | prim, /* PurpleStatusPrimitive */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
229 | NULL, /* id - use default */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
230 | NULL, /* name - use default */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
231 | TRUE, /* savable */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
232 | TRUE, /* user_settable */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
233 | FALSE, /* not independent */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
234 | \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
235 | /* Attributes - each status can have a message. */ \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
236 | "message", \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
237 | _("Message"), \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
238 | purple_value_new(PURPLE_TYPE_STRING), \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
239 | NULL); \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
240 | \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
241 | \ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
242 | types = g_list_append(types, status) |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
243 | |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
244 | |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
245 | _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_AVAILABLE); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
246 | _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_AWAY); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
247 | _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_OFFLINE); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
248 | _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_INVISIBLE); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
249 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
250 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
251 | return types; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
252 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
253 | |
|
18053
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
254 | /** Zap someone. Callback from msim_blist_node_menu zap menu. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
255 | static void |
|
18053
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
256 | msim_send_zap(PurpleBlistNode *node, gpointer zap_num_ptr) |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
257 | { |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
258 | PurpleBuddy *buddy; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
259 | PurpleConnection *gc; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
260 | MsimSession *session; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
261 | gchar *username, *zap_string, *zap_text; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
262 | guint zap; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
263 | const gchar *zap_gerund[10]; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
264 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
265 | if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
266 | { |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
267 | /* Only know about buddies for now. */ |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
268 | return; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
269 | } |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
270 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
271 | zap_gerund[0] = _("Zapping"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
272 | zap_gerund[1] = _("Whacking"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
273 | zap_gerund[2] = _("Torching"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
274 | zap_gerund[3] = _("Smooching"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
275 | zap_gerund[4] = _("Hugging"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
276 | zap_gerund[5] = _("Bslapping"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
277 | zap_gerund[6] = _("Goosing"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
278 | zap_gerund[7] = _("Hi-fiving"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
279 | zap_gerund[8] = _("Punking"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
280 | zap_gerund[9] = _("Raspberry'ing"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
281 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
282 | g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
283 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
284 | buddy = (PurpleBuddy *)node; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
285 | gc = purple_account_get_connection(buddy->account); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
286 | g_return_if_fail(gc != NULL); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
287 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
288 | session = (MsimSession *)(gc->proto_data); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
289 | g_return_if_fail(session != NULL); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
290 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
291 | username = buddy->name; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
292 | g_return_if_fail(username != NULL); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
293 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
294 | zap = GPOINTER_TO_INT(zap_num_ptr); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
295 | zap_string = g_strdup_printf("!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", zap); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
296 | zap_text = g_strdup_printf("*** %s! ***", zap_gerund[zap]); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
297 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
298 | serv_got_im(session->gc, username, zap_text, |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
299 | PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
300 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
301 | if (!msim_send_bm(session, username, zap_string, MSIM_BM_ACTION)) |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
302 | { |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
303 | purple_debug_info("msim_send_zap", "msim_send_bm failed: zapping %s with %s", |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
304 | username, zap_string); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
305 | } |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
306 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
307 | g_free(zap_string); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
308 | g_free(zap_text); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
309 | return; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
310 | } |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
311 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
312 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
313 | /** Return menu, if any, for a buddy list node. */ |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
314 | GList * |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
315 | msim_blist_node_menu(PurpleBlistNode *node) |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
316 | { |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
317 | GList *menu, *zap_menu; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
318 | PurpleMenuAction *act; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
319 | const gchar *zap_names[10]; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
320 | guint i; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
321 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
322 | if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
323 | { |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
324 | /* Only know about buddies for now. */ |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
325 | return NULL; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
326 | } |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
327 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
328 | /* Names from official client. */ |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
329 | zap_names[0] = _("zap"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
330 | zap_names[1] = _("whack"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
331 | zap_names[2] = _("torch"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
332 | zap_names[3] = _("smooch"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
333 | zap_names[4] = _("hug"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
334 | zap_names[5] = _("bslap"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
335 | zap_names[6] = _("goose"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
336 | zap_names[7] = _("hi-five"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
337 | zap_names[8] = _("punk'd"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
338 | zap_names[9] = _("raspberry"); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
339 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
340 | menu = zap_menu = NULL; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
341 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
342 | for (i = 0; i < sizeof(zap_names) / sizeof(zap_names[0]); ++i) |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
343 | { |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
344 | act = purple_menu_action_new(zap_names[i], PURPLE_CALLBACK(msim_send_zap), |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
345 | GUINT_TO_POINTER(i), NULL); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
346 | zap_menu = g_list_append(zap_menu, act); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
347 | } |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
348 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
349 | act = purple_menu_action_new(_("Zap"), NULL, NULL, zap_menu); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
350 | menu = g_list_append(menu, act); |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
351 | |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
352 | return menu; |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
353 | } |
|
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
354 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
355 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
356 | * Return the icon name for a buddy and account. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
357 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
358 | * @param acct The account to find the icon for, or NULL for protocol icon. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
359 | * @param buddy The buddy to find the icon for, or NULL for the account icon. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
360 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
361 | * @return The base icon name string. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
362 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
363 | const gchar * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
364 | msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
365 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
366 | /* Use a MySpace icon submitted by hbons at |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
367 | * http://developer.pidgin.im/wiki/MySpaceIM. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
368 | return "myspace"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
369 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
370 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
371 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
372 | * Replace 'old' with 'new' in 'str'. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
373 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
374 | * @param str The original string. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
375 | * @param old The substring of 'str' to replace. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
376 | * @param new The replacement for 'old' within 'str'. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
377 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
378 | * @return A _new_ string, based on 'str', with 'old' replaced |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
379 | * by 'new'. Must be g_free()'d by caller. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
380 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
381 | * This string replace method is based on |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
382 | * http://mail.gnome.org/archives/gtk-app-devel-list/2000-July/msg00201.html |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
383 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
384 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
385 | gchar * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
386 | str_replace(const gchar *str, const gchar *old, const gchar *new) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
387 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
388 | gchar **items; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
389 | gchar *ret; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
390 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
391 | items = g_strsplit(str, old, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
392 | ret = g_strjoinv(new, items); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
393 | g_free(items); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
394 | return ret; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
395 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
396 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
397 | #ifdef MSIM_DEBUG_MSG |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
398 | static void |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
399 | print_hash_item(gpointer key, gpointer value, gpointer user_data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
400 | { |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
401 | purple_debug_info("msim", "%s=%s\n", |
|
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
402 | key ? (gchar *)key : "(NULL)", |
|
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
403 | value ? (gchar *)value : "(NULL)"); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
404 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
405 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
406 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
407 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
408 | * Send raw data (given as a NUL-terminated string) to the server. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
409 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
410 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
411 | * @param msg The raw data to send, in a NUL-terminated string. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
412 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
413 | * @return TRUE if succeeded, FALSE if not. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
414 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
415 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
416 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
417 | msim_send_raw(MsimSession *session, const gchar *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
418 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
419 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
420 | g_return_val_if_fail(msg != NULL, FALSE); |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
421 | |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
422 | purple_debug_info("msim", "msim_send_raw: writing <%s>\n", msg); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
423 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
424 | return msim_send_really_raw(session->gc, msg, strlen(msg)) == |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
425 | strlen(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
426 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
427 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
428 | /** Send raw data to the server, possibly with embedded NULs. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
429 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
430 | * Used in prpl_info struct, so that plugins can have the most possible |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
431 | * control of what is sent over the connection. Inside this prpl, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
432 | * msim_send_raw() is used, since it sends NUL-terminated strings (easier). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
433 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
434 | * @param gc PurpleConnection |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
435 | * @param buf Buffer to send |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
436 | * @param total_bytes Size of buffer to send |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
437 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
438 | * @return Bytes successfully sent, or -1 on error. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
439 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
440 | static int |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
441 | msim_send_really_raw(PurpleConnection *gc, const char *buf, int total_bytes) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
442 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
443 | int total_bytes_sent; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
444 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
445 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
446 | g_return_val_if_fail(gc != NULL, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
447 | g_return_val_if_fail(buf != NULL, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
448 | g_return_val_if_fail(total_bytes >= 0, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
449 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
450 | session = (MsimSession *)(gc->proto_data); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
451 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
452 | g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
453 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
454 | /* Loop until all data is sent, or a failure occurs. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
455 | total_bytes_sent = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
456 | do |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
457 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
458 | int bytes_sent; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
459 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
460 | bytes_sent = send(session->fd, buf + total_bytes_sent, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
461 | total_bytes - total_bytes_sent, 0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
462 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
463 | if (bytes_sent < 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
464 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
465 | purple_debug_info("msim", "msim_send_raw(%s): send() failed: %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
466 | buf, g_strerror(errno)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
467 | return total_bytes_sent; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
468 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
469 | total_bytes_sent += bytes_sent; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
470 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
471 | } while(total_bytes_sent < total_bytes); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
472 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
473 | return total_bytes_sent; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
474 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
475 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
476 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
477 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
478 | * Start logging in to the MSIM servers. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
479 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
480 | * @param acct Account information to use to login. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
481 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
482 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
483 | msim_login(PurpleAccount *acct) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
484 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
485 | PurpleConnection *gc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
486 | const gchar *host; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
487 | int port; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
488 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
489 | g_return_if_fail(acct != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
490 | g_return_if_fail(acct->username != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
491 | |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
492 | purple_debug_info("msim", "logging in %s\n", acct->username); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
493 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
494 | gc = purple_account_get_connection(acct); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
495 | gc->proto_data = msim_session_new(acct); |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
496 | gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_URLDESC; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
497 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
498 | /* Passwords are limited in length. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
499 | if (strlen(acct->password) > MSIM_MAX_PASSWORD_LENGTH) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
500 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
501 | gchar *str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
502 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
503 | str = g_strdup_printf( |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
504 | _("Sorry, passwords over %d characters in length (yours is " |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
505 | "%d) are not supported by the MySpaceIM plugin."), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
506 | MSIM_MAX_PASSWORD_LENGTH, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
507 | (int)strlen(acct->password)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
508 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
509 | /* Notify an error message also, because this is important! */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
510 | purple_notify_error(acct, g_strdup(_("MySpaceIM Error")), str, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
511 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
512 | purple_connection_error(gc, str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
513 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
514 | g_free(str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
515 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
516 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
517 | /* 1. connect to server */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
518 | purple_connection_update_progress(gc, _("Connecting"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
519 | 0, /* which connection step this is */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
520 | 4); /* total number of steps */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
521 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
522 | host = purple_account_get_string(acct, "server", MSIM_SERVER); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
523 | port = purple_account_get_int(acct, "port", MSIM_PORT); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
524 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
525 | /* From purple.sf.net/api: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
526 | * """Note that this function name can be misleading--although it is called |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
527 | * "proxy connect," it is used for establishing any outgoing TCP connection, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
528 | * whether through a proxy or not.""" */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
529 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
530 | /* Calls msim_connect_cb when connected. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
531 | if (purple_proxy_connect(gc, acct, host, port, msim_connect_cb, gc) == NULL) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
532 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
533 | /* TODO: try other ports if in auto mode, then save |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
534 | * working port and try that first next time. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
535 | purple_connection_error(gc, _("Couldn't create socket")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
536 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
537 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
538 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
539 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
540 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
541 | * Process a login challenge, sending a response. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
542 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
543 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
544 | * @param msg Login challenge message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
545 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
546 | * @return TRUE if successful, FALSE if not |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
547 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
548 | static gboolean |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
549 | msim_login_challenge(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
550 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
551 | PurpleAccount *account; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
552 | const gchar *response; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
553 | guint response_len; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
554 | gchar *nc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
555 | gsize nc_len; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
556 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
557 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
558 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
559 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
560 | g_return_val_if_fail(msim_msg_get_binary(msg, "nc", &nc, &nc_len), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
561 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
562 | account = session->account; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
563 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
564 | g_return_val_if_fail(account != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
565 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
566 | purple_connection_update_progress(session->gc, _("Reading challenge"), 1, 4); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
567 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
568 | purple_debug_info("msim", "nc is %d bytes, decoded\n", nc_len); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
569 | |
|
18031
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
570 | if (nc_len != MSIM_AUTH_CHALLENGE_LENGTH) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
571 | { |
|
18031
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
572 | purple_debug_info("msim", "bad nc length: %x != 0x%x\n", nc_len, MSIM_AUTH_CHALLENGE_LENGTH); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
573 | purple_connection_error(session->gc, _("Unexpected challenge length from server")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
574 | return FALSE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
575 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
576 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
577 | purple_connection_update_progress(session->gc, _("Logging in"), 2, 4); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
578 | |
|
18062
c903259e0c83
Store 3rd-party client name/version and official client build version (cv) separately.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18061
diff
changeset
|
579 | response_len = 0; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
580 | response = msim_compute_login_response(nc, account->username, account->password, &response_len); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
581 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
582 | g_free(nc); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
583 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
584 | return msim_send(session, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
585 | "login2", MSIM_TYPE_INTEGER, MSIM_AUTH_ALGORITHM, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
586 | /* This is actually user's email address. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
587 | "username", MSIM_TYPE_STRING, g_strdup(account->username), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
588 | /* GString and gchar * response will be freed in msim_msg_free() in msim_send(). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
589 | "response", MSIM_TYPE_BINARY, g_string_new_len(response, response_len), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
590 | "clientver", MSIM_TYPE_INTEGER, MSIM_CLIENT_VERSION, |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
591 | "langid", MSIM_TYPE_INTEGER, MSIM_LANGUAGE_ID_ENGLISH, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
592 | "imlang", MSIM_TYPE_STRING, g_strdup(MSIM_LANGUAGE_NAME_ENGLISH), |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
593 | "reconn", MSIM_TYPE_INTEGER, 0, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
594 | "status", MSIM_TYPE_INTEGER, 100, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
595 | "id", MSIM_TYPE_INTEGER, 1, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
596 | NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
597 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
598 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
599 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
600 | * Compute the base64'd login challenge response based on username, password, nonce, and IPs. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
601 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
602 | * @param nonce The base64 encoded nonce ('nc') field from the server. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
603 | * @param email User's email address (used as login name). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
604 | * @param password User's cleartext password. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
605 | * @param response_len Will be written with response length. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
606 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
607 | * @return Binary login challenge response, ready to send to the server. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
608 | * Must be g_free()'d when finished. NULL if error. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
609 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
610 | static const gchar * |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
611 | msim_compute_login_response(const gchar nonce[2 * NONCE_SIZE], |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
612 | const gchar *email, const gchar *password, guint *response_len) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
613 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
614 | PurpleCipherContext *key_context; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
615 | PurpleCipher *sha1; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
616 | PurpleCipherContext *rc4; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
617 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
618 | guchar hash_pw[HASH_SIZE]; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
619 | guchar key[HASH_SIZE]; |
|
18031
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
620 | gchar *password_utf16le, *password_ascii_lc; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
621 | guchar *data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
622 | guchar *data_out; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
623 | size_t data_len, data_out_len; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
624 | gsize conv_bytes_read, conv_bytes_written; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
625 | GError *conv_error; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
626 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
627 | int i; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
628 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
629 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
630 | g_return_val_if_fail(nonce != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
631 | g_return_val_if_fail(email != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
632 | g_return_val_if_fail(password != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
633 | g_return_val_if_fail(response_len != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
634 | |
|
18031
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
635 | /* Convert password to lowercase (required for passwords containing |
|
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
636 | * uppercase characters). MySpace passwords are lowercase, |
|
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
637 | * see ticket #2066. */ |
|
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
638 | password_ascii_lc = g_strdup(password); |
|
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
639 | g_strdown(password_ascii_lc); |
|
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
640 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
641 | /* Convert ASCII password to UTF16 little endian */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
642 | purple_debug_info("msim", "converting password to UTF-16LE\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
643 | conv_error = NULL; |
|
18031
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
644 | password_utf16le = g_convert(password_ascii_lc, -1, "UTF-16LE", "UTF-8", |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
645 | &conv_bytes_read, &conv_bytes_written, &conv_error); |
|
18031
4ebc87fe43d9
Lowercase password before sending it. Closes #2066.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18029
diff
changeset
|
646 | g_free(password_ascii_lc); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
647 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
648 | g_return_val_if_fail(conv_bytes_read == strlen(password), NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
649 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
650 | if (conv_error != NULL) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
651 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
652 | purple_debug_error("msim", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
653 | "g_convert password UTF8->UTF16LE failed: %s", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
654 | conv_error->message); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
655 | g_error_free(conv_error); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
656 | return NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
657 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
658 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
659 | /* Compute password hash */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
660 | purple_cipher_digest_region("sha1", (guchar *)password_utf16le, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
661 | conv_bytes_written, sizeof(hash_pw), hash_pw, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
662 | g_free(password_utf16le); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
663 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
664 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
665 | purple_debug_info("msim", "pwhash = "); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
666 | for (i = 0; i < sizeof(hash_pw); i++) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
667 | purple_debug_info("msim", "%.2x ", hash_pw[i]); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
668 | purple_debug_info("msim", "\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
669 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
670 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
671 | /* key = sha1(sha1(pw) + nonce2) */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
672 | sha1 = purple_ciphers_find_cipher("sha1"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
673 | key_context = purple_cipher_context_new(sha1, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
674 | purple_cipher_context_append(key_context, hash_pw, HASH_SIZE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
675 | purple_cipher_context_append(key_context, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
676 | purple_cipher_context_digest(key_context, sizeof(key), key, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
677 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
678 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
679 | purple_debug_info("msim", "key = "); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
680 | for (i = 0; i < sizeof(key); i++) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
681 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
682 | purple_debug_info("msim", "%.2x ", key[i]); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
683 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
684 | purple_debug_info("msim", "\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
685 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
686 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
687 | rc4 = purple_cipher_context_new_by_name("rc4", NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
688 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
689 | /* Note: 'key' variable is 0x14 bytes (from SHA-1 hash), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
690 | * but only first 0x10 used for the RC4 key. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
691 | purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
692 | purple_cipher_context_set_key(rc4, key); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
693 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
694 | /* TODO: obtain IPs of network interfaces */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
695 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
696 | /* rc4 encrypt: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
697 | * nonce1+email+IP list */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
698 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
699 | data_len = NONCE_SIZE + strlen(email) + MSIM_LOGIN_IP_LIST_LEN; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
700 | data = g_new0(guchar, data_len); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
701 | memcpy(data, nonce, NONCE_SIZE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
702 | memcpy(data + NONCE_SIZE, email, strlen(email)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
703 | memcpy(data + NONCE_SIZE + strlen(email), MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
704 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
705 | data_out = g_new0(guchar, data_len); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
706 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
707 | purple_cipher_context_encrypt(rc4, (const guchar *)data, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
708 | data_len, data_out, &data_out_len); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
709 | purple_cipher_context_destroy(rc4); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
710 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
711 | g_assert(data_out_len == data_len); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
712 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
713 | #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
714 | purple_debug_info("msim", "response=<%s>\n", data_out); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
715 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
716 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
717 | *response_len = data_out_len; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
718 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
719 | return (const gchar *)data_out; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
720 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
721 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
722 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
723 | * Schedule an IM to be sent once the user ID is looked up. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
724 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
725 | * @param gc Connection. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
726 | * @param who A user id, email, or username to send the message to. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
727 | * @param message Instant message text to send. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
728 | * @param flags Flags. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
729 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
730 | * @return 1 if successful or postponed, -1 if failed |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
731 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
732 | * Allows sending to a user by username, email address, or userid. If |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
733 | * a username or email address is given, the userid must be looked up. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
734 | * This function does that by calling msim_postprocess_outgoing(). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
735 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
736 | int |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
737 | msim_send_im(PurpleConnection *gc, const gchar *who, const gchar *message, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
738 | PurpleMessageFlags flags) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
739 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
740 | MsimSession *session; |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
741 | gchar *message_msim; |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
742 | int rc; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
743 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
744 | g_return_val_if_fail(gc != NULL, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
745 | g_return_val_if_fail(who != NULL, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
746 | g_return_val_if_fail(message != NULL, -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
747 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
748 | /* 'flags' has many options, not used here. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
749 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
750 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
751 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
752 | g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
753 | |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
754 | message_msim = html_to_msim_markup(session, message); |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
755 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
756 | if (msim_send_bm(session, who, message_msim, MSIM_BM_INSTANT)) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
757 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
758 | /* Return 1 to have Purple show this IM as being sent, 0 to not. I always |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
759 | * return 1 even if the message could not be sent, since I don't know if |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
760 | * it has failed yet--because the IM is only sent after the userid is |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
761 | * retrieved from the server (which happens after this function returns). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
762 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
763 | /* TODO: maybe if message is delayed, don't echo to conv window, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
764 | * but do echo it to conv window manually once it is actually |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
765 | * sent? Would be complicated. */ |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
766 | rc = 1; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
767 | } else { |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
768 | rc = -1; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
769 | } |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
770 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
771 | g_free(message_msim); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
772 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
773 | /* |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
774 | * In MySpace, you login with your email address, but don't talk to other |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
775 | * users using their email address. So there is currently an asymmetry in the |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
776 | * IM windows when using this plugin: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
777 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
778 | * you@example.com: hello |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
779 | * some_other_user: what's going on? |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
780 | * you@example.com: just coding a prpl |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
781 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
782 | * TODO: Make the sent IM's appear as from the user's username, instead of |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
783 | * their email address. Purple uses the login (in MSIM, the email)--change this. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
784 | */ |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
785 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
786 | return rc; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
787 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
788 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
789 | /** Send a buddy message of a given type. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
790 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
791 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
792 | * @param who Username to send message to. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
793 | * @param text Message text to send. Not freed; will be copied. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
794 | * @param type A MSIM_BM_* constant. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
795 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
796 | * @return TRUE if success, FALSE if fail. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
797 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
798 | * Buddy messages ('bm') include instant messages, action messages, status messages, etc. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
799 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
800 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
801 | static gboolean |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
802 | msim_send_bm(MsimSession *session, const gchar *who, const gchar *text, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
803 | int type) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
804 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
805 | gboolean rc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
806 | MsimMessage *msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
807 | const gchar *from_username; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
808 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
809 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
810 | g_return_val_if_fail(who != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
811 | g_return_val_if_fail(text != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
812 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
813 | from_username = session->account->username; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
814 | |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
815 | g_return_val_if_fail(from_username != NULL, FALSE); |
|
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
816 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
817 | purple_debug_info("msim", "sending %d message from %s to %s: %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
818 | type, from_username, who, text); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
819 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
820 | msg = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
821 | "bm", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(type), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
822 | "sesskey", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(session->sesskey), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
823 | /* 't' will be inserted here */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
824 | "cv", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(MSIM_CLIENT_VERSION), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
825 | "msg", MSIM_TYPE_STRING, g_strdup(text), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
826 | NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
827 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
828 | rc = msim_postprocess_outgoing(session, msg, who, "t", "cv"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
829 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
830 | msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
831 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
832 | return rc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
833 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
834 | |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
835 | /* Indexes of this array + 1 map HTML font size to scale of normal font size. * |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
836 | * Based on _point_sizes from libpurple/gtkimhtml.c |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
837 | * 1 2 3 4 5 6 7 */ |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
838 | static gdouble _font_scale[] = { .85, .95, 1, 1.2, 1.44, 1.728, 2.0736 }; |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
839 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
840 | #define MAX_FONT_SIZE 7 /* Purple maximum font size */ |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
841 | #define POINTS_PER_INCH 72 /* How many pt's in an inch */ |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
842 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
843 | /** Convert typographical font point size to HTML font size. |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
844 | * Based on libpurple/gtkimhtml.c */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
845 | static guint |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
846 | msim_point_to_purple_size(MsimSession *session, guint point) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
847 | { |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
848 | guint size, this_point, base; |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
849 | gdouble scale; |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
850 | |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
851 | base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
852 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
853 | for (size = 0; size < sizeof(_font_scale) / sizeof(_font_scale[0]); ++size) |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
854 | { |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
855 | scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1]; |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
856 | this_point = (guint)round(scale * base); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
857 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
858 | if (this_point >= point) |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
859 | { |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
860 | purple_debug_info("msim", "msim_point_to_purple_size: %d pt -> size=%d\n", |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
861 | point, size); |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
862 | return size; |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
863 | } |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
864 | } |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
865 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
866 | /* No HTML font size was this big; return largest possible. */ |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
867 | return this_point; |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
868 | } |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
869 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
870 | /** Convert HTML font size to point size. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
871 | static guint |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
872 | msim_purple_size_to_point(MsimSession *session, guint size) |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
873 | { |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
874 | gdouble scale; |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
875 | guint point; |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
876 | guint base; |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
877 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
878 | scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1]; |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
879 | |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
880 | base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE); |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
881 | |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
882 | point = (guint)round(scale * base); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
883 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
884 | purple_debug_info("msim", "msim_purple_size_to_point: size=%d -> %d pt\n", |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
885 | size, point); |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
886 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
887 | return point; |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
888 | } |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
889 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
890 | /** Convert a msim markup font pixel height to the more usual point size, for incoming messages. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
891 | static guint |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
892 | msim_height_to_point(MsimSession *session, guint height) |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
893 | { |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
894 | guint dpi; |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
895 | |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
896 | dpi = purple_account_get_int(session->account, "port", MSIM_DEFAULT_DPI); |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
897 | |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
898 | return (guint)round((POINTS_PER_INCH * 1. / dpi) * height); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
899 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
900 | /* See also: libpurple/protocols/bonjour/jabber.c |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
901 | * _font_size_ichat_to_purple */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
902 | } |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
903 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
904 | /** Convert point size to msim pixel height font size specification, for outgoing messages. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
905 | static guint |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
906 | msim_point_to_height(MsimSession *session, guint point) |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
907 | { |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
908 | guint dpi; |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
909 | |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
910 | dpi = purple_account_get_int(session->account, "port", MSIM_DEFAULT_DPI); |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
911 | |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
912 | return (guint)round((dpi * 1. / POINTS_PER_INCH) * point); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
913 | } |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
914 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
915 | /** Convert the msim markup <f> (font) tag into HTML. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
916 | static void |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
917 | msim_markup_f_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
918 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
919 | const gchar *face, *height_str, *decor_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
920 | GString *gs_end, *gs_begin; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
921 | guint decor, height; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
922 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
923 | face = xmlnode_get_attrib(root, "f"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
924 | height_str = xmlnode_get_attrib(root, "h"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
925 | decor_str = xmlnode_get_attrib(root, "s"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
926 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
927 | if (height_str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
928 | height = atol(height_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
929 | else |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
930 | height = 12; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
931 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
932 | if (decor_str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
933 | decor = atol(decor_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
934 | else |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
935 | decor = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
936 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
937 | gs_begin = g_string_new(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
938 | /* TODO: get font size working */ |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
939 | if (height && !face) |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
940 | g_string_printf(gs_begin, "<font size='%d'>", |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
941 | msim_point_to_purple_size(session, msim_height_to_point(session, height))); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
942 | else if (height && face) |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
943 | g_string_printf(gs_begin, "<font face='%s' size='%d'>", face, |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
944 | msim_point_to_purple_size(session, msim_height_to_point(session, height))); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
945 | else |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
946 | g_string_printf(gs_begin, "<font>"); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
947 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
948 | /* No support for font-size CSS? */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
949 | /* g_string_printf(gs_begin, "<span style='font-family: %s; font-size: %dpt'>", face, |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
950 | msim_height_to_point(height)); */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
951 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
952 | gs_end = g_string_new("</font>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
953 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
954 | if (decor & MSIM_TEXT_BOLD) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
955 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
956 | g_string_append(gs_begin, "<b>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
957 | g_string_prepend(gs_end, "</b>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
958 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
959 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
960 | if (decor & MSIM_TEXT_ITALIC) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
961 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
962 | g_string_append(gs_begin, "<i>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
963 | g_string_append(gs_end, "</i>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
964 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
965 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
966 | if (decor & MSIM_TEXT_UNDERLINE) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
967 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
968 | g_string_append(gs_begin, "<u>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
969 | g_string_append(gs_end, "</u>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
970 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
971 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
972 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
973 | *begin = gs_begin->str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
974 | *end = gs_end->str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
975 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
976 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
977 | /** Convert a msim markup color to a color suitable for libpurple. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
978 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
979 | * @param msim Either a color name, or an rgb(x,y,z) code. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
980 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
981 | * @return A new string, either a color name or #rrggbb code. Must g_free(). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
982 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
983 | static char * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
984 | msim_color_to_purple(const char *msim) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
985 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
986 | guint red, green, blue; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
987 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
988 | if (!msim) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
989 | return g_strdup("black"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
990 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
991 | if (sscanf(msim, "rgb(%d,%d,%d)", &red, &green, &blue) != 3) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
992 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
993 | /* Color name. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
994 | return g_strdup(msim); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
995 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
996 | /* TODO: rgba (alpha). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
997 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
998 | return g_strdup_printf("#%.2x%.2x%.2x", red, green, blue); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
999 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1000 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1001 | /** Convert the msim markup <p> (paragraph) tag into HTML. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1002 | static void |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1003 | msim_markup_p_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1004 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1005 | /* Just pass through unchanged. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1006 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1007 | * Note: attributes currently aren't passed, if there are any. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1008 | *begin = g_strdup("<p>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1009 | *end = g_strdup("</p>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1010 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1011 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1012 | /** Convert the msim markup <c> tag (text color) into HTML. TODO: Test */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1013 | static void |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1014 | msim_markup_c_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1015 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1016 | const gchar *color; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1017 | gchar *purple_color; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1018 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1019 | color = xmlnode_get_attrib(root, "v"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1020 | if (!color) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1021 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1022 | purple_debug_info("msim", "msim_markup_c_to_html: <c> tag w/o v attr"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1023 | *begin = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1024 | *end = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1025 | /* TODO: log as unrecognized */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1026 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1027 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1028 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1029 | purple_color = msim_color_to_purple(color); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1030 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1031 | *begin = g_strdup_printf("<font color='%s'>", purple_color); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1032 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1033 | g_free(purple_color); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1034 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1035 | /* *begin = g_strdup_printf("<span style='color: %s'>", color); */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1036 | *end = g_strdup("</font>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1037 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1038 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1039 | /** Convert the msim markup <b> tag (background color) into HTML. TODO: Test */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1040 | static void |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1041 | msim_markup_b_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1042 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1043 | const gchar *color; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1044 | gchar *purple_color; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1045 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1046 | color = xmlnode_get_attrib(root, "v"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1047 | if (!color) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1048 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1049 | *begin = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1050 | *end = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1051 | purple_debug_info("msim", "msim_markup_b_to_html: <b> w/o v attr"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1052 | /* TODO: log as unrecognized. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1053 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1054 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1055 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1056 | purple_color = msim_color_to_purple(color); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1057 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1058 | /* TODO: find out how to set background color. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1059 | *begin = g_strdup_printf("<span style='background-color: %s'>", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1060 | purple_color); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1061 | g_free(purple_color); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1062 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1063 | *end = g_strdup("</p>"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1064 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1065 | |
|
18046
bb35d08adf0b
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18045
diff
changeset
|
1066 | /** Convert the msim markup <i> tag (emoticon image) into HTML. */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1067 | static void |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1068 | msim_markup_i_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1069 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1070 | const gchar *name; |
|
18046
bb35d08adf0b
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18045
diff
changeset
|
1071 | guint i; |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1072 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1073 | name = xmlnode_get_attrib(root, "n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1074 | if (!name) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1075 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1076 | purple_debug_info("msim", "msim_markup_i_to_html: <i> w/o n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1077 | *begin = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1078 | *end = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1079 | /* TODO: log as unrecognized */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1080 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1081 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1082 | |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1083 | for (i = 0; emoticon_names[i] != NULL; ++i) |
|
18046
bb35d08adf0b
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18045
diff
changeset
|
1084 | { |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1085 | if (!strcmp(name, emoticon_names[i])) |
|
18046
bb35d08adf0b
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18045
diff
changeset
|
1086 | { |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1087 | *begin = g_strdup(emoticon_symbols[i]); |
|
18046
bb35d08adf0b
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18045
diff
changeset
|
1088 | *end = g_strdup(""); |
|
bb35d08adf0b
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18045
diff
changeset
|
1089 | return; |
|
bb35d08adf0b
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18045
diff
changeset
|
1090 | } |
|
bb35d08adf0b
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18045
diff
changeset
|
1091 | } |
|
bb35d08adf0b
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18045
diff
changeset
|
1092 | |
|
bb35d08adf0b
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18045
diff
changeset
|
1093 | *begin = g_strdup(name); |
|
bb35d08adf0b
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18045
diff
changeset
|
1094 | *end = g_strdup(""); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1095 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1096 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1097 | /** Convert an individual msim markup tag to HTML. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1098 | static void |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1099 | msim_markup_tag_to_html(MsimSession *session, xmlnode *root, gchar **begin, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1100 | gchar **end) |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1101 | { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1102 | if (!strcmp(root->name, "f")) |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1103 | { |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1104 | msim_markup_f_to_html(session, root, begin, end); |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1105 | } else if (!strcmp(root->name, "p")) { |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1106 | msim_markup_p_to_html(session, root, begin, end); |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1107 | } else if (!strcmp(root->name, "c")) { |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1108 | msim_markup_c_to_html(session, root, begin, end); |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1109 | } else if (!strcmp(root->name, "b")) { |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1110 | msim_markup_b_to_html(session, root, begin, end); |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1111 | } else if (!strcmp(root->name, "i")) { |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1112 | msim_markup_i_to_html(session, root, begin, end); |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1113 | } else { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1114 | purple_debug_info("msim", "msim_markup_tag_to_html: " |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1115 | "unknown tag name=%s, ignoring", |
|
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1116 | (root && root->name) ? root->name : "(NULL)"); |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1117 | *begin = g_strdup(""); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1118 | *end = g_strdup(""); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1119 | } |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1120 | } |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1121 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1122 | /** Convert an individual HTML tag to msim markup. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1123 | static void |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1124 | html_tag_to_msim_markup(MsimSession *session, xmlnode *root, gchar **begin, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1125 | gchar **end) |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1126 | { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1127 | /* TODO: Coalesce nested tags into one <f> tag! |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1128 | * Currently, the 's' value will be overwritten when b/i/u is nested |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1129 | * within another one, and only the inner-most formatting will be |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1130 | * applied to the text. */ |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1131 | if (!strcmp(root->name, "root")) |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1132 | { |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1133 | *begin = g_strdup(""); |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1134 | *end = g_strdup(""); |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1135 | } else if (!strcmp(root->name, "b")) { |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1136 | *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_BOLD); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1137 | *end = g_strdup("</f>"); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1138 | } else if (!strcmp(root->name, "i")) { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1139 | *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_ITALIC); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1140 | *end = g_strdup("</f>"); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1141 | } else if (!strcmp(root->name, "u")) { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1142 | *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_UNDERLINE); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1143 | *end = g_strdup("</f>"); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1144 | } else if (!strcmp(root->name, "font")) { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1145 | const gchar *size; |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1146 | const gchar *face; |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1147 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1148 | size = xmlnode_get_attrib(root, "size"); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1149 | face = xmlnode_get_attrib(root, "face"); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1150 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1151 | if (face && size) |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1152 | { |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1153 | *begin = g_strdup_printf("<f f='%s' h='%d'>", face, |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1154 | msim_point_to_height(session, |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1155 | msim_purple_size_to_point(session, atoi(size)))); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1156 | } else if (face) { |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1157 | *begin = g_strdup_printf("<f f='%s'>", face); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1158 | } else if (size) { |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1159 | *begin = g_strdup_printf("<f h='%d'>", |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1160 | msim_point_to_height(session, |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1161 | msim_purple_size_to_point(session, atoi(size)))); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1162 | } else { |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1163 | *begin = g_strdup("<f>"); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1164 | } |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1165 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1166 | *end = g_strdup("</f>"); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1167 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1168 | /* TODO: color (bg uses <body>), emoticons */ |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1169 | } else { |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1170 | *begin = g_strdup_printf("[%s]", root->name); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1171 | *end = g_strdup_printf("[/%s]", root->name); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1172 | } |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1173 | } |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1174 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1175 | /** Convert an xmlnode of msim markup or HTML to an HTML string or msim markup. |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1176 | * |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1177 | * @param f Function to convert tags. |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1178 | * |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1179 | * @return An HTML string. Caller frees. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1180 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1181 | static gchar * |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1182 | msim_convert_xmlnode(MsimSession *session, xmlnode *root, MSIM_XMLNODE_CONVERT f) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1183 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1184 | xmlnode *node; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1185 | gchar *begin, *inner, *end; |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1186 | GString *final; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1187 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1188 | if (!root || !root->name) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1189 | return g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1190 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1191 | purple_debug_info("msim", "msim_convert_xmlnode: got root=%s\n", |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1192 | root->name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1193 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1194 | begin = inner = end = NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1195 | |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1196 | final = g_string_new(""); |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1197 | |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1198 | f(session, root, &begin, &end); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1199 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1200 | g_string_append(final, begin); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1201 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1202 | /* Loop over all child nodes. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1203 | for (node = root->child; node != NULL; node = node->next) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1204 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1205 | switch (node->type) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1206 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1207 | case XMLNODE_TYPE_ATTRIB: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1208 | /* Attributes handled above. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1209 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1210 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1211 | case XMLNODE_TYPE_TAG: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1212 | /* A tag or tag with attributes. Recursively descend. */ |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1213 | inner = msim_convert_xmlnode(session, node, f); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1214 | g_return_val_if_fail(inner != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1215 | |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1216 | purple_debug_info("msim", " ** node name=%s\n", |
|
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1217 | (node && node->name) ? node->name : "(NULL)"); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1218 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1219 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1220 | case XMLNODE_TYPE_DATA: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1221 | /* Literal text. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1222 | inner = g_new0(char, node->data_sz + 1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1223 | strncpy(inner, node->data, node->data_sz); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1224 | inner[node->data_sz] = 0; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1225 | |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1226 | purple_debug_info("msim", " ** node data=%s\n", |
|
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1227 | inner ? inner : "(NULL)"); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1228 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1229 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1230 | default: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1231 | purple_debug_info("msim", |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1232 | "msim_convert_xmlnode: strange node\n"); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1233 | inner = g_strdup(""); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1234 | } |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1235 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1236 | if (inner) |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1237 | g_string_append(final, inner); |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1238 | } |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1239 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1240 | /* TODO: Note that msim counts each piece of text enclosed by <f> as |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1241 | * a paragraph and will display each on its own line. You actually have |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1242 | * to _nest_ <f> tags to intersperse different text in one paragraph! |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1243 | * Comment out this line below to see. */ |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1244 | g_string_append(final, end); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1245 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1246 | purple_debug_info("msim", "msim_markup_xmlnode_to_gtkhtml: RETURNING %s\n", |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1247 | (final && final->str) ? final->str : "(NULL)"); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1248 | |
|
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1249 | return final->str; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1250 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1251 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1252 | /** Convert XML to something based on MSIM_XMLNODE_CONVERT. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1253 | static gchar * |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1254 | msim_convert_xml(MsimSession *session, const gchar *raw, MSIM_XMLNODE_CONVERT f) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1255 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1256 | xmlnode *root; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1257 | gchar *str; |
|
18048
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1258 | gchar *enclosed_raw; |
|
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1259 | |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1260 | g_return_val_if_fail(raw != NULL, NULL); |
|
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1261 | |
|
18048
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1262 | /* Enclose text in one root tag, to try to make it valid XML for parsing. */ |
|
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1263 | enclosed_raw = g_strconcat("<root>", raw, "</root>", NULL); |
|
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1264 | |
|
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1265 | root = xmlnode_from_str(enclosed_raw, -1); |
|
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1266 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1267 | if (!root) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1268 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1269 | purple_debug_info("msim", "msim_markup_to_html: couldn't parse " |
|
18048
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1270 | "%s as XML, returning raw: %s\n", enclosed_raw, raw); |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1271 | /* TODO: msim_unrecognized */ |
|
18048
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1272 | g_free(enclosed_raw); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1273 | return g_strdup(raw); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1274 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1275 | |
|
18048
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1276 | g_free(enclosed_raw); |
|
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1277 | |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1278 | str = msim_convert_xmlnode(session, root, f); |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1279 | g_return_val_if_fail(str != NULL, NULL); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1280 | purple_debug_info("msim", "msim_markup_to_html: returning %s\n", str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1281 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1282 | xmlnode_free(root); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1283 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1284 | return str; |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1285 | } |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1286 | |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1287 | /** Convert plaintext smileys to <i> markup tags. |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1288 | * |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1289 | * @param before Original text with ASCII smileys. Will be freed. |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1290 | * @return A new string with <i> tags, if applicable. Must be g_free()'d. |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1291 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1292 | static gchar * |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1293 | msim_convert_smileys_to_markup(gchar *before) |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1294 | { |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1295 | gchar *old, *new, *replacement; |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1296 | guint i; |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1297 | |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1298 | old = before; |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1299 | new = NULL; |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1300 | |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1301 | for (i = 0; emoticon_symbols[i] != NULL; ++i) |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1302 | { |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1303 | |
|
18051
e8d4851edaa2
Finish emoticon support. You can now send smileys to yourself, they can
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18050
diff
changeset
|
1304 | replacement = g_strdup_printf("<i n=\"%s\"/>", emoticon_names[i]); |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1305 | |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1306 | purple_debug_info("msim", "msim_convert_smileys_to_markup: %s->%s\n", |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1307 | emoticon_symbols[i] ? emoticon_symbols[i] : "(NULL)", |
|
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1308 | replacement ? replacement : "(NULL)"); |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1309 | new = str_replace(old, emoticon_symbols[i], replacement); |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1310 | |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1311 | g_free(replacement); |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1312 | g_free(old); |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1313 | |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1314 | old = new; |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1315 | } |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1316 | |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1317 | return new; |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1318 | } |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1319 | |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1320 | |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1321 | /** High-level function to convert MySpaceIM markup to Purple (HTML) markup. |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1322 | * |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1323 | * @return Purple markup string, must be g_free()'d. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1324 | static gchar * |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1325 | msim_markup_to_html(MsimSession *session, const gchar *raw) |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1326 | { |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1327 | return msim_convert_xml(session, raw, |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1328 | (MSIM_XMLNODE_CONVERT)(msim_markup_tag_to_html)); |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1329 | } |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1330 | |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1331 | /** High-level function to convert Purple (HTML) to MySpaceIM markup. |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1332 | * |
|
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1333 | * @return HTML markup string, must be g_free()'d. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1334 | static gchar * |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1335 | html_to_msim_markup(MsimSession *session, const gchar *raw) |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1336 | { |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1337 | gchar *markup; |
|
18048
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1338 | |
|
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1339 | markup = msim_convert_xml(session, raw, |
|
18028
85ed2582be94
Support sending some formatted text in instant messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18026
diff
changeset
|
1340 | (MSIM_XMLNODE_CONVERT)(html_tag_to_msim_markup)); |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1341 | |
|
18051
e8d4851edaa2
Finish emoticon support. You can now send smileys to yourself, they can
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18050
diff
changeset
|
1342 | if (purple_account_get_bool(session->account, "emoticons", TRUE)) |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1343 | { |
|
18048
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
1344 | /* Frees markup and allocates a new one. */ |
|
18047
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1345 | markup = msim_convert_smileys_to_markup(markup); |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1346 | } |
|
c58fc8a8e378
Add support for sending emoticons.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18046
diff
changeset
|
1347 | |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
1348 | return markup; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1349 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1350 | |
|
18045
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1351 | /** Record the client version in the buddy list, from an incoming message. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1352 | static gboolean |
|
18045
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1353 | msim_incoming_bm_record_cv(MsimSession *session, MsimMessage *msg) |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1354 | { |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1355 | gchar *username, *cv; |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1356 | gboolean ret; |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1357 | PurpleBuddy *buddy; |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1358 | |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1359 | username = msim_msg_get_string(msg, "_username"); |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1360 | cv = msim_msg_get_string(msg, "cv"); |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1361 | |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1362 | g_return_val_if_fail(username != NULL, FALSE); |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1363 | g_return_val_if_fail(cv != NULL, FALSE); |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1364 | |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1365 | buddy = purple_find_buddy(session->account, username); |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1366 | |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1367 | if (buddy) |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1368 | { |
|
18062
c903259e0c83
Store 3rd-party client name/version and official client build version (cv) separately.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18061
diff
changeset
|
1369 | purple_blist_node_set_int(&buddy->node, "client_cv", atol(cv)); |
|
18045
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1370 | ret = TRUE; |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1371 | } else { |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1372 | ret = FALSE; |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1373 | } |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1374 | |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1375 | g_free(username); |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1376 | g_free(cv); |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1377 | |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1378 | return ret; |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1379 | } |
|
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1380 | |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1381 | /** Handle an incoming buddy message. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1382 | static gboolean |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1383 | msim_incoming_bm(MsimSession *session, MsimMessage *msg) |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1384 | { |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1385 | guint bm; |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1386 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1387 | bm = msim_msg_get_integer(msg, "bm"); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1388 | |
|
18045
7e4b117d740b
Show official client build in buddy profiles.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18044
diff
changeset
|
1389 | msim_incoming_bm_record_cv(session, msg); |
|
18044
06152cc939ef
Increase read buffer size and be more careful about overruns.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18043
diff
changeset
|
1390 | |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1391 | switch (bm) |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1392 | { |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1393 | case MSIM_BM_STATUS: |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1394 | return msim_incoming_status(session, msg); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1395 | case MSIM_BM_INSTANT: |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1396 | return msim_incoming_im(session, msg); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1397 | case MSIM_BM_ACTION: |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1398 | return msim_incoming_action(session, msg); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1399 | case MSIM_BM_MEDIA: |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1400 | return msim_incoming_media(session, msg); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1401 | case MSIM_BM_UNOFFICIAL_CLIENT: |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1402 | return msim_incoming_unofficial_client(session, msg); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1403 | default: |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1404 | /* Not really an IM, but show it for informational |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1405 | * purposes during development. */ |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1406 | return msim_incoming_im(session, msg); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1407 | } |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1408 | } |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1409 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1410 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1411 | * Handle an incoming instant message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1412 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1413 | * @param session The session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1414 | * @param msg Message from the server, containing 'f' (userid from) and 'msg'. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1415 | * Should also contain username in _username from preprocessing. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1416 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1417 | * @return TRUE if successful. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1418 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1419 | static gboolean |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1420 | msim_incoming_im(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1421 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1422 | gchar *username, *msg_msim_markup, *msg_purple_markup; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1423 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1424 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1425 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1426 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1427 | username = msim_msg_get_string(msg, "_username"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1428 | g_return_val_if_fail(username != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1429 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1430 | msg_msim_markup = msim_msg_get_string(msg, "msg"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1431 | g_return_val_if_fail(msg_msim_markup != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1432 | |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
1433 | msg_purple_markup = msim_markup_to_html(session, msg_msim_markup); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1434 | g_free(msg_msim_markup); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1435 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1436 | serv_got_im(session->gc, username, msg_purple_markup, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1437 | PURPLE_MESSAGE_RECV, time(NULL)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1438 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1439 | g_free(username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1440 | g_free(msg_purple_markup); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1441 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1442 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1443 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1444 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1445 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1446 | * Process unrecognized information. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1447 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1448 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1449 | * @param msg An MsimMessage that was unrecognized, or NULL. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1450 | * @param note Information on what was unrecognized, or NULL. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1451 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1452 | static void |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1453 | msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1454 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1455 | /* TODO: Some more context, outwardly equivalent to a backtrace, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1456 | * for helping figure out what this msg is for. What was going on? |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1457 | * But not too much information so that a user |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1458 | * posting this dump reveals confidential information. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1459 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1460 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1461 | /* TODO: dump unknown msgs to file, so user can send them to me |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1462 | * if they wish, to help add support for new messages (inspired |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1463 | * by Alexandr Shutko, who maintains OSCAR protocol documentation). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1464 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1465 | purple_debug_info("msim", "Unrecognized data on account for %s\n", |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1466 | session->account->username ? session->account->username |
|
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1467 | : "(NULL)"); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1468 | if (note) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1469 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1470 | purple_debug_info("msim", "(Note: %s)\n", note); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1471 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1472 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1473 | if (msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1474 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1475 | msim_msg_dump("Unrecognized message dump: %s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1476 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1477 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1478 | |
|
18052
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1479 | /** Process an incoming zap. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1480 | static gboolean |
|
18052
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1481 | msim_incoming_zap(MsimSession *session, MsimMessage *msg) |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1482 | { |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1483 | gchar *msg_text, *username, *zap_text; |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1484 | gint zap; |
|
18053
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
1485 | const gchar *zap_past_tense[10]; |
|
18052
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1486 | |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1487 | zap_past_tense[0] = _("zapped"); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1488 | zap_past_tense[1] = _("whacked"); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1489 | zap_past_tense[2] = _("torched"); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1490 | zap_past_tense[3] = _("smooched"); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1491 | zap_past_tense[4] = _("hugged"); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1492 | zap_past_tense[5] = _("bslapped"); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1493 | zap_past_tense[6] = _("goosed"); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1494 | zap_past_tense[7] = _("hi-fived"); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1495 | zap_past_tense[8] = _("punk'd"); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1496 | zap_past_tense[9] = _("raspberried"); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1497 | |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1498 | msg_text = msim_msg_get_string(msg, "msg"); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1499 | username = msim_msg_get_string(msg, "_username"); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1500 | |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1501 | g_return_val_if_fail(msg_text != NULL, FALSE); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1502 | g_return_val_if_fail(username != NULL, FALSE); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1503 | |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1504 | g_return_val_if_fail(sscanf(msg_text, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", &zap) == 1, FALSE); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1505 | |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1506 | zap = CLAMP(zap, 0, sizeof(zap_past_tense) / sizeof(zap_past_tense[0])); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1507 | |
|
18053
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
1508 | zap_text = g_strdup_printf(_("*** You have been %s! ***"), zap_past_tense[zap]); |
|
18052
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1509 | |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1510 | serv_got_im(session->gc, username, zap_text, |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1511 | PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1512 | |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1513 | g_free(zap_text); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1514 | g_free(msg_text); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1515 | g_free(username); |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1516 | |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1517 | return TRUE; |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1518 | } |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1519 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1520 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1521 | * Handle an incoming action message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1522 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1523 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1524 | * @param msg |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1525 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1526 | * @return TRUE if successful. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1527 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1528 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1529 | static gboolean |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1530 | msim_incoming_action(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1531 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1532 | gchar *msg_text, *username; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1533 | gboolean rc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1534 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1535 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1536 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1537 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1538 | msg_text = msim_msg_get_string(msg, "msg"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1539 | g_return_val_if_fail(msg_text != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1540 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1541 | username = msim_msg_get_string(msg, "_username"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1542 | g_return_val_if_fail(username != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1543 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1544 | purple_debug_info("msim", "msim_incoming_action: action <%s> from <%d>\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1545 | msg_text, username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1546 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1547 | if (strcmp(msg_text, "%typing%") == 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1548 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1549 | /* TODO: find out if msim repeatedly sends typing messages, so we can |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1550 | * give it a timeout. Right now, there does seem to be an inordinately |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1551 | * amount of time between typing stopped-typing notifications. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1552 | serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1553 | rc = TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1554 | } else if (strcmp(msg_text, "%stoptyping%") == 0) { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1555 | serv_got_typing_stopped(session->gc, username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1556 | rc = TRUE; |
|
18052
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1557 | } else if (strstr(msg_text, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_")) { |
|
49c29865fde5
Support incoming zaps.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18051
diff
changeset
|
1558 | rc = msim_incoming_zap(session, msg); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1559 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1560 | msim_unrecognized(session, msg, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1561 | "got to msim_incoming_action but unrecognized value for 'msg'"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1562 | rc = FALSE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1563 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1564 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1565 | g_free(msg_text); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1566 | g_free(username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1567 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1568 | return rc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1569 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1570 | |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1571 | /* Process an incoming media (buddy icon) message. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1572 | static gboolean |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1573 | msim_incoming_media(MsimSession *session, MsimMessage *msg) |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1574 | { |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1575 | gchar *username, *text; |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1576 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1577 | username = msim_msg_get_string(msg, "_username"); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1578 | text = msim_msg_get_string(msg, "msg"); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1579 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1580 | g_return_val_if_fail(username != NULL, FALSE); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1581 | g_return_val_if_fail(text != NULL, FALSE); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1582 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1583 | purple_debug_info("msim", "msim_incoming_media: from %s, got msg=%s\n", username, text); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1584 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1585 | /* Media messages are sent when the user opens a window to someone. |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1586 | * Tell libpurple they started typing and stopped typing, to inform the Psychic |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1587 | * Mode plugin so it too can open a window to the user. */ |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1588 | serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1589 | serv_got_typing_stopped(session->gc, username); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1590 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1591 | g_free(username); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1592 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1593 | return TRUE; |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1594 | } |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1595 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1596 | /* Process an incoming "unofficial client" message. The plugin for |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1597 | * Miranda IM sends this message with the plugin information. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1598 | static gboolean |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1599 | msim_incoming_unofficial_client(MsimSession *session, MsimMessage *msg) |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1600 | { |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1601 | PurpleBuddy *buddy; |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1602 | gchar *username, *client_info; |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1603 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1604 | username = msim_msg_get_string(msg, "_username"); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1605 | client_info = msim_msg_get_string(msg, "msg"); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1606 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1607 | g_return_val_if_fail(username != NULL, FALSE); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1608 | g_return_val_if_fail(client_info != NULL, FALSE); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1609 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1610 | purple_debug_info("msim", "msim_incoming_unofficial_client: %s is using client %s\n", |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1611 | username, client_info); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1612 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1613 | buddy = purple_find_buddy(session->account, username); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1614 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1615 | g_return_val_if_fail(buddy != NULL, FALSE); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1616 | |
|
18062
c903259e0c83
Store 3rd-party client name/version and official client build version (cv) separately.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18061
diff
changeset
|
1617 | purple_blist_node_remove_setting(&buddy->node, "client"); |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1618 | purple_blist_node_set_string(&buddy->node, "client", client_info); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1619 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1620 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1621 | g_free(username); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1622 | /* Do not free client_info - the blist now owns it. */ |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1623 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1624 | return TRUE; |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1625 | } |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1626 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1627 | |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1628 | #ifdef MSIM_SEND_CLIENT_VERSION |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1629 | /** Send our client version to another unofficial client that understands it. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1630 | static gboolean |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1631 | msim_send_unofficial_client(MsimSession *session, gchar *username) |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1632 | { |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1633 | gchar *our_info; |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1634 | gboolean ret; |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1635 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1636 | our_info = g_strdup_printf("Libpurple %d.%d.%d - msimprpl %s", |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1637 | PURPLE_MAJOR_VERSION, |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1638 | PURPLE_MINOR_VERSION, |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1639 | PURPLE_MICRO_VERSION, |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1640 | MSIM_PRPL_VERSION_STRING); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1641 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1642 | ret = msim_send_bm(session, username, our_info, MSIM_BM_UNOFFICIAL_CLIENT); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1643 | |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1644 | return ret; |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1645 | } |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1646 | #endif |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1647 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1648 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1649 | * Handle when our user starts or stops typing to another user. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1650 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1651 | * @param gc |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1652 | * @param name The buddy name to which our user is typing to |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1653 | * @param state PURPLE_TYPING, PURPLE_TYPED, PURPLE_NOT_TYPING |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1654 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1655 | * @return 0 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1656 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1657 | unsigned int |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1658 | msim_send_typing(PurpleConnection *gc, const gchar *name, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1659 | PurpleTypingState state) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1660 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1661 | const gchar *typing_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1662 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1663 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1664 | g_return_val_if_fail(gc != NULL, 0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1665 | g_return_val_if_fail(name != NULL, 0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1666 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1667 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1668 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1669 | g_return_val_if_fail(MSIM_SESSION_VALID(session), 0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1670 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1671 | switch (state) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1672 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1673 | case PURPLE_TYPING: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1674 | typing_str = "%typing%"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1675 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1676 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1677 | case PURPLE_TYPED: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1678 | case PURPLE_NOT_TYPING: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1679 | default: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1680 | typing_str = "%stoptyping%"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1681 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1682 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1683 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1684 | purple_debug_info("msim", "msim_send_typing(%s): %d (%s)\n", name, state, typing_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1685 | msim_send_bm(session, name, typing_str, MSIM_BM_ACTION); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1686 | return 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1687 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1688 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1689 | /** Callback for msim_get_info(), for when user info is received. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1690 | static void |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1691 | msim_get_info_cb(MsimSession *session, MsimMessage *user_info_msg, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1692 | gpointer data) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1693 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1694 | GHashTable *body; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1695 | gchar *body_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1696 | MsimMessage *msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1697 | gchar *user; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1698 | PurpleNotifyUserInfo *user_info; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1699 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1700 | const gchar *str, *str2; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1701 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1702 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1703 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1704 | /* Get user{name,id} from msim_get_info, passed as an MsimMessage for |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1705 | orthogonality. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1706 | msg = (MsimMessage *)data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1707 | g_return_if_fail(msg != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1708 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1709 | user = msim_msg_get_string(msg, "user"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1710 | if (!user) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1711 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1712 | purple_debug_info("msim", "msim_get_info_cb: no 'user' in msg"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1713 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1714 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1715 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1716 | msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1717 | purple_debug_info("msim", "msim_get_info_cb: got for user: %s\n", user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1718 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1719 | body_str = msim_msg_get_string(user_info_msg, "body"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1720 | g_return_if_fail(body_str != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1721 | body = msim_parse_body(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1722 | g_free(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1723 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1724 | buddy = purple_find_buddy(session->account, user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1725 | /* Note: don't assume buddy is non-NULL; will be if lookup random user |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1726 | * not on blist. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1727 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1728 | user_info = purple_notify_user_info_new(); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1729 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1730 | /* Identification */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1731 | purple_notify_user_info_add_pair(user_info, _("User"), user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1732 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1733 | /* note: g_hash_table_lookup does not create a new string! */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1734 | str = g_hash_table_lookup(body, "UserID"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1735 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1736 | purple_notify_user_info_add_pair(user_info, _("User ID"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1737 | g_strdup(str)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1738 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1739 | /* a/s/l...the vitals */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1740 | str = g_hash_table_lookup(body, "Age"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1741 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1742 | purple_notify_user_info_add_pair(user_info, _("Age"), g_strdup(str)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1743 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1744 | str = g_hash_table_lookup(body, "Gender"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1745 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1746 | purple_notify_user_info_add_pair(user_info, _("Gender"), g_strdup(str)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1747 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1748 | str = g_hash_table_lookup(body, "Location"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1749 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1750 | purple_notify_user_info_add_pair(user_info, _("Location"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1751 | g_strdup(str)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1752 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1753 | /* Other information */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1754 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1755 | if (buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1756 | { |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1757 | /* Headline comes from buddy status messages */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1758 | str = purple_blist_node_get_string(&buddy->node, "Headline"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1759 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1760 | purple_notify_user_info_add_pair(user_info, "Headline", str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1761 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1762 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1763 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1764 | str = g_hash_table_lookup(body, "BandName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1765 | str2 = g_hash_table_lookup(body, "SongName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1766 | if (str || str2) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1767 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1768 | purple_notify_user_info_add_pair(user_info, _("Song"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1769 | g_strdup_printf("%s - %s", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1770 | str ? str : "Unknown Artist", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1771 | str2 ? str2 : "Unknown Song")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1772 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1773 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1774 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1775 | /* Total friends only available if looked up by uid, not username. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1776 | str = g_hash_table_lookup(body, "TotalFriends"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1777 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1778 | purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1779 | g_strdup(str)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1780 | |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1781 | if (buddy) |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1782 | { |
|
18062
c903259e0c83
Store 3rd-party client name/version and official client build version (cv) separately.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18061
diff
changeset
|
1783 | gint cv; |
|
c903259e0c83
Store 3rd-party client name/version and official client build version (cv) separately.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18061
diff
changeset
|
1784 | |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1785 | str = purple_blist_node_get_string(&buddy->node, "client"); |
|
18062
c903259e0c83
Store 3rd-party client name/version and official client build version (cv) separately.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18061
diff
changeset
|
1786 | cv = purple_blist_node_get_int(&buddy->node, "client_cv"); |
|
c903259e0c83
Store 3rd-party client name/version and official client build version (cv) separately.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18061
diff
changeset
|
1787 | |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1788 | if (str) |
|
18062
c903259e0c83
Store 3rd-party client name/version and official client build version (cv) separately.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18061
diff
changeset
|
1789 | { |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1790 | purple_notify_user_info_add_pair(user_info, _("Client Version"), |
|
18062
c903259e0c83
Store 3rd-party client name/version and official client build version (cv) separately.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18061
diff
changeset
|
1791 | g_strdup_printf("%s (build %d)", str, cv)); |
|
c903259e0c83
Store 3rd-party client name/version and official client build version (cv) separately.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18061
diff
changeset
|
1792 | } |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1793 | } |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
1794 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1795 | purple_notify_userinfo(session->gc, user, user_info, NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1796 | purple_debug_info("msim", "msim_get_info_cb: username=%s\n", user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1797 | //purple_notify_user_info_destroy(user_info); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1798 | /* Do not free username, since it will be used by user_info. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1799 | |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
1800 | g_hash_table_destroy(body); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1801 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1802 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1803 | /** Retrieve a user's profile. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1804 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1805 | msim_get_info(PurpleConnection *gc, const gchar *user) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1806 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1807 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1808 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1809 | guint uid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1810 | gchar *user_to_lookup; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1811 | MsimMessage *user_msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1812 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1813 | g_return_if_fail(gc != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1814 | g_return_if_fail(user != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1815 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1816 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1817 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1818 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1819 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1820 | /* Obtain uid of buddy. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1821 | buddy = purple_find_buddy(session->account, user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1822 | if (buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1823 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1824 | uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1825 | if (!uid) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1826 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1827 | PurpleNotifyUserInfo *user_info; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1828 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1829 | user_info = purple_notify_user_info_new(); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1830 | purple_notify_user_info_add_pair(user_info, NULL, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1831 | _("This buddy appears to not have a userid stored in the buddy list, can't look up. Is the user really on the buddy list?")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1832 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1833 | purple_notify_userinfo(session->gc, user, user_info, NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1834 | purple_notify_user_info_destroy(user_info); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1835 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1836 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1837 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1838 | user_to_lookup = g_strdup_printf("%d", uid); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1839 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1840 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1841 | /* Looking up buddy not on blist. Lookup by whatever user entered. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1842 | user_to_lookup = g_strdup(user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1843 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1844 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1845 | /* Pass the username to msim_get_info_cb(), because since we lookup |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1846 | * by userid, the userinfo message will only contain the uid (not |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1847 | * the username). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1848 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1849 | user_msg = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1850 | "user", MSIM_TYPE_STRING, g_strdup(user), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1851 | NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1852 | purple_debug_info("msim", "msim_get_info, setting up lookup, user=%s\n", user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1853 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1854 | msim_lookup_user(session, user_to_lookup, msim_get_info_cb, user_msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1855 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1856 | g_free(user_to_lookup); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1857 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1858 | |
|
18035
2c401f444456
Remove MSIM_FAKE_SELF_ONLINE option, since our own status is actually updated
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18034
diff
changeset
|
1859 | /** Set your status - callback for when user manually sets it. */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1860 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1861 | msim_set_status(PurpleAccount *account, PurpleStatus *status) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1862 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1863 | PurpleStatusType *type; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1864 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1865 | guint status_code; |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1866 | const gchar *statstring; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1867 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1868 | session = (MsimSession *)account->gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1869 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1870 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1871 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1872 | type = purple_status_get_type(status); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1873 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1874 | switch (purple_status_type_get_primitive(type)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1875 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1876 | case PURPLE_STATUS_AVAILABLE: |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1877 | purple_debug_info("msim", "msim_set_status: available (%d->%d)\n", PURPLE_STATUS_AVAILABLE, |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1878 | MSIM_STATUS_CODE_ONLINE); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1879 | status_code = MSIM_STATUS_CODE_ONLINE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1880 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1881 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1882 | case PURPLE_STATUS_INVISIBLE: |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1883 | purple_debug_info("msim", "msim_set_status: invisible (%d->%d)\n", PURPLE_STATUS_INVISIBLE, |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1884 | MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1885 | status_code = MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1886 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1887 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1888 | case PURPLE_STATUS_AWAY: |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1889 | purple_debug_info("msim", "msim_set_status: away (%d->%d)\n", PURPLE_STATUS_AWAY, |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1890 | MSIM_STATUS_CODE_AWAY); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1891 | status_code = MSIM_STATUS_CODE_AWAY; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1892 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1893 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1894 | default: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1895 | purple_debug_info("msim", "msim_set_status: unknown " |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1896 | "status interpreting as online"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1897 | status_code = MSIM_STATUS_CODE_ONLINE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1898 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1899 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1900 | |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1901 | statstring = purple_status_get_attr_string(status, "message"); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1902 | |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1903 | if (!statstring) |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1904 | statstring = g_strdup(""); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1905 | |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1906 | msim_set_status_code(session, status_code, g_strdup(statstring)); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1907 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1908 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1909 | /** Go idle. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1910 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1911 | msim_set_idle(PurpleConnection *gc, int time) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1912 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1913 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1914 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1915 | g_return_if_fail(gc != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1916 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1917 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1918 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1919 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1920 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1921 | if (time == 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1922 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1923 | /* Going back from idle. In msim, idle is mutually exclusive |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1924 | * from the other states (you can only be away or idle, but not |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1925 | * both, for example), so by going non-idle I go online. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1926 | */ |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1927 | /* TODO: find out how to keep old status string? */ |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1928 | msim_set_status_code(session, MSIM_STATUS_CODE_ONLINE, g_strdup("")); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1929 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1930 | /* msim doesn't support idle time, so just go idle */ |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1931 | msim_set_status_code(session, MSIM_STATUS_CODE_IDLE, g_strdup("")); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1932 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1933 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1934 | |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1935 | /** Set status using an MSIM_STATUS_CODE_* value. |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1936 | * @param status_code An MSIM_STATUS_CODE_* value. |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1937 | * @param statstring Status string, must be a dynamic string (will be freed by msim_send). |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1938 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
1939 | static void |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1940 | msim_set_status_code(MsimSession *session, guint status_code, gchar *statstring) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1941 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1942 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
1943 | g_return_if_fail(statstring != NULL); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1944 | |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1945 | purple_debug_info("msim", "msim_set_status_code: going to set status to code=%d,str=%s\n", |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1946 | status_code, statstring); |
|
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1947 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1948 | if (!msim_send(session, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1949 | "status", MSIM_TYPE_INTEGER, status_code, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1950 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
1951 | "statstring", MSIM_TYPE_STRING, statstring, |
|
18029
48e7b6d97f1f
Fix compile warnings on Unix (missing sentinel and time_t to int typecast).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18028
diff
changeset
|
1952 | "locstring", MSIM_TYPE_STRING, g_strdup(""), |
|
48e7b6d97f1f
Fix compile warnings on Unix (missing sentinel and time_t to int typecast).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18028
diff
changeset
|
1953 | NULL)) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1954 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1955 | purple_debug_info("msim", "msim_set_status: failed to set status"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1956 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1957 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1958 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1959 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1960 | /** After a uid is resolved to username, tag it with the username and submit for processing. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1961 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1962 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1963 | * @param userinfo Response messsage to resolving request. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1964 | * @param data MsimMessage *, the message to attach information to. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1965 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1966 | static void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1967 | msim_incoming_resolved(MsimSession *session, MsimMessage *userinfo, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1968 | gpointer data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1969 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1970 | gchar *body_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1971 | GHashTable *body; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1972 | gchar *username; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1973 | MsimMessage *msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1974 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1975 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1976 | g_return_if_fail(userinfo != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1977 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1978 | body_str = msim_msg_get_string(userinfo, "body"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1979 | g_return_if_fail(body_str != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1980 | body = msim_parse_body(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1981 | g_return_if_fail(body != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1982 | g_free(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1983 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1984 | username = g_hash_table_lookup(body, "UserName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1985 | g_return_if_fail(username != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1986 | |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
1987 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1988 | msg = (MsimMessage *)data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1989 | g_return_if_fail(msg != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1990 | |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
1991 | /* TODO: more elegant solution than below. attach whole message? */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1992 | /* Special elements name beginning with '_', we'll use internally within the |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
1993 | * program (did not come directly from the wire). */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1994 | msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
1995 | |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
1996 | /* TODO: attach more useful information, like ImageURL */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1997 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1998 | msim_process(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
1999 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2000 | /* TODO: Free copy cloned from msim_preprocess_incoming(). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2001 | //XXX msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2002 | g_hash_table_destroy(body); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2003 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2004 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2005 | #if 0 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2006 | /* Lookup a username by userid, from buddy list. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2007 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2008 | * @param wanted_uid |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2009 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2010 | * @return Username of wanted_uid, if on blist, or NULL. Static string. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2011 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2012 | * XXX WARNING: UNKNOWN MEMORY CORRUPTION HERE! |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2013 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2014 | static const gchar * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2015 | msim_uid2username_from_blist(MsimSession *session, guint wanted_uid) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2016 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2017 | GSList *buddies, *cur; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2018 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2019 | buddies = purple_find_buddies(session->account, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2020 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2021 | if (!buddies) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2022 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2023 | purple_debug_info("msim", "msim_uid2username_from_blist: no buddies?"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2024 | return NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2025 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2026 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2027 | for (cur = buddies; cur != NULL; cur = g_slist_next(cur)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2028 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2029 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2030 | //PurpleBlistNode *node; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2031 | guint uid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2032 | const gchar *name; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2033 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2034 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2035 | /* See finch/gnthistory.c */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2036 | buddy = cur->data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2037 | //node = cur->data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2038 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2039 | uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2040 | //uid = purple_blist_node_get_int(node, "UserID"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2041 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2042 | /* name = buddy->name; */ /* crash */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2043 | /* name = PURPLE_BLIST_NODE_NAME(&buddy->node); */ /* crash */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2044 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2045 | /* XXX Is this right? Memory corruption here somehow. Happens only |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2046 | * when return one of these values. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2047 | name = purple_buddy_get_name(buddy); /* crash */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2048 | //name = purple_buddy_get_name((PurpleBuddy *)node); /* crash */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2049 | /* return name; */ /* crash (with above) */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2050 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2051 | /* name = NULL; */ /* no crash */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2052 | /* return NULL; */ /* no crash (with anything) */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2053 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2054 | /* crash = |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2055 | *** glibc detected *** pidgin: realloc(): invalid pointer: 0x0000000000d2aec0 *** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2056 | ======= Backtrace: ========= |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2057 | /lib/libc.so.6(__libc_realloc+0x323)[0x2b7bfc012e03] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2058 | /usr/lib/libglib-2.0.so.0(g_realloc+0x31)[0x2b7bfba79a41] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2059 | /usr/lib/libgtk-x11-2.0.so.0(gtk_tree_path_append_index+0x3a)[0x2b7bfa110d5a] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2060 | /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa1287dc] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2061 | /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128e56] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2062 | /usr/lib/libgtk-x11-2.0.so.0[0x2b7bfa128efd] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2063 | /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x1b4)[0x2b7bfba72c84] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2064 | /usr/lib/libglib-2.0.so.0[0x2b7bfba75acd] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2065 | /usr/lib/libglib-2.0.so.0(g_main_loop_run+0x1ca)[0x2b7bfba75dda] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2066 | /usr/lib/libgtk-x11-2.0.so.0(gtk_main+0xa3)[0x2b7bfa0475f3] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2067 | pidgin(main+0x8be)[0x46b45e] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2068 | /lib/libc.so.6(__libc_start_main+0xf4)[0x2b7bfbfbf0c4] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2069 | pidgin(gtk_widget_grab_focus+0x39)[0x429ab9] |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2070 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2071 | or: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2072 | *** glibc detected *** /usr/local/bin/pidgin: malloc(): memory corruption (fast): 0x0000000000c10076 *** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2073 | (gdb) bt |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2074 | #0 0x00002b4074ecd47b in raise () from /lib/libc.so.6 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2075 | #1 0x00002b4074eceda0 in abort () from /lib/libc.so.6 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2076 | #2 0x00002b4074f0453b in __fsetlocking () from /lib/libc.so.6 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2077 | #3 0x00002b4074f0c810 in free () from /lib/libc.so.6 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2078 | #4 0x00002b4074f0d6dd in malloc () from /lib/libc.so.6 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2079 | #5 0x00002b4074974b5b in g_malloc () from /usr/lib/libglib-2.0.so.0 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2080 | #6 0x00002b40749868bf in g_strdup () from /usr/lib/libglib-2.0.so.0 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2081 | #7 0x00002b407810969f in msim_parse ( |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2082 | raw=0xd2a910 "\\bm\\100\\f\\3656574\\msg\\|s|0|ss|Offline") |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2083 | at message.c:648 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2084 | #8 0x00002b407810889c in msim_input_cb (gc_uncasted=0xcf92c0, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2085 | source=<value optimized out>, cond=<value optimized out>) at myspace.c:1478 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2086 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2087 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2088 | Why is it crashing in msim_parse()'s g_strdup()? |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2089 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2090 | purple_debug_info("msim", "msim_uid2username_from_blist: %s's uid=%d (want %d)\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2091 | name, uid, wanted_uid); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2092 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2093 | if (uid == wanted_uid) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2094 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2095 | gchar *ret; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2096 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2097 | ret = g_strdup(name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2098 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2099 | g_slist_free(buddies); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2100 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2101 | return ret; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2102 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2103 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2104 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2105 | g_slist_free(buddies); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2106 | return NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2107 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2108 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2109 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2110 | /** Preprocess incoming messages, resolving as needed, calling msim_process() when ready to process. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2111 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2112 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2113 | * @param msg MsimMessage *, freed by caller. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2114 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2115 | static gboolean |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2116 | msim_preprocess_incoming(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2117 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2118 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2119 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2120 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2121 | if (msim_msg_get(msg, "bm") && msim_msg_get(msg, "f")) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2122 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2123 | guint uid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2124 | const gchar *username; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2125 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2126 | /* 'f' = userid message is from, in buddy messages */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2127 | uid = msim_msg_get_integer(msg, "f"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2128 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2129 | /* TODO: Make caching work. Currently it is commented out because |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2130 | * it crashes for unknown reasons, memory realloc error. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2131 | #if 0 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2132 | username = msim_uid2username_from_blist(session, uid); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2133 | #else |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2134 | username = NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2135 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2136 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2137 | if (username) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2138 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2139 | /* Know username already, use it. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2140 | purple_debug_info("msim", "msim_preprocess_incoming: tagging with _username=%s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2141 | username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2142 | msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2143 | return msim_process(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2144 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2145 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2146 | gchar *from; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2147 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2148 | /* Send lookup request. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2149 | /* XXX: where is msim_msg_get_string() freed? make _strdup and _nonstrdup. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2150 | purple_debug_info("msim", "msim_incoming: sending lookup, setting up callback\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2151 | from = msim_msg_get_string(msg, "f"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2152 | msim_lookup_user(session, from, msim_incoming_resolved, msim_msg_clone(msg)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2153 | g_free(from); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2154 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2155 | /* indeterminate */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2156 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2157 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2158 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2159 | /* Nothing to resolve - send directly to processing. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2160 | return msim_process(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2161 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2162 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2163 | |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2164 | #ifdef MSIM_USE_KEEPALIVE |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2165 | /** Check if the connection is still alive, based on last communication. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2166 | static gboolean |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2167 | msim_check_alive(gpointer data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2168 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2169 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2170 | time_t delta; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2171 | gchar *errmsg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2172 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2173 | session = (MsimSession *)data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2174 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2175 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2176 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2177 | delta = time(NULL) - session->last_comm; |
|
18036
532aa29d4dda
Support font sizes in sending and receiving formatted text.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18035
diff
changeset
|
2178 | //purple_debug_info("msim", "msim_check_alive: delta=%d\n", delta); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2179 | if (delta >= MSIM_KEEPALIVE_INTERVAL) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2180 | { |
|
18029
48e7b6d97f1f
Fix compile warnings on Unix (missing sentinel and time_t to int typecast).
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18028
diff
changeset
|
2181 | errmsg = g_strdup_printf(_("Connection to server lost (no data received within %d seconds)"), (int)delta); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2182 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2183 | purple_debug_info("msim", "msim_check_alive: %s > interval of %d, presumed dead\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2184 | errmsg, MSIM_KEEPALIVE_INTERVAL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2185 | purple_connection_error(session->gc, errmsg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2186 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2187 | purple_notify_error(session->gc, NULL, errmsg, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2188 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2189 | g_free(errmsg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2190 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2191 | return FALSE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2192 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2193 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2194 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2195 | } |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2196 | #endif |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2197 | |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2198 | /** Handle mail reply checks. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2199 | static void |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2200 | msim_check_inbox_cb(MsimSession *session, MsimMessage *reply, gpointer data) |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2201 | { |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2202 | GHashTable *body; |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2203 | gchar *body_str; |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2204 | GString *notification; |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2205 | guint old_inbox_status; |
|
18040
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2206 | guint i, n; |
|
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2207 | const gchar *froms[5], *tos[5], *urls[5], *subjects[5]; |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2208 | |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2209 | /* Three parallel arrays for each new inbox message type. */ |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2210 | static const gchar *inbox_keys[] = |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2211 | { |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2212 | "Mail", |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2213 | "BlogComment", |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2214 | "ProfileComment", |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2215 | "FriendRequest", |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2216 | "PictureComment" |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2217 | }; |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2218 | |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2219 | static const guint inbox_bits[] = |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2220 | { |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2221 | MSIM_INBOX_MAIL, |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2222 | MSIM_INBOX_BLOG_COMMENT, |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2223 | MSIM_INBOX_PROFILE_COMMENT, |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2224 | MSIM_INBOX_FRIEND_REQUEST, |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2225 | MSIM_INBOX_PICTURE_COMMENT |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2226 | }; |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2227 | |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2228 | static const gchar *inbox_urls[] = |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2229 | { |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2230 | "http://messaging.myspace.com/index.cfm?fuseaction=mail.inbox", |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2231 | "http://blog.myspace.com/index.cfm?fuseaction=blog", |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2232 | "http://home.myspace.com/index.cfm?fuseaction=user", |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2233 | "http://messaging.myspace.com/index.cfm?fuseaction=mail.friendRequests", |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2234 | "http://home.myspace.com/index.cfm?fuseaction=user" |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2235 | }; |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2236 | |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2237 | static const gchar *inbox_text[5]; |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2238 | |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2239 | /* Can't write _()'d strings in array initializers. Workaround. */ |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2240 | inbox_text[0] = _("New mail messages"); |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2241 | inbox_text[1] = _("New blog comments"); |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2242 | inbox_text[2] = _("New profile comments"); |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2243 | inbox_text[3] = _("New friend requests!"); |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2244 | inbox_text[4] = _("New picture comments"); |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2245 | |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2246 | g_return_if_fail(reply != NULL); |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2247 | |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2248 | msim_msg_dump("msim_check_inbox_cb: reply=%s\n", reply); |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2249 | |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2250 | body_str = msim_msg_get_string(reply, "body"); |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2251 | g_return_if_fail(body_str != NULL); |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2252 | |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2253 | body = msim_parse_body(body_str); |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2254 | g_free(body_str); |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2255 | |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2256 | notification = g_string_new(""); |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2257 | |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2258 | old_inbox_status = session->inbox_status; |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2259 | |
|
18040
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2260 | n = 0; |
|
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2261 | |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2262 | for (i = 0; i < sizeof(inbox_keys) / sizeof(inbox_keys[0]); ++i) |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2263 | { |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2264 | const gchar *key; |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2265 | guint bit; |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2266 | |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2267 | key = inbox_keys[i]; |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2268 | bit = inbox_bits[i]; |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2269 | |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2270 | if (g_hash_table_lookup(body, key)) |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2271 | { |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2272 | /* Notify only on when _changes_ from no mail -> has mail |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2273 | * (edge triggered) */ |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2274 | if (!(session->inbox_status & bit)) |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2275 | { |
|
18040
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2276 | purple_debug_info("msim", "msim_check_inbox_cb: got %s, at %d\n", |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
2277 | key ? key : "(NULL)", n); |
|
18040
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2278 | |
|
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2279 | subjects[n] = inbox_text[i]; |
|
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2280 | froms[n] = _("MySpace"); |
|
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2281 | tos[n] = session->username; |
|
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2282 | /* TODO: append token, web challenge, so automatically logs in. |
|
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2283 | * Would also need to free strings because they won't be static |
|
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2284 | */ |
|
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2285 | urls[n] = inbox_urls[i]; |
|
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2286 | |
|
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2287 | ++n; |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2288 | } else { |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2289 | purple_debug_info("msim", |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2290 | "msim_check_inbox_cb: already notified of %s\n", |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
2291 | key ? key : "(NULL)"); |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2292 | } |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2293 | |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2294 | session->inbox_status |= bit; |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2295 | } |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2296 | } |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2297 | |
|
18040
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2298 | if (n) |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2299 | { |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2300 | purple_debug_info("msim", |
|
18040
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2301 | "msim_check_inbox_cb: notifying of %d\n", n); |
|
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2302 | |
|
e6993fff1e1a
Use the much nicer purple_notify_emails() API to notify of new inbox messages,
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18038
diff
changeset
|
2303 | /* TODO: free strings with callback _if_ change to dynamic (w/ token) */ |
|
18063
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
2304 | purple_notify_emails(session->gc, /* handle */ |
|
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
2305 | n, /* count */ |
|
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
2306 | TRUE, /* detailed */ |
|
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
2307 | subjects, froms, tos, urls, |
|
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
2308 | NULL, /* PurpleNotifyCloseCallback cb */ |
|
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
2309 | NULL); /* gpointer user_data */ |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2310 | |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2311 | } |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2312 | |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2313 | g_hash_table_destroy(body); |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2314 | } |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2315 | |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2316 | /* Send request to check if there is new mail. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2317 | static gboolean |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2318 | msim_check_inbox(gpointer data) |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2319 | { |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2320 | MsimSession *session; |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2321 | |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2322 | session = (MsimSession *)data; |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2323 | |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2324 | purple_debug_info("msim", "msim_check_inbox: checking mail\n"); |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2325 | g_return_val_if_fail(msim_send(session, |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2326 | "persist", MSIM_TYPE_INTEGER, 1, |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2327 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2328 | "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_GET, |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2329 | "dsn", MSIM_TYPE_INTEGER, MG_CHECK_MAIL_DSN, |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2330 | "lid", MSIM_TYPE_INTEGER, MG_CHECK_MAIL_LID, |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2331 | "uid", MSIM_TYPE_INTEGER, session->userid, |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2332 | "rid", MSIM_TYPE_INTEGER, |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2333 | msim_new_reply_callback(session, msim_check_inbox_cb, NULL), |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2334 | "body", MSIM_TYPE_STRING, g_strdup(""), |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2335 | NULL), TRUE); |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2336 | |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2337 | /* Always return true, so that we keep checking for mail. */ |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2338 | return TRUE; |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2339 | } |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2340 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2341 | /** Called when the session key arrives. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2342 | static gboolean |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2343 | msim_we_are_logged_on(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2344 | { |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2345 | MsimMessage *body; |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2346 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2347 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2348 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2349 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2350 | purple_connection_update_progress(session->gc, _("Connected"), 3, 4); |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2351 | purple_connection_set_state(session->gc, PURPLE_CONNECTED); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2352 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2353 | session->sesskey = msim_msg_get_integer(msg, "sesskey"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2354 | purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2355 | |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2356 | /* What is proof? Used to be uid, but now is 52 base64'd bytes... */ |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2357 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2358 | /* Comes with: proof,profileid,userid,uniquenick -- all same values |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2359 | * some of the time, but can vary. This is our own user ID. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2360 | session->userid = msim_msg_get_integer(msg, "userid"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2361 | |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2362 | /* Not sure what profileid is used for. */ |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2363 | if (msim_msg_get_integer(msg, "profileid") != session->userid) |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2364 | { |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2365 | msim_unrecognized(session, msg, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2366 | "Profile ID didn't match user ID, don't know why"); |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2367 | } |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2368 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2369 | /* We now know are our own username, only after we're logged in.. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2370 | * which is weird, but happens because you login with your email |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2371 | * address and not username. Will be freed in msim_session_destroy(). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2372 | session->username = msim_msg_get_string(msg, "uniquenick"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2373 | |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2374 | if (msim_msg_get_integer(msg, "uniquenick") == session->userid) |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2375 | { |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2376 | purple_debug_info("msim_we_are_logged_on", "TODO: pick username"); |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2377 | } |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2378 | |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2379 | body = msim_msg_new(TRUE, |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2380 | "UserID", MSIM_TYPE_INTEGER, session->userid, |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2381 | NULL); |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2382 | |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2383 | /* Request IM info about ourself. */ |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2384 | msim_send(session, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2385 | "persist", MSIM_TYPE_STRING, g_strdup("persist"), |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2386 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2387 | "dsn", MSIM_TYPE_INTEGER, MG_OWN_MYSPACE_INFO_DSN, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2388 | "uid", MSIM_TYPE_INTEGER, session->userid, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2389 | "lid", MSIM_TYPE_INTEGER, MG_OWN_MYSPACE_INFO_LID, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2390 | "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2391 | "body", MSIM_TYPE_DICTIONARY, body, |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2392 | NULL); |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2393 | |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2394 | /* Request MySpace info about ourself. */ |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2395 | msim_send(session, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2396 | "persist", MSIM_TYPE_STRING, g_strdup("persist"), |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2397 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2398 | "dsn", MSIM_TYPE_INTEGER, MG_OWN_IM_INFO_DSN, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2399 | "uid", MSIM_TYPE_INTEGER, session->userid, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2400 | "lid", MSIM_TYPE_INTEGER, MG_OWN_IM_INFO_LID, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2401 | "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2402 | "body", MSIM_TYPE_STRING, g_strdup(""), |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2403 | NULL); |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2404 | |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2405 | /* TODO: set options (persist cmd=514,dsn=1,lid=10) */ |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2406 | /* TODO: set blocklist */ |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2407 | |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2408 | /* Notify servers of our current status. */ |
|
18034
e1b21d1e5c7a
Allow setting status string messages. Known bug: custom status messages always
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18032
diff
changeset
|
2409 | purple_debug_info("msim", "msim_we_are_logged_on: notifying servers of status\n"); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2410 | msim_set_status(session->account, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2411 | purple_account_get_active_status(session->account)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2412 | |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2413 | /* TODO: setinfo */ |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2414 | /* |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2415 | body = msim_msg_new(TRUE, |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2416 | "TotalFriends", MSIM_TYPE_INTEGER, 666, |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2417 | NULL); |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2418 | msim_send(session, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2419 | "setinfo", MSIM_TYPE_BOOLEAN, TRUE, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2420 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2421 | "info", MSIM_TYPE_DICTIONARY, body, |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2422 | NULL); |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2423 | */ |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2424 | |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2425 | /* Disable due to problems with timeouts. TODO: fix. */ |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2426 | #ifdef MSIM_USE_KEEPALIVE |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2427 | purple_timeout_add(MSIM_KEEPALIVE_INTERVAL_CHECK, |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2428 | (GSourceFunc)msim_check_alive, session); |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2429 | #endif |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2430 | |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2431 | purple_timeout_add(MSIM_MAIL_INTERVAL_CHECK, |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2432 | (GSourceFunc)msim_check_inbox, session); |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2433 | |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
2434 | msim_check_inbox(session); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2435 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2436 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2437 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2438 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2439 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2440 | * Process a message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2441 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2442 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2443 | * @param msg A message from the server, ready for processing (possibly with resolved username information attached). Caller frees. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2444 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2445 | * @return TRUE if successful. FALSE if processing failed. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2446 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2447 | static gboolean |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2448 | msim_process(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2449 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2450 | g_return_val_if_fail(session != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2451 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2452 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2453 | #ifdef MSIM_DEBUG_MSG |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2454 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2455 | msim_msg_dump("ready to process: %s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2456 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2457 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2458 | |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2459 | if (msim_msg_get_integer(msg, "lc") == 1) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2460 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2461 | return msim_login_challenge(session, msg); |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2462 | } else if (msim_msg_get_integer(msg, "lc") == 2) { |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2463 | return msim_we_are_logged_on(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2464 | } else if (msim_msg_get(msg, "bm")) { |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
2465 | return msim_incoming_bm(session, msg); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2466 | } else if (msim_msg_get(msg, "rid")) { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2467 | return msim_process_reply(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2468 | } else if (msim_msg_get(msg, "error")) { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2469 | return msim_error(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2470 | } else if (msim_msg_get(msg, "ka")) { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2471 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2472 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2473 | msim_unrecognized(session, msg, "in msim_process"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2474 | return FALSE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2475 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2476 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2477 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2478 | /** Store an field of information about a buddy. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2479 | static void |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2480 | msim_store_buddy_info_each(gpointer key, gpointer value, gpointer user_data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2481 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2482 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2483 | gchar *key_str, *value_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2484 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2485 | buddy = (PurpleBuddy *)user_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2486 | key_str = (gchar *)key; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2487 | value_str = (gchar *)value; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2488 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2489 | if (strcmp(key_str, "UserID") == 0 || |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2490 | strcmp(key_str, "Age") == 0 || |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2491 | strcmp(key_str, "TotalFriends") == 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2492 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2493 | /* Certain fields get set as integers, instead of strings, for |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2494 | * convenience. May not be the best way to do it, but having at least |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2495 | * UserID as an integer is convenient...until it overflows! */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2496 | purple_blist_node_set_int(&buddy->node, key_str, atol(value_str)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2497 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2498 | purple_blist_node_set_string(&buddy->node, key_str, value_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2499 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2500 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2501 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2502 | /** Save buddy information to the buddy list from a user info reply message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2503 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2504 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2505 | * @param msg The user information reply, with any amount of information. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2506 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2507 | * The information is saved to the buddy's blist node, which ends up in blist.xml. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2508 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2509 | static gboolean |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2510 | msim_store_buddy_info(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2511 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2512 | GHashTable *body; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2513 | gchar *username, *body_str, *uid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2514 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2515 | guint rid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2516 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2517 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2518 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2519 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2520 | rid = msim_msg_get_integer(msg, "rid"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2521 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2522 | g_return_val_if_fail(rid != 0, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2523 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2524 | body_str = msim_msg_get_string(msg, "body"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2525 | g_return_val_if_fail(body_str != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2526 | body = msim_parse_body(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2527 | g_free(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2528 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2529 | /* TODO: implement a better hash-like interface, and use it. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2530 | username = g_hash_table_lookup(body, "UserName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2531 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2532 | if (!username) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2533 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2534 | purple_debug_info("msim", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2535 | "msim_process_reply: not caching body, no UserName\n"); |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2536 | g_hash_table_destroy(body); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2537 | return FALSE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2538 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2539 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2540 | uid = g_hash_table_lookup(body, "UserID"); |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2541 | if (!uid) |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2542 | { |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2543 | g_hash_table_destroy(body); |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2544 | g_return_val_if_fail(uid, FALSE); |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2545 | } |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2546 | |
|
18044
06152cc939ef
Increase read buffer size and be more careful about overruns.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18043
diff
changeset
|
2547 | purple_debug_info("msim", "associating uid %s with username %s\n", uid, username); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2548 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2549 | buddy = purple_find_buddy(session->account, username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2550 | if (buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2551 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2552 | g_hash_table_foreach(body, msim_store_buddy_info_each, buddy); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2553 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2554 | |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2555 | if (msim_msg_get_integer(msg, "dsn") == MG_OWN_IM_INFO_DSN && |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2556 | msim_msg_get_integer(msg, "lid") == MG_OWN_IM_INFO_LID) |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2557 | { |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2558 | /* TODO: do something with our own IM info, if we need it for some |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2559 | * specific purpose. Otherwise it is available on the buddy list, |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2560 | * if the user has themselves as their own buddy. */ |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2561 | } else if (msim_msg_get_integer(msg, "dsn") == MG_OWN_MYSPACE_INFO_DSN && |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2562 | msim_msg_get_integer(msg, "lid") == MG_OWN_MYSPACE_INFO_LID) { |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2563 | /* TODO: same as above, but for MySpace info. */ |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2564 | } |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2565 | |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2566 | g_hash_table_destroy(body); |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
2567 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2568 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2569 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2570 | |
|
18056
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2571 | /** Process the initial server information from the server. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2572 | static gboolean |
|
18056
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2573 | msim_process_server_info(MsimSession *session, MsimMessage *msg) |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2574 | { |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2575 | gchar *body_str; |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2576 | GHashTable *body; |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2577 | |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2578 | body_str = msim_msg_get_string(msg, "body"); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2579 | g_return_val_if_fail(body_str != NULL, FALSE); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2580 | body = msim_parse_body(body_str); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2581 | g_free(body_str); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2582 | g_return_val_if_fail(body != NULL, FALSE); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2583 | |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2584 | /* Example body: |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2585 | AdUnitRefreshInterval=10. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2586 | AlertPollInterval=360. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2587 | AllowChatRoomEmoticonSharing=False. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2588 | ChatRoomUserIDs=78744676;163733130;1300326231;123521495;142663391. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2589 | CurClientVersion=673. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2590 | EnableIMBrowse=True. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2591 | EnableIMStuffAvatars=False. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2592 | EnableIMStuffZaps=False. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2593 | MaxAddAllFriends=100. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2594 | MaxContacts=1000. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2595 | MinClientVersion=594. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2596 | MySpaceIM_ENGLISH=78744676. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2597 | MySpaceNowTimer=720. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2598 | PersistenceDataTimeout=900. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2599 | UseWebChallenge=1. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2600 | WebTicketGoHome=False |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2601 | |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2602 | Anything useful? TODO: use what is useful, and use it. |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2603 | */ |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2604 | purple_debug_info("msim_process_server_info", |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
2605 | "maximum contacts: %s\n", |
|
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
2606 | g_hash_table_lookup(body, "MaxContacts") ? |
|
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
2607 | g_hash_table_lookup(body, "MaxContacts") : "(NULL)"); |
|
18056
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2608 | |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2609 | session->server_info = body; |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2610 | /* session->server_info freed in msim_session_destroy */ |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2611 | |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2612 | return TRUE; |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2613 | } |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2614 | |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2615 | /** Process a web challenge, used to login to the web site. */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2616 | static gboolean |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2617 | msim_web_challenge(MsimSession *session, MsimMessage *msg) |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2618 | { |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2619 | /* TODO: web challenge, store token */ |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2620 | return FALSE; |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2621 | } |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2622 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2623 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2624 | * Process a persistance message reply from the server. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2625 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2626 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2627 | * @param msg Message reply from server. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2628 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2629 | * @return TRUE if successful. |
|
18056
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2630 | * |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2631 | * msim_lookup_user sets callback for here |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2632 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2633 | static gboolean |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2634 | msim_process_reply(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2635 | { |
|
18056
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2636 | MSIM_USER_LOOKUP_CB cb; |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2637 | gpointer data; |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2638 | guint rid, cmd, dsn, lid; |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2639 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2640 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2641 | g_return_val_if_fail(msg != NULL, FALSE); |
|
18056
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2642 | |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2643 | msim_store_buddy_info(session, msg); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2644 | |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2645 | rid = msim_msg_get_integer(msg, "rid"); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2646 | cmd = msim_msg_get_integer(msg, "cmd"); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2647 | dsn = msim_msg_get_integer(msg, "dsn"); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2648 | lid = msim_msg_get_integer(msg, "lid"); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2649 | |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2650 | /* Unsolicited messages */ |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2651 | if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_GET)) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2652 | { |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2653 | if (dsn == MG_SERVER_INFO_DSN && lid == MG_SERVER_INFO_LID) |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2654 | { |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2655 | return msim_process_server_info(session, msg); |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2656 | } else if (dsn == MG_WEB_CHALLENGE_DSN && lid == MG_WEB_CHALLENGE_LID) { |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2657 | return msim_web_challenge(session, msg); |
|
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
2658 | } |
|
18056
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2659 | } |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2660 | |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2661 | /* If a callback is registered for this userid lookup, call it. */ |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2662 | cb = g_hash_table_lookup(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2663 | data = g_hash_table_lookup(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2664 | |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2665 | if (cb) |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2666 | { |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2667 | purple_debug_info("msim", |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2668 | "msim_process_body: calling callback now\n"); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2669 | /* Clone message, so that the callback 'cb' can use it (needs to free it also). */ |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2670 | cb(session, msim_msg_clone(msg), data); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2671 | g_hash_table_remove(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2672 | g_hash_table_remove(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2673 | } else { |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2674 | purple_debug_info("msim", |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
2675 | "msim_process_body: no callback for rid %d\n", rid); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2676 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2677 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2678 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2679 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2680 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2681 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2682 | * Handle an error from the server. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2683 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2684 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2685 | * @param msg The message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2686 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2687 | * @return TRUE if successfully reported error. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2688 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2689 | static gboolean |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2690 | msim_error(MsimSession *session, MsimMessage *msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2691 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2692 | gchar *errmsg, *full_errmsg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2693 | guint err; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2694 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2695 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2696 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2697 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2698 | err = msim_msg_get_integer(msg, "err"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2699 | errmsg = msim_msg_get_string(msg, "errmsg"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2700 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2701 | full_errmsg = g_strdup_printf(_("Protocol error, code %d: %s"), err, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2702 | errmsg ? errmsg : "no 'errmsg' given"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2703 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2704 | g_free(errmsg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2705 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2706 | purple_debug_info("msim", "msim_error: %s\n", full_errmsg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2707 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2708 | purple_notify_error(session->account, g_strdup(_("MySpaceIM Error")), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2709 | full_errmsg, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2710 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2711 | /* Destroy session if fatal. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2712 | if (msim_msg_get(msg, "fatal")) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2713 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2714 | purple_debug_info("msim", "fatal error, closing\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2715 | purple_connection_error(session->gc, full_errmsg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2716 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2717 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2718 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2719 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2720 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2721 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2722 | * Process incoming status messages. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2723 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2724 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2725 | * @param msg Status update message. Caller frees. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2726 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2727 | * @return TRUE if successful. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2728 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2729 | static gboolean |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
2730 | msim_incoming_status(MsimSession *session, MsimMessage *msg) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2731 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2732 | PurpleBuddyList *blist; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2733 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2734 | //PurpleStatus *status; |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2735 | //gchar **status_array; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2736 | GList *list; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2737 | gchar *status_headline; |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2738 | //gchar *status_str; |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2739 | //gint i; |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2740 | gint status_code, purple_status_code; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2741 | gchar *username; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2742 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2743 | g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2744 | g_return_val_if_fail(msg != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2745 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2746 | msim_msg_dump("msim_status msg=%s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2747 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2748 | /* Helpfully looked up by msim_incoming_resolve() for us. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2749 | username = msim_msg_get_string(msg, "_username"); |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2750 | g_return_val_if_fail(username != NULL, FALSE); |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2751 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2752 | { |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2753 | gchar *ss; |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2754 | |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2755 | ss = msim_msg_get_string(msg, "msg"); |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2756 | purple_debug_info("msim", |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2757 | "msim_status: updating status for <%s> to <%s>\n", |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
2758 | username, ss ? ss : "(NULL)"); |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2759 | g_free(ss); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2760 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2761 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2762 | /* Example fields: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2763 | * |s|0|ss|Offline |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2764 | * |s|1|ss|:-)|ls||ip|0|p|0 |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2765 | */ |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2766 | list = msim_msg_get_list(msg, "msg"); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2767 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2768 | status_code = atoi(g_list_nth_data(list, MSIM_STATUS_ORDINAL_ONLINE)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2769 | purple_debug_info("msim", "msim_status: %s's status code = %d\n", username, status_code); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2770 | status_headline = g_list_nth_data(list, MSIM_STATUS_ORDINAL_HEADLINE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2771 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2772 | blist = purple_get_blist(); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2773 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2774 | /* Add buddy if not found */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2775 | buddy = purple_find_buddy(session->account, username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2776 | if (!buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2777 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2778 | purple_debug_info("msim", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2779 | "msim_status: making new buddy for %s\n", username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2780 | buddy = purple_buddy_new(session->account, username, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2781 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2782 | purple_blist_add_buddy(buddy, NULL, NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2783 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2784 | /* All buddies on list should have 'uid' integer associated with them. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2785 | purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2786 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2787 | msim_store_buddy_info(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2788 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2789 | purple_debug_info("msim", "msim_status: found buddy %s\n", username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2790 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2791 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2792 | purple_blist_node_set_string(&buddy->node, "Headline", status_headline); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2793 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2794 | /* Set user status */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2795 | switch (status_code) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2796 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2797 | case MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2798 | purple_status_code = PURPLE_STATUS_OFFLINE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2799 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2800 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2801 | case MSIM_STATUS_CODE_ONLINE: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2802 | purple_status_code = PURPLE_STATUS_AVAILABLE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2803 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2804 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2805 | case MSIM_STATUS_CODE_AWAY: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2806 | purple_status_code = PURPLE_STATUS_AWAY; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2807 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2808 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2809 | case MSIM_STATUS_CODE_IDLE: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2810 | /* will be handled below */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2811 | purple_status_code = -1; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2812 | break; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2813 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2814 | default: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2815 | purple_debug_info("msim", "msim_status for %s, unknown status code %d, treating as available\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2816 | username, status_code); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2817 | purple_status_code = PURPLE_STATUS_AVAILABLE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2818 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2819 | |
|
18035
2c401f444456
Remove MSIM_FAKE_SELF_ONLINE option, since our own status is actually updated
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18034
diff
changeset
|
2820 | purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2821 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2822 | if (status_code == MSIM_STATUS_CODE_IDLE) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2823 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2824 | purple_debug_info("msim", "msim_status: got idle: %s\n", username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2825 | purple_prpl_got_user_idle(session->account, username, TRUE, time(NULL)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2826 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2827 | /* All other statuses indicate going back to non-idle. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2828 | purple_prpl_got_user_idle(session->account, username, FALSE, time(NULL)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2829 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2830 | |
|
18064
527bea0f11ab
Disable sending third-party client version to oncoming buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18063
diff
changeset
|
2831 | #ifdef MSIM_SEND_CLIENT_VERSION |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
2832 | if (status_code == MSIM_STATUS_CODE_ONLINE) |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
2833 | { |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
2834 | /* Secretly whisper to unofficial clients our own version as they come online */ |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
2835 | msim_send_unofficial_client(session, username); |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
2836 | } |
|
18064
527bea0f11ab
Disable sending third-party client version to oncoming buddies.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18063
diff
changeset
|
2837 | #endif |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
2838 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2839 | g_free(username); |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
2840 | msim_msg_list_free(list); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2841 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2842 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2843 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2844 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2845 | /** Add a buddy to user's buddy list. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2846 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2847 | msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2848 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2849 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2850 | MsimMessage *msg; |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2851 | MsimMessage *msg_blocklist; |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2852 | MsimMessage *body; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2853 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2854 | session = (MsimSession *)gc->proto_data; |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
2855 | purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n", |
|
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
2856 | buddy->name, (group && group->name) ? group->name : "(no group)"); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2857 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2858 | msg = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2859 | "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2860 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2861 | /* "newprofileid" will be inserted here with uid. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2862 | "reason", MSIM_TYPE_STRING, g_strdup(""), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2863 | NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2864 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2865 | if (!msim_postprocess_outgoing(session, msg, buddy->name, "newprofileid", "reason")) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2866 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2867 | purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed.")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2868 | msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2869 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2870 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2871 | msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2872 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2873 | /* TODO: if addbuddy fails ('error' message is returned), delete added buddy from |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2874 | * buddy list since Purple adds it locally. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2875 | |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2876 | body = msim_msg_new(TRUE, |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2877 | "ContactID", MSIM_TYPE_STRING, g_strdup("<uid>"), |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2878 | "GroupName", MSIM_TYPE_STRING, g_strdup(group->name), |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2879 | "Position", MSIM_TYPE_INTEGER, 1000, |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2880 | "Visibility", MSIM_TYPE_INTEGER, 1, |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2881 | "NickName", MSIM_TYPE_STRING, g_strdup(""), |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2882 | "NameSelect", MSIM_TYPE_INTEGER, 0, |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2883 | NULL); |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2884 | |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2885 | /* Update blocklist. */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2886 | msg_blocklist = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2887 | "persist", MSIM_TYPE_INTEGER, 1, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2888 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2889 | "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_PUT, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2890 | "dsn", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_DSN, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2891 | "lid", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_LID, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2892 | /* TODO: Use msim_new_reply_callback to get rid. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2893 | "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2894 | "body", MSIM_TYPE_DICTIONARY, body, |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2895 | NULL); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2896 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2897 | if (!msim_postprocess_outgoing(session, msg, buddy->name, "body", NULL)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2898 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2899 | purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2900 | msim_msg_free(msg_blocklist); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2901 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2902 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2903 | msim_msg_free(msg_blocklist); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2904 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2905 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2906 | /** Perform actual postprocessing on a message, adding userid as specified. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2907 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2908 | * @param msg The message to postprocess. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2909 | * @param uid_before Name of field where to insert new field before, or NULL for end. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2910 | * @param uid_field_name Name of field to add uid to. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2911 | * @param uid The userid to insert. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2912 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2913 | * If the field named by uid_field_name already exists, then its string contents will |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2914 | * be used for the field, except "<uid>" will be replaced by the userid. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2915 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2916 | * If the field named by uid_field_name does not exist, it will be added before the |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2917 | * field named by uid_before, as an integer, with the userid. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2918 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2919 | * Does not handle sending, or scheduling userid lookup. For that, see msim_postprocess_outgoing(). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2920 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2921 | static MsimMessage * |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2922 | msim_do_postprocessing(MsimMessage *msg, const gchar *uid_before, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2923 | const gchar *uid_field_name, guint uid) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2924 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2925 | msim_msg_dump("msim_do_postprocessing msg: %s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2926 | |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2927 | /* First, check - if the field already exists, replace <uid> within it */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2928 | if (msim_msg_get(msg, uid_field_name)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2929 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2930 | MsimMessageElement *elem; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2931 | gchar *fmt_string; |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2932 | gchar *uid_str, *new_str; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2933 | |
|
19137
fb04b5cf5817
Use a list when updating the blocklist when removing the buddy, since
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19135
diff
changeset
|
2934 | /* Warning: this is a delicate, but safe, operation */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2935 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2936 | elem = msim_msg_get(msg, uid_field_name); |
|
19137
fb04b5cf5817
Use a list when updating the blocklist when removing the buddy, since
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19135
diff
changeset
|
2937 | |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2938 | /* Get the packed element, flattening it. This allows <uid> to be |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2939 | * replaced within nested data structures, since the replacement is done |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2940 | * on the linear, packed data, not on a complicated data structure. |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2941 | * |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2942 | * For example, if the field was originally a dictionary or a list, you |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2943 | * would have to iterate over all the items in it to see what needs to |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2944 | * be replaced. But by packing it first, the <uid> marker is easily replaced |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2945 | * just by a string replacement. |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2946 | */ |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2947 | fmt_string = msim_msg_pack_element_data(elem); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2948 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2949 | uid_str = g_strdup_printf("%d", uid); |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2950 | new_str = str_replace(fmt_string, "<uid>", uid_str); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2951 | g_free(uid_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2952 | g_free(fmt_string); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2953 | |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2954 | /* Free the old element data */ |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2955 | msim_msg_free_element_data(elem->data); |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2956 | |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2957 | /* Replace it with our new data */ |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2958 | elem->data = new_str; |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2959 | elem->type = MSIM_TYPE_RAW; |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
2960 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2961 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2962 | /* Otherwise, insert new field into outgoing message. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2963 | msg = msim_msg_insert_before(msg, uid_before, uid_field_name, MSIM_TYPE_INTEGER, GUINT_TO_POINTER(uid)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2964 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2965 | |
|
19137
fb04b5cf5817
Use a list when updating the blocklist when removing the buddy, since
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19135
diff
changeset
|
2966 | msim_msg_dump("msim_postprocess_outgoing_cb: postprocessed msg=%s\n", msg); |
|
fb04b5cf5817
Use a list when updating the blocklist when removing the buddy, since
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19135
diff
changeset
|
2967 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2968 | return msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2969 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2970 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2971 | /** Callback for msim_postprocess_outgoing() to add a userid to a message, and send it (once receiving userid). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2972 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2973 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2974 | * @param userinfo The user information reply message, containing the user ID |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2975 | * @param data The message to postprocess and send. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2976 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2977 | * The data message should contain these fields: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2978 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2979 | * _uid_field_name: string, name of field to add with userid from userinfo message |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2980 | * _uid_before: string, name of field before field to insert, or NULL for end |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2981 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2982 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2983 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2984 | static void |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2985 | msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, |
|
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
2986 | gpointer data) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2987 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2988 | gchar *body_str; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2989 | GHashTable *body; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2990 | gchar *uid, *uid_field_name, *uid_before; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2991 | MsimMessage *msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2992 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2993 | msg = (MsimMessage *)data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2994 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2995 | msim_msg_dump("msim_postprocess_outgoing_cb() got msg=%s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2996 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2997 | /* Obtain userid from userinfo message. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2998 | body_str = msim_msg_get_string(userinfo, "body"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
2999 | g_return_if_fail(body_str != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3000 | body = msim_parse_body(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3001 | g_free(body_str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3002 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3003 | uid = g_strdup(g_hash_table_lookup(body, "UserID")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3004 | g_hash_table_destroy(body); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3005 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3006 | uid_field_name = msim_msg_get_string(msg, "_uid_field_name"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3007 | uid_before = msim_msg_get_string(msg, "_uid_before"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3008 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3009 | msg = msim_do_postprocessing(msg, uid_before, uid_field_name, atol(uid)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3010 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3011 | /* Send */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3012 | if (!msim_msg_send(session, msg)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3013 | { |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
3014 | msim_msg_dump("msim_postprocess_outgoing_cb: sending failed for message: %s\n", msg); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3015 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3016 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3017 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3018 | /* Free field names AFTER sending message, because MsimMessage does NOT copy |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3019 | * field names - instead, treats them as static strings (which they usually are). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3020 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3021 | g_free(uid_field_name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3022 | g_free(uid_before); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3023 | |
|
18037
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
3024 | g_hash_table_destroy(body); |
|
038a99b09d35
Add msim_check_mail to check for new mail (called periodically), and
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18036
diff
changeset
|
3025 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3026 | //msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3027 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3028 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3029 | /** Postprocess and send a message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3030 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3031 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3032 | * @param msg Message to postprocess. Will NOT be freed. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3033 | * @param username Username to resolve. Assumed to be a static string (will not be freed or copied). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3034 | * @param uid_field_name Name of new field to add, containing uid of username. Static string. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3035 | * @param uid_before Name of existing field to insert username field before. Static string. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3036 | * |
|
18063
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
3037 | * @return TRUE if successful. |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3038 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3039 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3040 | msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3041 | const gchar *username, const gchar *uid_field_name, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3042 | const gchar *uid_before) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3043 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3044 | PurpleBuddy *buddy; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3045 | guint uid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3046 | gboolean rc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3047 | |
|
18063
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
3048 | g_return_val_if_fail(msg != NULL, FALSE); |
|
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
3049 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3050 | /* Store information for msim_postprocess_outgoing_cb(). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3051 | msim_msg_dump("msim_postprocess_outgoing: msg before=%s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3052 | msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3053 | msg = msim_msg_append(msg, "_uid_field_name", MSIM_TYPE_STRING, g_strdup(uid_field_name)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3054 | msg = msim_msg_append(msg, "_uid_before", MSIM_TYPE_STRING, g_strdup(uid_before)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3055 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3056 | /* First, try the most obvious. If numeric userid is given, use that directly. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3057 | if (msim_is_userid(username)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3058 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3059 | uid = atol(username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3060 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3061 | /* Next, see if on buddy list and know uid. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3062 | buddy = purple_find_buddy(session->account, username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3063 | if (buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3064 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3065 | uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3066 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3067 | uid = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3068 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3069 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3070 | if (!buddy || !uid) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3071 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3072 | /* Don't have uid offhand - need to ask for it, and wait until hear back before sending. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3073 | purple_debug_info("msim", ">>> msim_postprocess_outgoing: couldn't find username %s in blist\n", |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
3074 | username ? username : "(NULL)"); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3075 | msim_msg_dump("msim_postprocess_outgoing - scheduling lookup, msg=%s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3076 | /* TODO: where is cloned message freed? Should be in _cb. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3077 | msim_lookup_user(session, username, msim_postprocess_outgoing_cb, msim_msg_clone(msg)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3078 | return TRUE; /* not sure of status yet - haven't sent! */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3079 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3080 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3081 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3082 | /* Already have uid, postprocess and send msg immediately. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3083 | purple_debug_info("msim", "msim_postprocess_outgoing: found username %s has uid %d\n", |
|
18066
101acc0b44be
Be more careful about null strings in %s format specifier in debug messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18064
diff
changeset
|
3084 | username ? username : "(NULL)", uid); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3085 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3086 | msg = msim_do_postprocessing(msg, uid_before, uid_field_name, uid); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3087 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3088 | msim_msg_dump("msim_postprocess_outgoing: msg after (uid immediate)=%s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3089 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3090 | rc = msim_msg_send(session, msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3091 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3092 | //msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3093 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3094 | return rc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3095 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3096 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3097 | /** Remove a buddy from the user's buddy list. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3098 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3099 | msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3100 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3101 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3102 | MsimMessage *delbuddy_msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3103 | MsimMessage *persist_msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3104 | MsimMessage *blocklist_msg; |
|
19133
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3105 | GList *blocklist_updates; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3106 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3107 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3108 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3109 | delbuddy_msg = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3110 | "delbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3111 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3112 | /* 'delprofileid' with uid will be inserted here. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3113 | NULL); |
|
18063
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
3114 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3115 | if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3116 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3117 | purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed")); |
|
18063
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
3118 | msim_msg_free(delbuddy_msg); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3119 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3120 | } |
|
18063
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
3121 | msim_msg_free(delbuddy_msg); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3122 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3123 | persist_msg = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3124 | "persist", MSIM_TYPE_INTEGER, 1, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3125 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3126 | "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3127 | "dsn", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_DSN, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3128 | "lid", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_LID, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3129 | "uid", MSIM_TYPE_INTEGER, session->userid, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3130 | "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3131 | /* <uid> will be replaced by postprocessing */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3132 | "body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3133 | NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3134 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3135 | if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3136 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3137 | purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed")); |
|
18063
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
3138 | msim_msg_free(persist_msg); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3139 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3140 | } |
|
18063
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
3141 | msim_msg_free(persist_msg); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3142 | |
|
19133
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3143 | blocklist_updates = NULL; |
|
19137
fb04b5cf5817
Use a list when updating the blocklist when removing the buddy, since
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19135
diff
changeset
|
3144 | blocklist_updates = g_list_prepend(blocklist_updates, "a-"); |
|
fb04b5cf5817
Use a list when updating the blocklist when removing the buddy, since
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19135
diff
changeset
|
3145 | blocklist_updates = g_list_prepend(blocklist_updates, "<uid>"); |
|
fb04b5cf5817
Use a list when updating the blocklist when removing the buddy, since
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19135
diff
changeset
|
3146 | blocklist_updates = g_list_prepend(blocklist_updates, "b-"); |
|
fb04b5cf5817
Use a list when updating the blocklist when removing the buddy, since
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19135
diff
changeset
|
3147 | blocklist_updates = g_list_prepend(blocklist_updates, "<uid>"); |
|
fb04b5cf5817
Use a list when updating the blocklist when removing the buddy, since
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19135
diff
changeset
|
3148 | blocklist_updates = g_list_reverse(blocklist_updates); |
|
19133
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3149 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3150 | blocklist_msg = msim_msg_new(TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3151 | "blocklist", MSIM_TYPE_BOOLEAN, TRUE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3152 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
19133
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3153 | /* TODO: MsimMessage lists. Currently <uid> isn't replaced in lists. */ |
|
19137
fb04b5cf5817
Use a list when updating the blocklist when removing the buddy, since
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19135
diff
changeset
|
3154 | //"idlist", MSIM_TYPE_STRING, g_strdup("a-|<uid>|b-|<uid>"), |
|
fb04b5cf5817
Use a list when updating the blocklist when removing the buddy, since
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19135
diff
changeset
|
3155 | "idlist", MSIM_TYPE_LIST, blocklist_updates, |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3156 | NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3157 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3158 | if (!msim_postprocess_outgoing(session, blocklist_msg, buddy->name, "idlist", NULL)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3159 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3160 | purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("blocklist command failed")); |
|
18063
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
3161 | msim_msg_free(blocklist_msg); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3162 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3163 | } |
|
18063
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
3164 | msim_msg_free(blocklist_msg); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3165 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3166 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3167 | /** Return whether the buddy can be messaged while offline. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3168 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3169 | * The protocol supports offline messages in just the same way as online |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3170 | * messages. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3171 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3172 | gboolean |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3173 | msim_offline_message(const PurpleBuddy *buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3174 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3175 | return TRUE; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3176 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3177 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3178 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3179 | * Callback when input available. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3180 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3181 | * @param gc_uncasted A PurpleConnection pointer. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3182 | * @param source File descriptor. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3183 | * @param cond PURPLE_INPUT_READ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3184 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3185 | * Reads the input, and calls msim_preprocess_incoming() to handle it. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3186 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
3187 | static void |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3188 | msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3189 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3190 | PurpleConnection *gc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3191 | PurpleAccount *account; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3192 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3193 | gchar *end; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3194 | int n; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3195 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3196 | g_return_if_fail(gc_uncasted != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3197 | g_return_if_fail(source >= 0); /* Note: 0 is a valid fd */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3198 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3199 | gc = (PurpleConnection *)(gc_uncasted); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3200 | account = purple_connection_get_account(gc); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3201 | session = gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3202 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3203 | g_return_if_fail(cond == PURPLE_INPUT_READ); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3204 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3205 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3206 | /* Mark down that we got data, so don't timeout. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3207 | session->last_comm = time(NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3208 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3209 | /* Only can handle so much data at once... |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3210 | * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3211 | * Should be large enough to hold the largest protocol message. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3212 | */ |
|
18044
06152cc939ef
Increase read buffer size and be more careful about overruns.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18043
diff
changeset
|
3213 | if (session->rxoff >= MSIM_READ_BUF_SIZE) |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3214 | { |
|
18044
06152cc939ef
Increase read buffer size and be more careful about overruns.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18043
diff
changeset
|
3215 | purple_debug_error("msim", |
|
06152cc939ef
Increase read buffer size and be more careful about overruns.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18043
diff
changeset
|
3216 | "msim_input_cb: %d-byte read buffer full! rxoff=%d\n", |
|
06152cc939ef
Increase read buffer size and be more careful about overruns.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18043
diff
changeset
|
3217 | MSIM_READ_BUF_SIZE, session->rxoff); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3218 | purple_connection_error(gc, _("Read buffer full")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3219 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3220 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3221 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3222 | purple_debug_info("msim", "buffer at %d (max %d), reading up to %d\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3223 | session->rxoff, MSIM_READ_BUF_SIZE, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3224 | MSIM_READ_BUF_SIZE - session->rxoff); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3225 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3226 | /* Read into buffer. On Win32, need recv() not read(). session->fd also holds |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3227 | * the file descriptor, but it sometimes differs from the 'source' parameter. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3228 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3229 | n = recv(session->fd, session->rxbuf + session->rxoff, MSIM_READ_BUF_SIZE - session->rxoff, 0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3230 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3231 | if (n < 0 && errno == EAGAIN) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3232 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3233 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3234 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3235 | else if (n < 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3236 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3237 | purple_debug_error("msim", "msim_input_cb: read error, ret=%d, " |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3238 | "error=%s, source=%d, fd=%d (%X))\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3239 | n, strerror(errno), source, session->fd, session->fd); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3240 | purple_connection_error(gc, _("Read error")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3241 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3242 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3243 | else if (n == 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3244 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3245 | purple_debug_info("msim", "msim_input_cb: server disconnected\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3246 | purple_connection_error(gc, _("Server has disconnected")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3247 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3248 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3249 | |
|
18044
06152cc939ef
Increase read buffer size and be more careful about overruns.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18043
diff
changeset
|
3250 | if (n + session->rxoff >= MSIM_READ_BUF_SIZE) |
|
06152cc939ef
Increase read buffer size and be more careful about overruns.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18043
diff
changeset
|
3251 | { |
|
06152cc939ef
Increase read buffer size and be more careful about overruns.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18043
diff
changeset
|
3252 | purple_debug_info("msim_input_cb", "received %d bytes, pushing rxoff to %d, over buffer size of %d\n", |
|
06152cc939ef
Increase read buffer size and be more careful about overruns.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18043
diff
changeset
|
3253 | n, n + session->rxoff, MSIM_READ_BUF_SIZE); |
|
18063
619ec16f2e6d
Fix crash when deleting buddies on Windows. This was done by
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18062
diff
changeset
|
3254 | /* TODO: g_realloc like msn, yahoo, irc, jabber? */ |
|
18044
06152cc939ef
Increase read buffer size and be more careful about overruns.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18043
diff
changeset
|
3255 | purple_connection_error(gc, _("Read buffer full")); |
|
06152cc939ef
Increase read buffer size and be more careful about overruns.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18043
diff
changeset
|
3256 | } |
|
06152cc939ef
Increase read buffer size and be more careful about overruns.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18043
diff
changeset
|
3257 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3258 | /* Null terminate */ |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
3259 | purple_debug_info("msim", "msim_input_cb: going to null terminate " |
|
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
3260 | "at n=%d\n", n); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3261 | session->rxbuf[session->rxoff + n] = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3262 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3263 | #ifdef MSIM_CHECK_EMBEDDED_NULLS |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3264 | /* Check for embedded NULs. I don't handle them, and they shouldn't occur. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3265 | if (strlen(session->rxbuf + session->rxoff) != n) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3266 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3267 | /* Occurs after login, but it is not a null byte. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3268 | purple_debug_info("msim", "msim_input_cb: strlen=%d, but read %d bytes" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3269 | "--null byte encountered?\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3270 | strlen(session->rxbuf + session->rxoff), n); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3271 | //purple_connection_error(gc, "Invalid message - null byte on input"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3272 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3273 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3274 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3275 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3276 | session->rxoff += n; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3277 | purple_debug_info("msim", "msim_input_cb: read=%d\n", n); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3278 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3279 | #ifdef MSIM_DEBUG_RXBUF |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3280 | purple_debug_info("msim", "buf=<%s>\n", session->rxbuf); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3281 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3282 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3283 | /* Look for \\final\\ end markers. If found, process message. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3284 | while((end = strstr(session->rxbuf, MSIM_FINAL_STRING))) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3285 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3286 | MsimMessage *msg; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3287 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3288 | #ifdef MSIM_DEBUG_RXBUF |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3289 | purple_debug_info("msim", "in loop: buf=<%s>\n", session->rxbuf); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3290 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3291 | *end = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3292 | msg = msim_parse(g_strdup(session->rxbuf)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3293 | if (!msg) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3294 | { |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
3295 | purple_debug_info("msim", "msim_input_cb: couldn't parse rxbuf\n"); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3296 | purple_connection_error(gc, _("Unparseable message")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3297 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3298 | else |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3299 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3300 | /* Process message and then free it (processing function should |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3301 | * clone message if it wants to keep it afterwards.) */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3302 | if (!msim_preprocess_incoming(session, msg)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3303 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3304 | msim_msg_dump("msim_input_cb: preprocessing message failed on msg: %s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3305 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3306 | msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3307 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3308 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3309 | /* Move remaining part of buffer to beginning. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3310 | session->rxoff -= strlen(session->rxbuf) + strlen(MSIM_FINAL_STRING); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3311 | memmove(session->rxbuf, end + strlen(MSIM_FINAL_STRING), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3312 | MSIM_READ_BUF_SIZE - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3313 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3314 | /* Clear end of buffer */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3315 | //memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3316 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3317 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3318 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3319 | /* Setup a callback, to be called when a reply is received with the returned rid. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3320 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3321 | * @param cb The callback, an MSIM_USER_LOOKUP_CB. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3322 | * @param data Arbitrary user data to be passed to callback (probably an MsimMessage *). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3323 | * |
| 18041 | 3324 | * @return The request/reply ID, used to link replies with requests, or -1. |
| 3325 | * Put the rid in your request, 'rid' field. | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3326 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3327 | * TODO: Make more generic and more specific: |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3328 | * 1) MSIM_USER_LOOKUP_CB - make it for PERSIST_REPLY, not just user lookup |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3329 | * 2) data - make it an MsimMessage? |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3330 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
3331 | static guint |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3332 | msim_new_reply_callback(MsimSession *session, MSIM_USER_LOOKUP_CB cb, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3333 | gpointer data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3334 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3335 | guint rid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3336 | |
| 18041 | 3337 | g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
| 3338 | ||
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3339 | rid = session->next_rid++; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3340 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3341 | g_hash_table_insert(session->user_lookup_cb, GUINT_TO_POINTER(rid), cb); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3342 | g_hash_table_insert(session->user_lookup_cb_data, GUINT_TO_POINTER(rid), data); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3343 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3344 | return rid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3345 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3346 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3347 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3348 | * Callback when connected. Sets up input handlers. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3349 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3350 | * @param data A PurpleConnection pointer. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3351 | * @param source File descriptor. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3352 | * @param error_message |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3353 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
3354 | static void |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3355 | msim_connect_cb(gpointer data, gint source, const gchar *error_message) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3356 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3357 | PurpleConnection *gc; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3358 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3359 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3360 | g_return_if_fail(data != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3361 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3362 | gc = (PurpleConnection *)data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3363 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3364 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3365 | if (source < 0) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3366 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3367 | purple_connection_error(gc, _("Couldn't connect to host")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3368 | purple_connection_error(gc, g_strdup_printf( |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3369 | _("Couldn't connect to host: %s (%d)"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3370 | error_message ? error_message : "no message given", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3371 | source)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3372 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3373 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3374 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3375 | session->fd = source; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3376 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3377 | gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3378 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3379 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3380 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3381 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3382 | /* Session methods */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3383 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3384 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3385 | * Create a new MSIM session. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3386 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3387 | * @param acct The account to create the session from. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3388 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3389 | * @return Pointer to a new session. Free with msim_session_destroy. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3390 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3391 | MsimSession * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3392 | msim_session_new(PurpleAccount *acct) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3393 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3394 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3395 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3396 | g_return_val_if_fail(acct != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3397 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3398 | session = g_new0(MsimSession, 1); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3399 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3400 | session->magic = MSIM_SESSION_STRUCT_MAGIC; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3401 | session->account = acct; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3402 | session->gc = purple_account_get_connection(acct); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3403 | session->sesskey = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3404 | session->userid = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3405 | session->username = NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3406 | session->fd = -1; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3407 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3408 | /* TODO: Remove. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3409 | session->user_lookup_cb = g_hash_table_new_full(g_direct_hash, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3410 | g_direct_equal, NULL, NULL); /* do NOT free function pointers! (values) */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3411 | session->user_lookup_cb_data = g_hash_table_new_full(g_direct_hash, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3412 | g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3413 | they could be integers inside gpointers |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3414 | or strings, so I don't freed them. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3415 | Figure this out, once free cache. */ |
|
18056
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
3416 | |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
3417 | /* Created in msim_process_server_info() */ |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
3418 | session->server_info = NULL; |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
3419 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3420 | session->rxoff = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3421 | session->rxbuf = g_new0(gchar, MSIM_READ_BUF_SIZE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3422 | session->next_rid = 1; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3423 | session->last_comm = time(NULL); |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
3424 | session->inbox_status = 0; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3425 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3426 | return session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3427 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3428 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3429 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3430 | * Free a session. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3431 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3432 | * @param session The session to destroy. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3433 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3434 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3435 | msim_session_destroy(MsimSession *session) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3436 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3437 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3438 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3439 | session->magic = -1; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3440 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3441 | g_free(session->rxbuf); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3442 | g_free(session->username); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3443 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3444 | /* TODO: Remove. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3445 | g_hash_table_destroy(session->user_lookup_cb); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3446 | g_hash_table_destroy(session->user_lookup_cb_data); |
|
18056
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
3447 | |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
3448 | if (session->server_info) |
|
2c2d509ebe78
Add msim_process_server_info() to save the server information dictionary
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18055
diff
changeset
|
3449 | g_hash_table_destroy(session->server_info); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3450 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3451 | g_free(session); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3452 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3453 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3454 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3455 | * Close the connection. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3456 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3457 | * @param gc The connection. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3458 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3459 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3460 | msim_close(PurpleConnection *gc) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3461 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3462 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3463 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3464 | if (gc == NULL) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3465 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3466 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3467 | session = (MsimSession *)gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3468 | if (session == NULL) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3469 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3470 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3471 | gc->proto_data = NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3472 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3473 | if (!MSIM_SESSION_VALID(session)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3474 | return; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3475 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3476 | if (session->gc->inpa) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3477 | purple_input_remove(session->gc->inpa); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3478 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3479 | msim_session_destroy(session); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3480 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3481 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3482 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3483 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3484 | * Check if a string is a userid (all numeric). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3485 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3486 | * @param user The user id, email, or name. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3487 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3488 | * @return TRUE if is userid, FALSE if not. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3489 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
3490 | static gboolean |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3491 | msim_is_userid(const gchar *user) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3492 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3493 | g_return_val_if_fail(user != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3494 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3495 | return strspn(user, "0123456789") == strlen(user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3496 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3497 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3498 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3499 | * Check if a string is an email address (contains an @). |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3500 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3501 | * @param user The user id, email, or name. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3502 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3503 | * @return TRUE if is an email, FALSE if not. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3504 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3505 | * This function is not intended to be used as a generic |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3506 | * means of validating email addresses, but to distinguish |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3507 | * between a user represented by an email address from |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3508 | * other forms of identification. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3509 | */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
3510 | static gboolean |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3511 | msim_is_email(const gchar *user) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3512 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3513 | g_return_val_if_fail(user != NULL, FALSE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3514 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3515 | return strchr(user, '@') != NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3516 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3517 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3518 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3519 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3520 | * Asynchronously lookup user information, calling callback when receive result. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3521 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3522 | * @param session |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3523 | * @param user The user id, email address, or username. Not freed. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3524 | * @param cb Callback, called with user information when available. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3525 | * @param data An arbitray data pointer passed to the callback. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3526 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3527 | /* TODO: change to not use callbacks */ |
|
18059
9dcbd6ed0b28
Make msimprpl-internal functions static.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18058
diff
changeset
|
3528 | static void |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3529 | msim_lookup_user(MsimSession *session, const gchar *user, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3530 | MSIM_USER_LOOKUP_CB cb, gpointer data) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3531 | { |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
3532 | MsimMessage *body; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3533 | gchar *field_name; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3534 | guint rid, cmd, dsn, lid; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3535 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3536 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3537 | g_return_if_fail(user != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3538 | g_return_if_fail(cb != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3539 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3540 | purple_debug_info("msim", "msim_lookup_userid: " |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3541 | "asynchronously looking up <%s>\n", user); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3542 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3543 | msim_msg_dump("msim_lookup_user: data=%s\n", (MsimMessage *)data); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3544 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3545 | /* Setup callback. Response will be associated with request using 'rid'. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3546 | rid = msim_new_reply_callback(session, cb, data); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3547 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3548 | /* Send request */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3549 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3550 | cmd = MSIM_CMD_GET; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3551 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3552 | if (msim_is_userid(user)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3553 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3554 | field_name = "UserID"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3555 | dsn = MG_MYSPACE_INFO_BY_ID_DSN; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3556 | lid = MG_MYSPACE_INFO_BY_ID_LID; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3557 | } else if (msim_is_email(user)) { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3558 | field_name = "Email"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3559 | dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3560 | lid = MG_MYSPACE_INFO_BY_STRING_LID; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3561 | } else { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3562 | field_name = "UserName"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3563 | dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3564 | lid = MG_MYSPACE_INFO_BY_STRING_LID; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3565 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3566 | |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
3567 | body = msim_msg_new(TRUE, |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
3568 | field_name, MSIM_TYPE_STRING, g_strdup(user), |
|
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
3569 | NULL); |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3570 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3571 | g_return_if_fail(msim_send(session, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3572 | "persist", MSIM_TYPE_INTEGER, 1, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3573 | "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3574 | "cmd", MSIM_TYPE_INTEGER, 1, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3575 | "dsn", MSIM_TYPE_INTEGER, dsn, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3576 | "uid", MSIM_TYPE_INTEGER, session->userid, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3577 | "lid", MSIM_TYPE_INTEGER, lid, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3578 | "rid", MSIM_TYPE_INTEGER, rid, |
|
19135
705302b2c7f7
Use the new dictionary data type when:
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
19133
diff
changeset
|
3579 | "body", MSIM_TYPE_DICTIONARY, body, |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3580 | NULL)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3581 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3582 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3583 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3584 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3585 | * Obtain the status text for a buddy. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3586 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3587 | * @param buddy The buddy to obtain status text for. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3588 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3589 | * @return Status text, or NULL if error. Caller g_free()'s. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3590 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3591 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3592 | char * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3593 | msim_status_text(PurpleBuddy *buddy) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3594 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3595 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3596 | const gchar *display_name, *headline; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3597 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3598 | g_return_val_if_fail(buddy != NULL, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3599 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3600 | session = (MsimSession *)buddy->account->gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3601 | g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3602 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3603 | display_name = headline = NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3604 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3605 | /* Retrieve display name and/or headline, depending on user preference. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3606 | if (purple_account_get_bool(session->account, "show_display_name", TRUE)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3607 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3608 | display_name = purple_blist_node_get_string(&buddy->node, "DisplayName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3609 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3610 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3611 | if (purple_account_get_bool(session->account, "show_headline", FALSE)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3612 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3613 | headline = purple_blist_node_get_string(&buddy->node, "Headline"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3614 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3615 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3616 | /* Return appropriate combination of display name and/or headline, or neither. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3617 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3618 | if (display_name && headline) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3619 | return g_strconcat(display_name, " ", headline, NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3620 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3621 | if (display_name) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3622 | return g_strdup(display_name); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3623 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3624 | if (headline) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3625 | return g_strdup(headline); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3626 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3627 | return NULL; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3628 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3629 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3630 | /** |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3631 | * Obtain the tooltip text for a buddy. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3632 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3633 | * @param buddy Buddy to obtain tooltip text on. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3634 | * @param user_info Variable modified to have the tooltip text. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3635 | * @param full TRUE if should obtain full tooltip text. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3636 | * |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3637 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3638 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3639 | msim_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3640 | gboolean full) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3641 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3642 | const gchar *str, *str2; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3643 | gint n; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3644 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3645 | g_return_if_fail(buddy != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3646 | g_return_if_fail(user_info != NULL); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3647 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3648 | if (PURPLE_BUDDY_IS_ONLINE(buddy)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3649 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3650 | MsimSession *session; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3651 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3652 | session = (MsimSession *)buddy->account->gc->proto_data; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3653 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3654 | g_return_if_fail(MSIM_SESSION_VALID(session)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3655 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3656 | /* TODO: if (full), do something different */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3657 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3658 | /* Useful to identify the account the tooltip refers to. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3659 | * Other prpls show this. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3660 | str = purple_blist_node_get_string(&buddy->node, "UserName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3661 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3662 | purple_notify_user_info_add_pair(user_info, _("User Name"), str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3663 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3664 | /* a/s/l...the vitals */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3665 | n = purple_blist_node_get_int(&buddy->node, "Age"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3666 | if (n) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3667 | purple_notify_user_info_add_pair(user_info, _("Age"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3668 | g_strdup_printf("%d", n)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3669 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3670 | str = purple_blist_node_get_string(&buddy->node, "Gender"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3671 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3672 | purple_notify_user_info_add_pair(user_info, _("Gender"), str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3673 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3674 | str = purple_blist_node_get_string(&buddy->node, "Location"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3675 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3676 | purple_notify_user_info_add_pair(user_info, _("Location"), str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3677 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3678 | /* Other information */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3679 | str = purple_blist_node_get_string(&buddy->node, "Headline"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3680 | if (str) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3681 | purple_notify_user_info_add_pair(user_info, _("Headline"), str); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3682 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3683 | str = purple_blist_node_get_string(&buddy->node, "BandName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3684 | str2 = purple_blist_node_get_string(&buddy->node, "SongName"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3685 | if (str || str2) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3686 | purple_notify_user_info_add_pair(user_info, _("Song"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3687 | g_strdup_printf("%s - %s", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3688 | str ? str : _("Unknown Artist"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3689 | str2 ? str2 : _("Unknown Song"))); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3690 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3691 | n = purple_blist_node_get_int(&buddy->node, "TotalFriends"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3692 | if (n) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3693 | purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3694 | g_strdup_printf("%d", n)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3695 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3696 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3697 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3698 | |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3699 | /** Actions menu for account. */ |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3700 | GList * |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3701 | msim_actions(PurplePlugin *plugin, gpointer context) |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3702 | { |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3703 | PurpleConnection *gc; |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3704 | GList *menu; |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3705 | //PurplePluginAction *act; |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3706 | |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3707 | gc = (PurpleConnection *)context; |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3708 | |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3709 | menu = NULL; |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3710 | |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3711 | #if 0 |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3712 | /* TODO: find out how */ |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3713 | act = purple_plugin_action_new(_("Find people..."), msim_); |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3714 | menu = g_list_append(menu, act); |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3715 | |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3716 | act = purple_plugin_action_new(_("Import friends..."), NULL); |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3717 | menu = g_list_append(menu, act); |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3718 | |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3719 | act = purple_plugin_action_new(_("Change IM name..."), NULL); |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3720 | menu = g_list_append(menu, act); |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3721 | #endif |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3722 | |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3723 | return menu; |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3724 | } |
|
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3725 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3726 | /** Callbacks called by Purple, to access this plugin. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3727 | PurplePluginProtocolInfo prpl_info = |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3728 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3729 | /* options */ |
|
18038
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
3730 | OPT_PROTO_USE_POINTSIZE /* specify font size in sane point size */ |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
3731 | | OPT_PROTO_MAIL_CHECK, |
|
4a904c0a564e
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18037
diff
changeset
|
3732 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3733 | /* | OPT_PROTO_IM_IMAGE - TODO: direct images. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3734 | NULL, /* user_splits */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3735 | NULL, /* protocol_options */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3736 | NO_BUDDY_ICONS, /* icon_spec - TODO: eventually should add this */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3737 | msim_list_icon, /* list_icon */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3738 | NULL, /* list_emblems */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3739 | msim_status_text, /* status_text */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3740 | msim_tooltip_text, /* tooltip_text */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3741 | msim_status_types, /* status_types */ |
|
18053
e0e7522cda38
Allow sending zaps through buddy list menu.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18052
diff
changeset
|
3742 | msim_blist_node_menu, /* blist_node_menu */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3743 | NULL, /* chat_info */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3744 | NULL, /* chat_info_defaults */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3745 | msim_login, /* login */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3746 | msim_close, /* close */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3747 | msim_send_im, /* send_im */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3748 | NULL, /* set_info */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3749 | msim_send_typing, /* send_typing */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3750 | msim_get_info, /* get_info */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3751 | msim_set_status, /* set_status */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3752 | msim_set_idle, /* set_idle */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3753 | NULL, /* change_passwd */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3754 | msim_add_buddy, /* add_buddy */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3755 | NULL, /* add_buddies */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3756 | msim_remove_buddy, /* remove_buddy */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3757 | NULL, /* remove_buddies */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3758 | NULL, /* add_permit */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3759 | NULL, /* add_deny */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3760 | NULL, /* rem_permit */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3761 | NULL, /* rem_deny */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3762 | NULL, /* set_permit_deny */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3763 | NULL, /* join_chat */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3764 | NULL, /* reject chat invite */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3765 | NULL, /* get_chat_name */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3766 | NULL, /* chat_invite */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3767 | NULL, /* chat_leave */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3768 | NULL, /* chat_whisper */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3769 | NULL, /* chat_send */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3770 | NULL, /* keepalive */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3771 | NULL, /* register_user */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3772 | NULL, /* get_cb_info */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3773 | NULL, /* get_cb_away */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3774 | NULL, /* alias_buddy */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3775 | NULL, /* group_buddy */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3776 | NULL, /* rename_group */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3777 | NULL, /* buddy_free */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3778 | NULL, /* convo_closed */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3779 | NULL, /* normalize */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3780 | NULL, /* set_buddy_icon */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3781 | NULL, /* remove_group */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3782 | NULL, /* get_cb_real_name */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3783 | NULL, /* set_chat_topic */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3784 | NULL, /* find_blist_chat */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3785 | NULL, /* roomlist_get_list */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3786 | NULL, /* roomlist_cancel */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3787 | NULL, /* roomlist_expand_category */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3788 | NULL, /* can_receive_file */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3789 | NULL, /* send_file */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3790 | NULL, /* new_xfer */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3791 | msim_offline_message, /* offline_message */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3792 | NULL, /* whiteboard_prpl_ops */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3793 | msim_send_really_raw, /* send_raw */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3794 | NULL, /* roomlist_room_serialize */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3795 | NULL, /* _purple_reserved1 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3796 | NULL, /* _purple_reserved2 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3797 | NULL, /* _purple_reserved3 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3798 | NULL /* _purple_reserved4 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3799 | }; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3800 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3801 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3802 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3803 | /** Based on MSN's plugin info comments. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3804 | PurplePluginInfo info = |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3805 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3806 | PURPLE_PLUGIN_MAGIC, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3807 | PURPLE_MAJOR_VERSION, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3808 | PURPLE_MINOR_VERSION, |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3809 | PURPLE_PLUGIN_PROTOCOL, /**< type */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3810 | NULL, /**< ui_requirement */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3811 | 0, /**< flags */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3812 | NULL, /**< dependencies */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3813 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3814 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3815 | "prpl-myspace", /**< id */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3816 | "MySpaceIM", /**< name */ |
|
18043
6c7ea1ce1beb
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18042
diff
changeset
|
3817 | MSIM_PRPL_VERSION_STRING, /**< version */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3818 | /** summary */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3819 | "MySpaceIM Protocol Plugin", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3820 | /** description */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3821 | "MySpaceIM Protocol Plugin", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3822 | "Jeff Connelly <jeff2@soc.pidgin.im>", /**< author */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3823 | "http://developer.pidgin.im/wiki/MySpaceIM/", /**< homepage */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3824 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3825 | msim_load, /**< load */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3826 | NULL, /**< unload */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3827 | NULL, /**< destroy */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3828 | NULL, /**< ui_info */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3829 | &prpl_info, /**< extra_info */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3830 | NULL, /**< prefs_info */ |
|
18055
ed3a5b60eff6
Use MsimMessage's new list type for status messages.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18053
diff
changeset
|
3831 | msim_actions, /**< msim_actions */ |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3832 | NULL, /**< reserved1 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3833 | NULL, /**< reserved2 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3834 | NULL, /**< reserved3 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3835 | NULL /**< reserved4 */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3836 | }; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3837 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3838 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3839 | #ifdef MSIM_SELF_TEST |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3840 | /** Test functions. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3841 | * Used to test or try out the internal workings of msimprpl. If you're reading |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3842 | * this code for the first time, these functions can be instructive in how |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3843 | * msimprpl is architected. |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3844 | */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3845 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3846 | msim_test_all(void) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3847 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3848 | guint failures; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3849 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3850 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3851 | failures = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3852 | failures += msim_test_msg(); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3853 | failures += msim_test_escaping(); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3854 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3855 | if (failures) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3856 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3857 | purple_debug_info("msim", "msim_test_all HAD FAILURES: %d\n", failures); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3858 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3859 | else |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3860 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3861 | purple_debug_info("msim", "msim_test_all - all tests passed!\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3862 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3863 | exit(0); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3864 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3865 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3866 | /** Test MsimMessage for basic functionality. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3867 | int |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3868 | msim_test_msg(void) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3869 | { |
|
19133
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3870 | MsimMessage *msg, *msg_cloned, *msg2; |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3871 | GList *list; |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3872 | gchar *packed, *packed_expected, *packed_cloned; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3873 | guint failures; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3874 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3875 | failures = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3876 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3877 | purple_debug_info("msim", "\n\nTesting MsimMessage\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3878 | msg = msim_msg_new(FALSE); /* Create a new, empty message. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3879 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3880 | /* Append some new elements. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3881 | msg = msim_msg_append(msg, "bx", MSIM_TYPE_BINARY, g_string_new_len(g_strdup("XXX"), 3)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3882 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v1")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3883 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(42)); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3884 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v43")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3885 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v52/xxx\\yyy")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3886 | msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v7")); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3887 | msim_msg_dump("msg debug str=%s\n", msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3888 | packed = msim_msg_pack(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3889 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3890 | purple_debug_info("msim", "msg packed=%s\n", packed); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3891 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3892 | packed_expected = "\\bx\\WFhY\\k1\\v1\\k1\\42\\k1" |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3893 | "\\v43\\k1\\v52/1xxx/2yyy\\k1\\v7\\final\\"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3894 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3895 | if (0 != strcmp(packed, packed_expected)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3896 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3897 | purple_debug_info("msim", "!!!(%d), msim_msg_pack not what expected: %s != %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3898 | ++failures, packed, packed_expected); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3899 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3900 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3901 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3902 | msg_cloned = msim_msg_clone(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3903 | packed_cloned = msim_msg_pack(msg_cloned); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3904 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3905 | purple_debug_info("msim", "msg cloned=%s\n", packed_cloned); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3906 | if (0 != strcmp(packed, packed_cloned)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3907 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3908 | purple_debug_info("msim", "!!!(%d), msim_msg_pack on cloned message not equal to original: %s != %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3909 | ++failures, packed_cloned, packed); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3910 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3911 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3912 | g_free(packed); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3913 | g_free(packed_cloned); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3914 | msim_msg_free(msg_cloned); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3915 | msim_msg_free(msg); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3916 | |
|
19133
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3917 | /* Try some of the more advanced functionality */ |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3918 | list = NULL; |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3919 | |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3920 | list = g_list_prepend(list, "item3"); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3921 | list = g_list_prepend(list, "item2"); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3922 | list = g_list_prepend(list, "item1"); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3923 | list = g_list_prepend(list, "item0"); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3924 | |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3925 | msg = msim_msg_new(FALSE); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3926 | msg = msim_msg_append(msg, "string", MSIM_TYPE_STRING, g_strdup("string value")); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3927 | msg = msim_msg_append(msg, "raw", MSIM_TYPE_RAW, g_strdup("raw value")); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3928 | msg = msim_msg_append(msg, "integer", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(3140)); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3929 | msg = msim_msg_append(msg, "boolean", MSIM_TYPE_BOOLEAN, GUINT_TO_POINTER(FALSE)); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3930 | msg = msim_msg_append(msg, "list", MSIM_TYPE_LIST, list); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3931 | |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3932 | msim_msg_dump("msg with list=%s\n", msg); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3933 | purple_debug_info("msim", "msg with list packed=%s\n", msim_msg_pack(msg)); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3934 | |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3935 | msg2 = msim_msg_new(FALSE); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3936 | msg2 = msim_msg_append(msg2, "outer", MSIM_TYPE_STRING, g_strdup("outer value")); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3937 | msg2 = msim_msg_append(msg2, "body", MSIM_TYPE_DICTIONARY, msg); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3938 | msim_msg_dump("msg with dict=%s\n", msg2); /* msg2 now 'owns' msg */ |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3939 | purple_debug_info("msim", "msg with dict packed=%s\n", msim_msg_pack(msg2)); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3940 | |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3941 | msim_msg_free(msg2); |
|
81e7c23bbb7f
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18066
diff
changeset
|
3942 | |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3943 | return failures; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3944 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3945 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3946 | /** Test protocol-level escaping/unescaping. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3947 | int |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3948 | msim_test_escaping(void) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3949 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3950 | guint failures; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3951 | gchar *raw, *escaped, *unescaped, *expected; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3952 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3953 | failures = 0; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3954 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3955 | purple_debug_info("msim", "\n\nTesting escaping\n"); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3956 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3957 | raw = "hello/world\\hello/world"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3958 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3959 | escaped = msim_escape(raw); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3960 | purple_debug_info("msim", "msim_test_escaping: raw=%s, escaped=%s\n", raw, escaped); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3961 | expected = "hello/1world/2hello/1world"; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3962 | if (0 != strcmp(escaped, expected)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3963 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3964 | purple_debug_info("msim", "!!!(%d), msim_escape failed: %s != %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3965 | ++failures, escaped, expected); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3966 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3967 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3968 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3969 | unescaped = msim_unescape(escaped); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3970 | g_free(escaped); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3971 | purple_debug_info("msim", "msim_test_escaping: unescaped=%s\n", unescaped); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3972 | if (0 != strcmp(raw, unescaped)) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3973 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3974 | purple_debug_info("msim", "!!!(%d), msim_unescape failed: %s != %s\n", |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3975 | ++failures, raw, unescaped); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3976 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3977 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3978 | return failures; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3979 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3980 | #endif |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3981 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3982 | /** Initialize plugin. */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3983 | void |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3984 | init_plugin(PurplePlugin *plugin) |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3985 | { |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3986 | PurpleAccountOption *option; |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3987 | #ifdef MSIM_SELF_TEST |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3988 | msim_test_all(); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3989 | #endif /* MSIM_SELF_TEST */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3990 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3991 | /* TODO: default to automatically try different ports. Make the user be |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3992 | * able to set the first port to try (like LastConnectedPort in Windows client). */ |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3993 | option = purple_account_option_string_new(_("Connect server"), "server", MSIM_SERVER); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3994 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3995 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3996 | option = purple_account_option_int_new(_("Connect port"), "port", MSIM_PORT); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3997 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3998 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
3999 | option = purple_account_option_bool_new(_("Show display name in status text"), "show_display_name", TRUE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
4000 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
4001 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
4002 | option = purple_account_option_bool_new(_("Show headline in status text"), "show_headline", TRUE); |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
4003 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
4004 | |
|
18048
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
4005 | option = purple_account_option_bool_new(_("Send emoticons"), "emoticons", FALSE); |
|
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
4006 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
c8f29e1916c2
Add account option to send emoticons, defaulting to off since can't currently
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18047
diff
changeset
|
4007 | |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
4008 | #ifdef MSIM_USER_REALLY_CARES_ABOUT_PRECISE_FONT_SIZES |
|
18042
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
4009 | option = purple_account_option_int_new(_("Screen resolution (dots per inch)"), "dpi", MSIM_DEFAULT_DPI); |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
4010 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
4011 | |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
4012 | option = purple_account_option_int_new(_("Base font size (points)"), "base_font_size", MSIM_BASE_FONT_POINT_SIZE); |
|
390fbe2a4e87
Make DPI and base font point size configurable in account options. This
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18041
diff
changeset
|
4013 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
18057
77eb36712aca
Update login process to more closely match official client.
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18056
diff
changeset
|
4014 | #endif |
|
18026
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
4015 | } |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
4016 | |
|
dec27c05ae89
Set status to current status when signing on. This makes the "Sign in as
Jeff Connelly <jeff2@soc.pidgin.im>
parents:
18025
diff
changeset
|
4017 | PURPLE_INIT_PLUGIN(myspace, init_plugin, info); |