Mercurial > pidgin.yaz
annotate libpurple/protocols/myspace/myspace.c @ 18918:abb5b6ec99a6
Change two strcmp()s to purple_utf8_strcasecmp() for case-insensitive comparison.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Tue, 14 Aug 2007 02:33:01 +0000 |
parents | 0f46f13c0805 |
children | f60192409e7f |
rev | line source |
---|---|
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1 /* MySpaceIM Protocol Plugin |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3 * \author Jeff Connelly |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
5 * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im> |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
6 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
7 * Based on Purple's "C Plugin HOWTO" hello world example. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
8 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
9 * Code also drawn from mockprpl: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
10 * http://snarfed.org/space/purple+mock+protocol+plugin |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
11 * Copyright (C) 2004-2007, Ryan Barrett <mockprpl@ryanb.org> |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
12 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
13 * and some constructs also based on existing Purple plugins, which are: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
14 * Copyright (C) 2003, Robbert Haarman <purple@inglorion.net> |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
15 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
16 * Copyright (C) 2000-2003, Rob Flynn <rob@tgflinux.com> |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
17 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
18 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
19 * This program is free software; you can redistribute it and/or modify |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
20 * it under the terms of the GNU General Public License as published by |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
21 * the Free Software Foundation; either version 2 of the License, or |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
22 * (at your option) any later version. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
23 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
27 * GNU General Public License for more details. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
28 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
30 * along with this program; if not, write to the Free Software |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
32 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
33 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
34 #define PURPLE_PLUGIN |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
35 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
36 #include "message.h" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
37 #include "persist.h" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
38 #include "myspace.h" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
39 |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
40 /* Globals */ |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
41 |
17960
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
42 /* The names in in emoticon_names (for <i n=whatever>) map to corresponding |
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
43 * entries in emoticon_symbols (for the ASCII representation of the emoticon). |
18893
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
44 * |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
45 * Multiple emoticon symbols in Pidgin can map to one name. List the |
17960
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
46 * canonical form, as inserted by the "Smile!" dialog, first. For example, |
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
47 * :) comes before :-), because although both are recognized as 'happy', |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
48 * the first is inserted by the smiley button (first symbol in theme). |
17960
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
49 * |
f61047bae7c0
Recognize non-canonical emoticon forms from Pidgin, and turn them into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17959
diff
changeset
|
50 * Note that symbols are case-sensitive in Pidgin -- :-X is not :-x. */ |
18893
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
51 static struct MSIM_EMOTICON |
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
52 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
53 gchar *name; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
54 gchar *symbol; |
18893
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
55 } msim_emoticons[] = { |
18903
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
56 /* Unfortunately, this list duplicates much of the file |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
57 * pidgin/pidgin/pixmaps/emotes/default/22/default.theme.in, because |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
58 * that file is part of Pidgin, but we're part of libpurple. |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
59 */ |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
60 { "bigsmile", ":D" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
61 { "bigsmile", ":-D" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
62 { "devil", "}:)" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
63 { "frazzled", ":Z" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
64 { "geek", "B)" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
65 { "googles", "%)" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
66 { "growl", ":E" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
67 { "laugh", ":))" }, /* Must be before ':)' */ |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
68 { "happy", ":)" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
69 { "happy", ":-)" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
70 { "happi", ":)" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
71 { "heart", ":X" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
72 { "mohawk", "-:" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
73 { "mad", "X(" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
74 { "messed", "X)" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
75 { "nerd", "Q)" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
76 { "oops", ":G" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
77 { "pirate", "P)" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
78 { "scared", ":O" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
79 { "sidefrown", ":{" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
80 { "sinister", ":B" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
81 { "smirk", ":," }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
82 { "straight", ":|" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
83 { "tongue", ":P" }, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
84 { "tongue", ":p" }, |
18903
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
85 { "tongy", ":P" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
86 { "upset", "B|" }, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
87 { "wink", ";-)" }, |
18903
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
88 { "wink", ";)" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
89 { "winc", ";)" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
90 { "worried", ":[" }, |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
91 { "kiss", ":x" }, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
92 { NULL, NULL } |
18893
cd90423c0a88
Use an array of structs instead of parallel arrays for the emoticon
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18892
diff
changeset
|
93 }; |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
94 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
95 /* Internal functions */ |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
96 static gboolean msim_send_zap(MsimSession *session, const gchar *username, guint code); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
97 static void msim_send_zap_from_menu(PurpleBlistNode *node, gpointer zap_num_ptr); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
98 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
99 #ifdef MSIM_DEBUG_MSG |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
100 static void print_hash_item(gpointer key, gpointer value, gpointer user_data); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
101 #endif |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
102 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
103 static int msim_send_really_raw(PurpleConnection *gc, const char *buf, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
104 int total_bytes); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
105 static gboolean msim_login_challenge(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
106 static const gchar *msim_compute_login_response( |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
107 const gchar nonce[2 * NONCE_SIZE], const gchar *email, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
108 const gchar *password, guint *response_len); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
109 static gboolean msim_send_bm(MsimSession *session, const gchar *who, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
110 const gchar *text, int type); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
111 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
112 static guint msim_point_to_purple_size(MsimSession *session, guint point); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
113 static guint msim_purple_size_to_point(MsimSession *session, guint size); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
114 static guint msim_height_to_point(MsimSession *session, guint height); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
115 static guint msim_point_to_height(MsimSession *session, guint point); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
116 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
117 static void msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
118 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
119 static void msim_markup_tag_to_html(MsimSession *, xmlnode *root, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
120 gchar **begin, gchar **end); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
121 static void html_tag_to_msim_markup(MsimSession *, xmlnode *root, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
122 gchar **begin, gchar **end); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
123 static gchar *msim_convert_xml(MsimSession *, const gchar *raw, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
124 MSIM_XMLNODE_CONVERT f); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
125 static gchar *msim_convert_smileys_to_markup(gchar *before); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
126 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
127 /* High-level msim markup <=> html conversion functions. */ |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
128 static gchar *msim_markup_to_html(MsimSession *, const gchar *raw); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
129 static gchar *html_to_msim_markup(MsimSession *, const gchar *raw); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
130 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
131 static MsimUser *msim_get_user_from_buddy(PurpleBuddy *buddy); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
132 static MsimUser *msim_find_user(MsimSession *session, const gchar *username); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
133 |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
134 static gboolean msim_incoming_bm_record_cv(MsimSession *session, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
135 MsimMessage *msg); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
136 static gboolean msim_incoming_bm(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
137 static gboolean msim_incoming_status(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
138 static gboolean msim_incoming_im(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
139 static gboolean msim_incoming_zap(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
140 static gboolean msim_incoming_action(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
141 static gboolean msim_incoming_media(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
142 static gboolean msim_incoming_unofficial_client(MsimSession *session, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
143 MsimMessage *msg); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
144 |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
145 #ifdef MSIM_SEND_CLIENT_VERSION |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
146 static gboolean msim_send_unofficial_client(MsimSession *session, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
147 gchar *username); |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
148 #endif |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
149 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
150 static void msim_get_info_cb(MsimSession *session, MsimMessage *userinfo, gpointer data); |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
151 static gchar *msim_format_now_playing(gchar *band, gchar *song); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
152 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
153 static void msim_set_status_code(MsimSession *session, guint code, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
154 gchar *statstring); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
155 |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
156 static void msim_append_user_info(MsimSession *session, PurpleNotifyUserInfo *user_info, MsimUser *user, gboolean full); |
18915
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
157 |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
158 static void msim_downloaded_buddy_icon(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
159 gsize len, const gchar *error_message); |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
160 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
161 static void msim_store_user_info_each(gpointer key, gpointer value, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
162 gpointer user_data); |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
163 static gboolean msim_store_user_info(MsimSession *session, MsimMessage *msg, MsimUser *user); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
164 static gboolean msim_process_server_info(MsimSession *session, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
165 MsimMessage *msg); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
166 static gboolean msim_web_challenge(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
167 static gboolean msim_process_reply(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
168 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
169 static gboolean msim_preprocess_incoming(MsimSession *session,MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
170 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
171 #ifdef MSIM_USE_KEEPALIVE |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
172 static gboolean msim_check_alive(gpointer data); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
173 #endif |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
174 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
175 static gboolean msim_we_are_logged_on(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
176 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
177 static gboolean msim_process(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
178 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
179 static MsimMessage *msim_do_postprocessing(MsimMessage *msg, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
180 const gchar *uid_field_name, const gchar *uid_before, guint uid); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
181 static void msim_postprocess_outgoing_cb(MsimSession *session, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
182 MsimMessage *userinfo, gpointer data); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
183 static gboolean msim_postprocess_outgoing(MsimSession *session, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
184 MsimMessage *msg, const gchar *username, const gchar *uid_field_name, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
185 const gchar *uid_before); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
186 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
187 static gboolean msim_error(MsimSession *session, MsimMessage *msg); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
188 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
189 static void msim_check_inbox_cb(MsimSession *session, MsimMessage *userinfo, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
190 gpointer data); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
191 static gboolean msim_check_inbox(gpointer data); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
192 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
193 static void msim_input_cb(gpointer gc_uncasted, gint source, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
194 PurpleInputCondition cond); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
195 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
196 static guint msim_new_reply_callback(MsimSession *session, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
197 MSIM_USER_LOOKUP_CB cb, gpointer data); |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
198 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
199 static void msim_connect_cb(gpointer data, gint source, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
200 const gchar *error_message); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
201 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
202 static gboolean msim_is_userid(const gchar *user); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
203 static gboolean msim_is_email(const gchar *user); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
204 |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
205 static void msim_lookup_user(MsimSession *session, const gchar *user, |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
206 MSIM_USER_LOOKUP_CB cb, gpointer data); |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
207 |
18892
138e9be2f917
Always use our own msim_round() instead of checking for C99's round and using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18890
diff
changeset
|
208 double msim_round(double round); |
17971
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
209 |
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
210 /* round is part of C99, but sometimes is unavailable before then. |
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
211 * Based on http://forums.belution.com/en/cpp/000/050/13.shtml |
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
212 */ |
18892
138e9be2f917
Always use our own msim_round() instead of checking for C99's round and using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18890
diff
changeset
|
213 double msim_round(double value) |
17971
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
214 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
215 if (value < 0) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
216 return -(floor(-value + 0.5)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
217 } else { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
218 return floor( value + 0.5); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
219 } |
17971
13a4f57f53a9
Implement round() if it is not available, using floor().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17969
diff
changeset
|
220 } |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
221 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
222 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
223 * Load the plugin. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
224 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
225 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
226 msim_load(PurplePlugin *plugin) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
227 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
228 /* If compiled to use RC4 from libpurple, check if it is really there. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
229 if (!purple_ciphers_find_cipher("rc4")) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
230 purple_debug_error("msim", "rc4 not in libpurple, but it is required - not loading MySpaceIM plugin!\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
231 purple_notify_error(plugin, _("Missing Cipher"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
232 _("The RC4 cipher could not be found"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
233 _("Upgrade " |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
234 "to a libpurple with RC4 support (>= 2.0.1). MySpaceIM " |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
235 "plugin will not be loaded.")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
236 return FALSE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
237 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
238 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
239 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
240 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
241 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
242 * Get possible user status types. Based on mockprpl. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
243 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
244 * @return GList of status types. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
245 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
246 GList * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
247 msim_status_types(PurpleAccount *acct) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
248 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
249 GList *types; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
250 PurpleStatusType *status; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
251 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
252 purple_debug_info("myspace", "returning status types\n"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
253 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
254 types = NULL; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
255 |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
256 /* Statuses are almost all the same. Define a macro to reduce code repetition. */ |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
257 #define _MSIM_ADD_NEW_STATUS(prim) status = \ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
258 purple_status_type_new_with_attrs( \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
259 prim, /* PurpleStatusPrimitive */ \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
260 NULL, /* id - use default */ \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
261 NULL, /* name - use default */ \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
262 TRUE, /* savable */ \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
263 TRUE, /* user_settable */ \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
264 FALSE, /* not independent */ \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
265 \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
266 /* Attributes - each status can have a message. */ \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
267 "message", \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
268 _("Message"), \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
269 purple_value_new(PURPLE_TYPE_STRING), \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
270 NULL); \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
271 \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
272 \ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
273 types = g_list_append(types, status) |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
274 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
275 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
276 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_AVAILABLE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
277 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_AWAY); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
278 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_OFFLINE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
279 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_INVISIBLE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
280 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
281 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
282 return types; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
283 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
284 |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
285 /** Get zap types. */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
286 GList * |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
287 msim_attention_types(PurpleAccount *acct) |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
288 { |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
289 static GList *types = NULL; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
290 PurpleAttentionType* attn; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
291 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
292 if (!types) { |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
293 #define _MSIM_ADD_NEW_ATTENTION(icn, des, incoming, outgoing) \ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
294 attn = g_new0(PurpleAttentionType, 1); \ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
295 attn->icon = icn; \ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
296 attn->description = des; \ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
297 attn->incoming_description = incoming; \ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
298 attn->outgoing_description = outgoing; \ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
299 types = g_list_append(types, attn); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
300 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
301 /* TODO: icons for each zap */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
302 _MSIM_ADD_NEW_ATTENTION(NULL, _("zap"), _("zapped"), _("Zapping")); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
303 _MSIM_ADD_NEW_ATTENTION(NULL, _("whack"), _("whacked"), _("Whacking")); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
304 _MSIM_ADD_NEW_ATTENTION(NULL, _("torch"), _("torched"), _("Torching")); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
305 _MSIM_ADD_NEW_ATTENTION(NULL, _("smooch"), _("smooched"), _("Smooching")); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
306 _MSIM_ADD_NEW_ATTENTION(NULL, _("hug"), _("hugged"), _("Hugging")); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
307 _MSIM_ADD_NEW_ATTENTION(NULL, _("bslap"), _("bslapped"), _("Bslapping")); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
308 _MSIM_ADD_NEW_ATTENTION(NULL, _("goose"), _("goosed"), _("Goosing")); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
309 _MSIM_ADD_NEW_ATTENTION(NULL, _("hi-five"), _("hi-fived"), _("Hi-fiving")); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
310 _MSIM_ADD_NEW_ATTENTION(NULL, _("punk"), _("punk'd"), _("Punking")); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
311 _MSIM_ADD_NEW_ATTENTION(NULL, _("raspberry"), _("raspberried"), _("Raspberry'ing")); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
312 } |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
313 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
314 return types; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
315 } |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
316 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
317 /** Send a zap */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
318 gboolean |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
319 msim_send_attention(PurpleConnection *gc, gchar *username, guint code) |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
320 { |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
321 GList *types; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
322 MsimSession *session; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
323 PurpleAttentionType *attn; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
324 PurpleBuddy *buddy; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
325 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
326 session = (MsimSession *)gc->proto_data; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
327 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
328 /* Look for this attention type, by the code index given. */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
329 types = msim_attention_types(gc->account); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
330 attn = (PurpleAttentionType *)g_list_nth_data(types, code); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
331 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
332 if (!attn) { |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
333 purple_debug_info("msim_send_attention", "got invalid zap code %d\n", code); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
334 return FALSE; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
335 } |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
336 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
337 buddy = purple_find_buddy(session->account, username); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
338 if (!buddy) { |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
339 return FALSE; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
340 } |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
341 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
342 /* TODO: make use of the PurpleAttentionType we found, instead of |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
343 * doing it all over in msim_send_zap_from_menu. */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
344 msim_send_zap_from_menu(&buddy->node, GUINT_TO_POINTER(code)); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
345 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
346 return TRUE; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
347 } |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
348 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
349 /** Send a zap to a user. */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
350 static gboolean |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
351 msim_send_zap(MsimSession *session, const gchar *username, guint code) |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
352 { |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
353 gchar *zap_string; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
354 #ifndef MSIM_USE_ATTENTION_API |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
355 gchar *zap_description; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
356 #endif |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
357 GList *types; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
358 PurpleAttentionType *attn; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
359 gboolean rc; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
360 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
361 g_return_val_if_fail(session != NULL, FALSE); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
362 g_return_val_if_fail(username != NULL, FALSE); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
363 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
364 types = msim_attention_types(session->account); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
365 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
366 attn = g_list_nth_data(types, code); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
367 if (!attn) { |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
368 return FALSE; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
369 } |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
370 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
371 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
372 #ifdef MSIM_USE_ATTENTION_API |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
373 serv_got_attention(session->gc, username, attn, FALSE); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
374 #else |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
375 zap_description = g_strdup_printf("*** Attention: %s %s ***", attn->outgoing_description, |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
376 username); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
377 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
378 serv_got_im(session->gc, username, zap_description, |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
379 PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
380 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
381 g_free(zap_description); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
382 #endif |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
383 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
384 /* Construct and send the actual zap command. */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
385 zap_string = g_strdup_printf("!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", code); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
386 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
387 if (!msim_send_bm(session, username, zap_string, MSIM_BM_ACTION)) { |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
388 purple_debug_info("msim_send_zap_from_menu", "msim_send_bm failed: zapping %s with %s", |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
389 username, zap_string); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
390 rc = FALSE; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
391 } else { |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
392 rc = TRUE; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
393 } |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
394 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
395 g_free(zap_string); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
396 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
397 return rc; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
398 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
399 } |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
400 |
17963
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
401 /** Zap someone. Callback from msim_blist_node_menu zap menu. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
402 static void |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
403 msim_send_zap_from_menu(PurpleBlistNode *node, gpointer zap_num_ptr) |
17963
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
404 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
405 PurpleBuddy *buddy; |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
406 PurpleAccount *account; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
407 PurpleConnection *gc; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
408 MsimSession *session; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
409 guint zap; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
410 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
411 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
412 /* Only know about buddies for now. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
413 return; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
414 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
415 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
416 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
417 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
418 buddy = (PurpleBuddy *)node; |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
419 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
420 /* Find the session */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
421 account = buddy->account; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
422 gc = purple_account_get_connection(account); |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
423 session = (MsimSession *)gc->proto_data; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
424 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
425 zap = GPOINTER_TO_INT(zap_num_ptr); |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
426 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
427 g_return_if_fail(msim_send_zap(session, buddy->name, zap)); |
17963
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
428 } |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
429 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
430 |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
431 /** Return menu, if any, for a buddy list node. */ |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
432 GList * |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
433 msim_blist_node_menu(PurpleBlistNode *node) |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
434 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
435 GList *menu, *zap_menu; |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
436 GList *types; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
437 PurpleMenuAction *act; |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
438 /* Warning: hardcoded to match that in msim_attention_types. */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
439 const gchar *zap_names[10]; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
440 guint i; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
441 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
442 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
443 /* Only know about buddies for now. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
444 return NULL; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
445 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
446 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
447 /* Names from official client. */ |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
448 types = msim_attention_types(NULL); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
449 i = 0; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
450 do |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
451 { |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
452 PurpleAttentionType *attn; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
453 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
454 attn = (PurpleAttentionType *)types->data; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
455 zap_names[i] = attn->description; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
456 ++i; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
457 } while ((types = g_list_next(types))); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
458 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
459 menu = zap_menu = NULL; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
460 |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
461 /* TODO: get rid of once is accessible directly in GUI */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
462 for (i = 0; i < sizeof(zap_names) / sizeof(zap_names[0]); ++i) { |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
463 act = purple_menu_action_new(zap_names[i], PURPLE_CALLBACK(msim_send_zap_from_menu), |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
464 GUINT_TO_POINTER(i), NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
465 zap_menu = g_list_append(zap_menu, act); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
466 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
467 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
468 act = purple_menu_action_new(_("Zap"), NULL, NULL, zap_menu); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
469 menu = g_list_append(menu, act); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
470 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
471 return menu; |
17963
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
472 } |
8305709dd0b9
Allow sending zaps through buddy list menu.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17962
diff
changeset
|
473 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
474 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
475 * Return the icon name for a buddy and account. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
476 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
477 * @param acct The account to find the icon for, or NULL for protocol icon. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
478 * @param buddy The buddy to find the icon for, or NULL for the account icon. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
479 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
480 * @return The base icon name string. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
481 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
482 const gchar * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
483 msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
484 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
485 /* Use a MySpace icon submitted by hbons at |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
486 * http://developer.pidgin.im/wiki/MySpaceIM. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
487 return "myspace"; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
488 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
489 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
490 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
491 * Replace 'old' with 'new' in 'str'. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
492 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
493 * @param str The original string. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
494 * @param old The substring of 'str' to replace. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
495 * @param new The replacement for 'old' within 'str'. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
496 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
497 * @return A _new_ string, based on 'str', with 'old' replaced |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
498 * by 'new'. Must be g_free()'d by caller. |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
499 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
500 * This string replace method is based on |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
501 * http://mail.gnome.org/archives/gtk-app-devel-list/2000-July/msg00201.html |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
502 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
503 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
504 gchar * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
505 str_replace(const gchar *str, const gchar *old, const gchar *new) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
506 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
507 gchar **items; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
508 gchar *ret; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
509 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
510 items = g_strsplit(str, old, -1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
511 ret = g_strjoinv(new, items); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
512 g_free(items); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
513 return ret; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
514 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
515 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
516 #ifdef MSIM_DEBUG_MSG |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
517 static void |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
518 print_hash_item(gpointer key, gpointer value, gpointer user_data) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
519 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
520 purple_debug_info("msim", "%s=%s\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
521 key ? (gchar *)key : "(NULL)", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
522 value ? (gchar *)value : "(NULL)"); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
523 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
524 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
525 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
526 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
527 * Send raw data (given as a NUL-terminated string) to the server. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
528 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
529 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
530 * @param msg The raw data to send, in a NUL-terminated string. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
531 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
532 * @return TRUE if succeeded, FALSE if not. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
533 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
534 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
535 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
536 msim_send_raw(MsimSession *session, const gchar *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
537 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
538 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
539 g_return_val_if_fail(msg != NULL, FALSE); |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
540 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
541 purple_debug_info("msim", "msim_send_raw: writing <%s>\n", msg); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
542 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
543 return msim_send_really_raw(session->gc, msg, strlen(msg)) == |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
544 strlen(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
545 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
546 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
547 /** Send raw data to the server, possibly with embedded NULs. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
548 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
549 * Used in prpl_info struct, so that plugins can have the most possible |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
550 * control of what is sent over the connection. Inside this prpl, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
551 * msim_send_raw() is used, since it sends NUL-terminated strings (easier). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
552 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
553 * @param gc PurpleConnection |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
554 * @param buf Buffer to send |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
555 * @param total_bytes Size of buffer to send |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
556 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
557 * @return Bytes successfully sent, or -1 on error. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
558 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
559 static int |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
560 msim_send_really_raw(PurpleConnection *gc, const char *buf, int total_bytes) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
561 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
562 int total_bytes_sent; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
563 MsimSession *session; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
564 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
565 g_return_val_if_fail(gc != NULL, -1); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
566 g_return_val_if_fail(buf != NULL, -1); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
567 g_return_val_if_fail(total_bytes >= 0, -1); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
568 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
569 session = (MsimSession *)gc->proto_data; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
570 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
571 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
572 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
573 /* Loop until all data is sent, or a failure occurs. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
574 total_bytes_sent = 0; |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
575 do { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
576 int bytes_sent; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
577 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
578 bytes_sent = send(session->fd, buf + total_bytes_sent, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
579 total_bytes - total_bytes_sent, 0); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
580 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
581 if (bytes_sent < 0) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
582 purple_debug_info("msim", "msim_send_raw(%s): send() failed: %s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
583 buf, g_strerror(errno)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
584 return total_bytes_sent; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
585 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
586 total_bytes_sent += bytes_sent; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
587 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
588 } while(total_bytes_sent < total_bytes); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
589 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
590 return total_bytes_sent; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
591 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
592 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
593 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
594 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
595 * Start logging in to the MSIM servers. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
596 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
597 * @param acct Account information to use to login. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
598 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
599 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
600 msim_login(PurpleAccount *acct) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
601 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
602 PurpleConnection *gc; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
603 const gchar *host; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
604 int port; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
605 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
606 g_return_if_fail(acct != NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
607 g_return_if_fail(acct->username != NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
608 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
609 purple_debug_info("msim", "logging in %s\n", acct->username); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
610 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
611 gc = purple_account_get_connection(acct); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
612 gc->proto_data = msim_session_new(acct); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
613 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_URLDESC; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
614 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
615 /* Passwords are limited in length. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
616 if (strlen(acct->password) > MSIM_MAX_PASSWORD_LENGTH) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
617 gchar *str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
618 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
619 str = g_strdup_printf( |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
620 _("Sorry, passwords over %d characters in length (yours is " |
18898
b94f831750e0
Clarify password-too-long error (MySpace limits it, not us), and clean up
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18897
diff
changeset
|
621 "%d) are not supported by MySpace."), |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
622 MSIM_MAX_PASSWORD_LENGTH, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
623 (int)strlen(acct->password)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
624 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
625 /* Notify an error message also, because this is important! */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
626 purple_notify_error(acct, g_strdup(_("MySpaceIM Error")), str, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
627 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
628 purple_connection_error(gc, str); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
629 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
630 g_free(str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
631 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
632 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
633 /* 1. connect to server */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
634 purple_connection_update_progress(gc, _("Connecting"), |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
635 0, /* which connection step this is */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
636 4); /* total number of steps */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
637 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
638 host = purple_account_get_string(acct, "server", MSIM_SERVER); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
639 port = purple_account_get_int(acct, "port", MSIM_PORT); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
640 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
641 /* From purple.sf.net/api: |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
642 * """Note that this function name can be misleading--although it is called |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
643 * "proxy connect," it is used for establishing any outgoing TCP connection, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
644 * whether through a proxy or not.""" */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
645 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
646 /* Calls msim_connect_cb when connected. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
647 if (!purple_proxy_connect(gc, acct, host, port, msim_connect_cb, gc)) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
648 /* TODO: try other ports if in auto mode, then save |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
649 * working port and try that first next time. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
650 purple_connection_error(gc, _("Couldn't create socket")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
651 return; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
652 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
653 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
654 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
655 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
656 * Process a login challenge, sending a response. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
657 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
658 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
659 * @param msg Login challenge message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
660 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
661 * @return TRUE if successful, FALSE if not |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
662 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
663 static gboolean |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
664 msim_login_challenge(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
665 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
666 PurpleAccount *account; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
667 const gchar *response; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
668 guint response_len; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
669 gchar *nc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
670 gsize nc_len; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
671 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
672 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
673 g_return_val_if_fail(msg != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
674 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
675 g_return_val_if_fail(msim_msg_get_binary(msg, "nc", &nc, &nc_len), FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
676 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
677 account = session->account; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
678 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
679 g_return_val_if_fail(account != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
680 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
681 purple_connection_update_progress(session->gc, _("Reading challenge"), 1, 4); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
682 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
683 purple_debug_info("msim", "nc is %d bytes, decoded\n", nc_len); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
684 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
685 if (nc_len != MSIM_AUTH_CHALLENGE_LENGTH) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
686 purple_debug_info("msim", "bad nc length: %x != 0x%x\n", nc_len, MSIM_AUTH_CHALLENGE_LENGTH); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
687 purple_connection_error(session->gc, _("Unexpected challenge length from server")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
688 return FALSE; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
689 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
690 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
691 purple_connection_update_progress(session->gc, _("Logging in"), 2, 4); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
692 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
693 response_len = 0; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
694 response = msim_compute_login_response(nc, account->username, account->password, &response_len); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
695 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
696 g_free(nc); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
697 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
698 return msim_send(session, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
699 "login2", MSIM_TYPE_INTEGER, MSIM_AUTH_ALGORITHM, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
700 /* This is actually user's email address. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
701 "username", MSIM_TYPE_STRING, g_strdup(account->username), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
702 /* GString and gchar * response will be freed in msim_msg_free() in msim_send(). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
703 "response", MSIM_TYPE_BINARY, g_string_new_len(response, response_len), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
704 "clientver", MSIM_TYPE_INTEGER, MSIM_CLIENT_VERSION, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
705 "langid", MSIM_TYPE_INTEGER, MSIM_LANGUAGE_ID_ENGLISH, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
706 "imlang", MSIM_TYPE_STRING, g_strdup(MSIM_LANGUAGE_NAME_ENGLISH), |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
707 "reconn", MSIM_TYPE_INTEGER, 0, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
708 "status", MSIM_TYPE_INTEGER, 100, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
709 "id", MSIM_TYPE_INTEGER, 1, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
710 NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
711 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
712 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
713 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
714 * Compute the base64'd login challenge response based on username, password, nonce, and IPs. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
715 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
716 * @param nonce The base64 encoded nonce ('nc') field from the server. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
717 * @param email User's email address (used as login name). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
718 * @param password User's cleartext password. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
719 * @param response_len Will be written with response length. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
720 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
721 * @return Binary login challenge response, ready to send to the server. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
722 * Must be g_free()'d when finished. NULL if error. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
723 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
724 static const gchar * |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
725 msim_compute_login_response(const gchar nonce[2 * NONCE_SIZE], |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
726 const gchar *email, const gchar *password, guint *response_len) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
727 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
728 PurpleCipherContext *key_context; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
729 PurpleCipher *sha1; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
730 PurpleCipherContext *rc4; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
731 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
732 guchar hash_pw[HASH_SIZE]; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
733 guchar key[HASH_SIZE]; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
734 gchar *password_utf16le, *password_utf8_lc; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
735 guchar *data; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
736 guchar *data_out; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
737 size_t data_len, data_out_len; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
738 gsize conv_bytes_read, conv_bytes_written; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
739 GError *conv_error; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
740 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
741 int i; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
742 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
743 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
744 g_return_val_if_fail(nonce != NULL, NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
745 g_return_val_if_fail(email != NULL, NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
746 g_return_val_if_fail(password != NULL, NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
747 g_return_val_if_fail(response_len != NULL, NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
748 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
749 /* Convert password to lowercase (required for passwords containing |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
750 * uppercase characters). MySpace passwords are lowercase, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
751 * see ticket #2066. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
752 password_utf8_lc = g_utf8_strdown(password, -1); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
753 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
754 /* Convert ASCII password to UTF16 little endian */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
755 purple_debug_info("msim", "converting password to UTF-16LE\n"); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
756 conv_error = NULL; |
18894
daedc9647341
Convert password to lowercase using g_utf8_strdown(), better because
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18893
diff
changeset
|
757 password_utf16le = g_convert(password_utf8_lc, -1, "UTF-16LE", "UTF-8", |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
758 &conv_bytes_read, &conv_bytes_written, &conv_error); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
759 g_free(password_utf8_lc); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
760 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
761 g_return_val_if_fail(conv_bytes_read == strlen(password), NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
762 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
763 if (conv_error != NULL) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
764 purple_debug_error("msim", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
765 "g_convert password UTF8->UTF16LE failed: %s", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
766 conv_error->message); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
767 g_error_free(conv_error); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
768 return NULL; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
769 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
770 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
771 /* Compute password hash */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
772 purple_cipher_digest_region("sha1", (guchar *)password_utf16le, |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
773 conv_bytes_written, sizeof(hash_pw), hash_pw, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
774 g_free(password_utf16le); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
775 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
776 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
777 purple_debug_info("msim", "pwhash = "); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
778 for (i = 0; i < sizeof(hash_pw); i++) |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
779 purple_debug_info("msim", "%.2x ", hash_pw[i]); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
780 purple_debug_info("msim", "\n"); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
781 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
782 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
783 /* key = sha1(sha1(pw) + nonce2) */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
784 sha1 = purple_ciphers_find_cipher("sha1"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
785 key_context = purple_cipher_context_new(sha1, NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
786 purple_cipher_context_append(key_context, hash_pw, HASH_SIZE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
787 purple_cipher_context_append(key_context, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
788 purple_cipher_context_digest(key_context, sizeof(key), key, NULL); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
789 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
790 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
791 purple_debug_info("msim", "key = "); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
792 for (i = 0; i < sizeof(key); i++) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
793 purple_debug_info("msim", "%.2x ", key[i]); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
794 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
795 purple_debug_info("msim", "\n"); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
796 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
797 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
798 rc4 = purple_cipher_context_new_by_name("rc4", NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
799 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
800 /* Note: 'key' variable is 0x14 bytes (from SHA-1 hash), |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
801 * but only first 0x10 used for the RC4 key. */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
802 purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
803 purple_cipher_context_set_key(rc4, key); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
804 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
805 /* TODO: obtain IPs of network interfaces */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
806 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
807 /* rc4 encrypt: |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
808 * nonce1+email+IP list */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
809 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
810 data_len = NONCE_SIZE + strlen(email) + MSIM_LOGIN_IP_LIST_LEN; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
811 data = g_new0(guchar, data_len); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
812 memcpy(data, nonce, NONCE_SIZE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
813 memcpy(data + NONCE_SIZE, email, strlen(email)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
814 memcpy(data + NONCE_SIZE + strlen(email), MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
815 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
816 data_out = g_new0(guchar, data_len); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
817 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
818 purple_cipher_context_encrypt(rc4, (const guchar *)data, |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
819 data_len, data_out, &data_out_len); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
820 purple_cipher_context_destroy(rc4); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
821 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
822 g_assert(data_out_len == data_len); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
823 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
824 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
825 purple_debug_info("msim", "response=<%s>\n", data_out); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
826 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
827 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
828 *response_len = data_out_len; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
829 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
830 return (const gchar *)data_out; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
831 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
832 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
833 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
834 * Schedule an IM to be sent once the user ID is looked up. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
835 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
836 * @param gc Connection. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
837 * @param who A user id, email, or username to send the message to. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
838 * @param message Instant message text to send. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
839 * @param flags Flags. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
840 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
841 * @return 1 if successful or postponed, -1 if failed |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
842 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
843 * Allows sending to a user by username, email address, or userid. If |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
844 * a username or email address is given, the userid must be looked up. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
845 * This function does that by calling msim_postprocess_outgoing(). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
846 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
847 int |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
848 msim_send_im(PurpleConnection *gc, const gchar *who, const gchar *message, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
849 PurpleMessageFlags flags) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
850 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
851 MsimSession *session; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
852 gchar *message_msim; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
853 int rc; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
854 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
855 g_return_val_if_fail(gc != NULL, -1); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
856 g_return_val_if_fail(who != NULL, -1); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
857 g_return_val_if_fail(message != NULL, -1); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
858 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
859 /* 'flags' has many options, not used here. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
860 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
861 session = (MsimSession *)gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
862 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
863 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
864 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
865 message_msim = html_to_msim_markup(session, message); |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
866 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
867 if (msim_send_bm(session, who, message_msim, MSIM_BM_INSTANT)) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
868 /* Return 1 to have Purple show this IM as being sent, 0 to not. I always |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
869 * return 1 even if the message could not be sent, since I don't know if |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
870 * it has failed yet--because the IM is only sent after the userid is |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
871 * retrieved from the server (which happens after this function returns). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
872 */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
873 /* TODO: maybe if message is delayed, don't echo to conv window, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
874 * but do echo it to conv window manually once it is actually |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
875 * sent? Would be complicated. */ |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
876 rc = 1; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
877 } else { |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
878 rc = -1; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
879 } |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
880 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
881 g_free(message_msim); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
882 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
883 /* |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
884 * In MySpace, you login with your email address, but don't talk to other |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
885 * users using their email address. So there is currently an asymmetry in the |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
886 * IM windows when using this plugin: |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
887 * |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
888 * you@example.com: hello |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
889 * some_other_user: what's going on? |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
890 * you@example.com: just coding a prpl |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
891 * |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
892 * TODO: Make the sent IM's appear as from the user's username, instead of |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
893 * their email address. Purple uses the login (in MSIM, the email)--change this. |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
894 */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
895 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
896 return rc; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
897 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
898 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
899 /** Send a buddy message of a given type. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
900 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
901 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
902 * @param who Username to send message to. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
903 * @param text Message text to send. Not freed; will be copied. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
904 * @param type A MSIM_BM_* constant. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
905 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
906 * @return TRUE if success, FALSE if fail. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
907 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
908 * Buddy messages ('bm') include instant messages, action messages, status messages, etc. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
909 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
910 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
911 static gboolean |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
912 msim_send_bm(MsimSession *session, const gchar *who, const gchar *text, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
913 int type) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
914 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
915 gboolean rc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
916 MsimMessage *msg; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
917 const gchar *from_username; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
918 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
919 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
920 g_return_val_if_fail(who != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
921 g_return_val_if_fail(text != NULL, FALSE); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
922 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
923 from_username = session->account->username; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
924 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
925 g_return_val_if_fail(from_username != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
926 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
927 purple_debug_info("msim", "sending %d message from %s to %s: %s\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
928 type, from_username, who, text); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
929 |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
930 msg = msim_msg_new( |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
931 "bm", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(type), |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
932 "sesskey", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(session->sesskey), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
933 /* 't' will be inserted here */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
934 "cv", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(MSIM_CLIENT_VERSION), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
935 "msg", MSIM_TYPE_STRING, g_strdup(text), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
936 NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
937 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
938 rc = msim_postprocess_outgoing(session, msg, who, "t", "cv"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
939 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
940 msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
941 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
942 return rc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
943 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
944 |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
945 /* Indexes of this array + 1 map HTML font size to scale of normal font size. * |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
946 * Based on _point_sizes from libpurple/gtkimhtml.c |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
947 * 1 2 3 4 5 6 7 */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
948 static gdouble _font_scale[] = { .85, .95, 1, 1.2, 1.44, 1.728, 2.0736 }; |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
949 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
950 #define MAX_FONT_SIZE 7 /* Purple maximum font size */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
951 #define POINTS_PER_INCH 72 /* How many pt's in an inch */ |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
952 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
953 /** Convert typographical font point size to HTML font size. |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
954 * Based on libpurple/gtkimhtml.c */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
955 static guint |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
956 msim_point_to_purple_size(MsimSession *session, guint point) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
957 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
958 guint size, this_point, base; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
959 gdouble scale; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
960 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
961 base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
962 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
963 for (size = 0; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
964 size < sizeof(_font_scale) / sizeof(_font_scale[0]); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
965 ++size) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
966 scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1]; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
967 this_point = (guint)msim_round(scale * base); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
968 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
969 if (this_point >= point) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
970 purple_debug_info("msim", "msim_point_to_purple_size: %d pt -> size=%d\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
971 point, size); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
972 return size; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
973 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
974 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
975 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
976 /* No HTML font size was this big; return largest possible. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
977 return this_point; |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
978 } |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
979 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
980 /** Convert HTML font size to point size. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
981 static guint |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
982 msim_purple_size_to_point(MsimSession *session, guint size) |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
983 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
984 gdouble scale; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
985 guint point; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
986 guint base; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
987 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
988 scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1]; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
989 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
990 base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
991 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
992 point = (guint)msim_round(scale * base); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
993 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
994 purple_debug_info("msim", "msim_purple_size_to_point: size=%d -> %d pt\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
995 size, point); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
996 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
997 return point; |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
998 } |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
999 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1000 /** Convert a msim markup font pixel height to the more usual point size, for incoming messages. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1001 static guint |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1002 msim_height_to_point(MsimSession *session, guint height) |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1003 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1004 guint dpi; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1005 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1006 dpi = purple_account_get_int(session->account, "port", MSIM_DEFAULT_DPI); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1007 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1008 return (guint)msim_round((POINTS_PER_INCH * 1. / dpi) * height); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1009 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1010 /* See also: libpurple/protocols/bonjour/jabber.c |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1011 * _font_size_ichat_to_purple */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1012 } |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1013 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1014 /** Convert point size to msim pixel height font size specification, for outgoing messages. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1015 static guint |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1016 msim_point_to_height(MsimSession *session, guint point) |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1017 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1018 guint dpi; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1019 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1020 dpi = purple_account_get_int(session->account, "port", MSIM_DEFAULT_DPI); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1021 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1022 return (guint)msim_round((dpi * 1. / POINTS_PER_INCH) * point); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1023 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1024 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1025 /** Convert the msim markup <f> (font) tag into HTML. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1026 static void |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1027 msim_markup_f_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1028 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1029 const gchar *face, *height_str, *decor_str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1030 GString *gs_end, *gs_begin; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1031 guint decor, height; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1032 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1033 face = xmlnode_get_attrib(root, "f"); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1034 height_str = xmlnode_get_attrib(root, "h"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1035 decor_str = xmlnode_get_attrib(root, "s"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1036 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1037 if (height_str) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1038 height = atol(height_str); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1039 } else { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1040 height = 12; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1041 } |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1042 |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1043 if (decor_str) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1044 decor = atol(decor_str); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1045 } else { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1046 decor = 0; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1047 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1048 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1049 gs_begin = g_string_new(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1050 /* TODO: get font size working */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1051 if (height && !face) { |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1052 g_string_printf(gs_begin, "<font size='%d'>", |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1053 msim_point_to_purple_size(session, msim_height_to_point(session, height))); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1054 } else if (height && face) { |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1055 g_string_printf(gs_begin, "<font face='%s' size='%d'>", face, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1056 msim_point_to_purple_size(session, msim_height_to_point(session, height))); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1057 } else { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1058 g_string_printf(gs_begin, "<font>"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1059 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1060 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1061 /* No support for font-size CSS? */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1062 /* g_string_printf(gs_begin, "<span style='font-family: %s; font-size: %dpt'>", face, |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1063 msim_height_to_point(height)); */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1064 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1065 gs_end = g_string_new("</font>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1066 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1067 if (decor & MSIM_TEXT_BOLD) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1068 g_string_append(gs_begin, "<b>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1069 g_string_prepend(gs_end, "</b>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1070 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1071 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1072 if (decor & MSIM_TEXT_ITALIC) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1073 g_string_append(gs_begin, "<i>"); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1074 g_string_append(gs_end, "</i>"); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1075 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1076 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1077 if (decor & MSIM_TEXT_UNDERLINE) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1078 g_string_append(gs_begin, "<u>"); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1079 g_string_append(gs_end, "</u>"); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1080 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1081 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1082 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1083 *begin = gs_begin->str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1084 *end = gs_end->str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1085 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1086 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1087 /** Convert a msim markup color to a color suitable for libpurple. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1088 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1089 * @param msim Either a color name, or an rgb(x,y,z) code. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1090 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1091 * @return A new string, either a color name or #rrggbb code. Must g_free(). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1092 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1093 static char * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1094 msim_color_to_purple(const char *msim) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1095 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1096 guint red, green, blue; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1097 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1098 if (!msim) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1099 return g_strdup("black"); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1100 } |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1101 |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1102 if (sscanf(msim, "rgb(%d,%d,%d)", &red, &green, &blue) != 3) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1103 /* Color name. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1104 return g_strdup(msim); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1105 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1106 /* TODO: rgba (alpha). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1107 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1108 return g_strdup_printf("#%.2x%.2x%.2x", red, green, blue); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1109 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1110 |
18904
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1111 /** Convert the msim markup <a> (anchor) tag into HTML. */ |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1112 static void |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1113 msim_markup_a_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1114 { |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1115 const gchar *href; |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1116 |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1117 href = xmlnode_get_attrib(root, "h"); |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1118 if (!href) { |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1119 href = ""; |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1120 } |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1121 |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1122 *begin = g_strdup_printf("<a href=\"%s\">%s", href, href); |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1123 *end = g_strdup("</a>"); |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1124 } |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1125 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1126 /** Convert the msim markup <p> (paragraph) tag into HTML. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1127 static void |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1128 msim_markup_p_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1129 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1130 /* Just pass through unchanged. |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1131 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1132 * Note: attributes currently aren't passed, if there are any. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1133 *begin = g_strdup("<p>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1134 *end = g_strdup("</p>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1135 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1136 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1137 /** Convert the msim markup <c> tag (text color) into HTML. TODO: Test */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1138 static void |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1139 msim_markup_c_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1140 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1141 const gchar *color; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1142 gchar *purple_color; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1143 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1144 color = xmlnode_get_attrib(root, "v"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1145 if (!color) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1146 purple_debug_info("msim", "msim_markup_c_to_html: <c> tag w/o v attr"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1147 *begin = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1148 *end = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1149 /* TODO: log as unrecognized */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1150 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1151 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1152 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1153 purple_color = msim_color_to_purple(color); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1154 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1155 *begin = g_strdup_printf("<font color='%s'>", purple_color); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1156 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1157 g_free(purple_color); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1158 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1159 /* *begin = g_strdup_printf("<span style='color: %s'>", color); */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1160 *end = g_strdup("</font>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1161 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1162 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1163 /** Convert the msim markup <b> tag (background color) into HTML. TODO: Test */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1164 static void |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1165 msim_markup_b_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1166 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1167 const gchar *color; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1168 gchar *purple_color; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1169 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1170 color = xmlnode_get_attrib(root, "v"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1171 if (!color) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1172 *begin = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1173 *end = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1174 purple_debug_info("msim", "msim_markup_b_to_html: <b> w/o v attr"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1175 /* TODO: log as unrecognized. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1176 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1177 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1178 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1179 purple_color = msim_color_to_purple(color); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1180 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1181 /* TODO: find out how to set background color. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1182 *begin = g_strdup_printf("<span style='background-color: %s'>", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1183 purple_color); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1184 g_free(purple_color); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1185 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1186 *end = g_strdup("</p>"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1187 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1188 |
17956
60f40fc52aa4
Support emoticons on incoming messages, approximating MySpaceIM's smileys
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17955
diff
changeset
|
1189 /** Convert the msim markup <i> tag (emoticon image) into HTML. */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1190 static void |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1191 msim_markup_i_to_html(MsimSession *session, xmlnode *root, gchar **begin, gchar **end) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1192 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1193 const gchar *name; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1194 guint i; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1195 struct MSIM_EMOTICON *emote; |
18903
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
1196 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1197 name = xmlnode_get_attrib(root, "n"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1198 if (!name) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1199 purple_debug_info("msim", "msim_markup_i_to_html: <i> w/o n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1200 *begin = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1201 *end = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1202 /* TODO: log as unrecognized */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1203 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1204 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1205 |
18903
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
1206 /* Find and use canonical form of smiley symbol. */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1207 for (i = 0; (emote = &msim_emoticons[i]) && emote->name != NULL; ++i) { |
18903
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
1208 if (!strcmp(name, emote->name)) { |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
1209 *begin = g_strdup(emote->symbol); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1210 *end = g_strdup(""); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1211 return; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1212 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1213 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1214 |
18903
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
1215 /* Couldn't find it, sorry. Try to degrade gracefully. */ |
3159f259bbe4
Support all emoticons used in the official MySpaceIM client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18899
diff
changeset
|
1216 *begin = g_strdup_printf("**%s**", name); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1217 *end = g_strdup(""); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1218 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1219 |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1220 /** Convert an individual msim markup tag to HTML. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1221 static void |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1222 msim_markup_tag_to_html(MsimSession *session, xmlnode *root, gchar **begin, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1223 gchar **end) |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1224 { |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1225 if (!strcmp(root->name, "f")) { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1226 msim_markup_f_to_html(session, root, begin, end); |
18904
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1227 } else if (!strcmp(root->name, "a")) { |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1228 msim_markup_a_to_html(session, root, begin, end); |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1229 } else if (!strcmp(root->name, "p")) { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1230 msim_markup_p_to_html(session, root, begin, end); |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1231 } else if (!strcmp(root->name, "c")) { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1232 msim_markup_c_to_html(session, root, begin, end); |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1233 } else if (!strcmp(root->name, "b")) { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1234 msim_markup_b_to_html(session, root, begin, end); |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1235 } else if (!strcmp(root->name, "i")) { |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1236 msim_markup_i_to_html(session, root, begin, end); |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1237 } else { |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1238 purple_debug_info("msim", "msim_markup_tag_to_html: " |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1239 "unknown tag name=%s, ignoring", |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1240 (root && root->name) ? root->name : "(NULL)"); |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1241 *begin = g_strdup(""); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1242 *end = g_strdup(""); |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1243 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1244 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1245 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1246 /** Convert an individual HTML tag to msim markup. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1247 static void |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1248 html_tag_to_msim_markup(MsimSession *session, xmlnode *root, gchar **begin, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1249 gchar **end) |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1250 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1251 /* TODO: Coalesce nested tags into one <f> tag! |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1252 * Currently, the 's' value will be overwritten when b/i/u is nested |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1253 * within another one, and only the inner-most formatting will be |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1254 * applied to the text. */ |
18918
abb5b6ec99a6
Change two strcmp()s to purple_utf8_strcasecmp() for case-insensitive comparison.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18916
diff
changeset
|
1255 if (!purple_utf8_strcasecmp(root->name, "root")) { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1256 *begin = g_strdup(""); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1257 *end = g_strdup(""); |
18918
abb5b6ec99a6
Change two strcmp()s to purple_utf8_strcasecmp() for case-insensitive comparison.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18916
diff
changeset
|
1258 } else if (!purple_utf8_strcasecmp(root->name, "b")) { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1259 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_BOLD); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1260 *end = g_strdup("</f>"); |
18918
abb5b6ec99a6
Change two strcmp()s to purple_utf8_strcasecmp() for case-insensitive comparison.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18916
diff
changeset
|
1261 } else if (!purple_utf8_strcasecmp(root->name, "i")) { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1262 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_ITALIC); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1263 *end = g_strdup("</f>"); |
18918
abb5b6ec99a6
Change two strcmp()s to purple_utf8_strcasecmp() for case-insensitive comparison.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18916
diff
changeset
|
1264 } else if (!purple_utf8_strcasecmp(root->name, "u")) { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1265 *begin = g_strdup_printf("<f s='%d'>", MSIM_TEXT_UNDERLINE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1266 *end = g_strdup("</f>"); |
18918
abb5b6ec99a6
Change two strcmp()s to purple_utf8_strcasecmp() for case-insensitive comparison.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18916
diff
changeset
|
1267 } else if (!purple_utf8_strcasecmp(root->name, "a")) { |
18904
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1268 const gchar *href, *link_text; |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1269 |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1270 href = xmlnode_get_attrib(root, "href"); |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1271 |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1272 if (!href) { |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1273 href = xmlnode_get_attrib(root, "HREF"); |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1274 } |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1275 |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1276 link_text = xmlnode_get_data(root); |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1277 |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1278 if (href) { |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1279 if (!strcmp(link_text, href)) { |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1280 /* Purple gives us: <a href="URL">URL</a> |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1281 * Translate to <a h='URL' /> |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1282 * Displayed as text of URL with link to URL |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1283 */ |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1284 *begin = g_strdup_printf("<a h='%s' />", href); |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1285 } else { |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1286 /* But if we get: <a href="URL">text</a> |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1287 * Translate to: text: <a h='URL' /> |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1288 * |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1289 * Because official client only supports self-closed <a> |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1290 * tags; you can't change the link text. |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1291 */ |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1292 *begin = g_strdup_printf("%s: <a h='%s' />", link_text, href); |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1293 } |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1294 } else { |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1295 *begin = g_strdup("<a />"); |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1296 } |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1297 |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1298 /* Sorry, kid. MySpace doesn't support you within <a> tags. */ |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1299 xmlnode_free(root->child); |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1300 root->child = NULL; |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1301 |
da2f37d232a9
Support sending and receiving hyperlinks.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18903
diff
changeset
|
1302 *end = g_strdup(""); |
18918
abb5b6ec99a6
Change two strcmp()s to purple_utf8_strcasecmp() for case-insensitive comparison.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18916
diff
changeset
|
1303 } else if (!purple_utf8_strcasecmp(root->name, "font")) { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1304 const gchar *size; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1305 const gchar *face; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1306 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1307 size = xmlnode_get_attrib(root, "size"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1308 face = xmlnode_get_attrib(root, "face"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1309 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1310 if (face && size) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1311 *begin = g_strdup_printf("<f f='%s' h='%d'>", face, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1312 msim_point_to_height(session, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1313 msim_purple_size_to_point(session, atoi(size)))); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1314 } else if (face) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1315 *begin = g_strdup_printf("<f f='%s'>", face); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1316 } else if (size) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1317 *begin = g_strdup_printf("<f h='%d'>", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1318 msim_point_to_height(session, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1319 msim_purple_size_to_point(session, atoi(size)))); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1320 } else { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1321 *begin = g_strdup("<f>"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1322 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1323 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1324 *end = g_strdup("</f>"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1325 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1326 /* TODO: color (bg uses <body>), emoticons */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1327 } else { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1328 *begin = g_strdup_printf("[%s]", root->name); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1329 *end = g_strdup_printf("[/%s]", root->name); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1330 } |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1331 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1332 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1333 /** Convert an xmlnode of msim markup or HTML to an HTML string or msim markup. |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1334 * |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1335 * @param f Function to convert tags. |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1336 * |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1337 * @return An HTML string. Caller frees. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1338 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1339 static gchar * |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1340 msim_convert_xmlnode(MsimSession *session, xmlnode *root, MSIM_XMLNODE_CONVERT f) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1341 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1342 xmlnode *node; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1343 gchar *begin, *inner, *end; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1344 GString *final; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1345 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1346 if (!root || !root->name) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1347 return g_strdup(""); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1348 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1349 |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1350 purple_debug_info("msim", "msim_convert_xmlnode: got root=%s\n", |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1351 root->name); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1352 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1353 begin = inner = end = NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1354 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1355 final = g_string_new(""); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1356 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1357 f(session, root, &begin, &end); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1358 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1359 g_string_append(final, begin); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1360 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1361 /* Loop over all child nodes. */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1362 for (node = root->child; node != NULL; node = node->next) { |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1363 switch (node->type) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1364 case XMLNODE_TYPE_ATTRIB: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1365 /* Attributes handled above. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1366 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1367 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1368 case XMLNODE_TYPE_TAG: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1369 /* A tag or tag with attributes. Recursively descend. */ |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1370 inner = msim_convert_xmlnode(session, node, f); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1371 g_return_val_if_fail(inner != NULL, NULL); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1372 |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1373 purple_debug_info("msim", " ** node name=%s\n", |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1374 (node && node->name) ? node->name : "(NULL)"); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1375 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1376 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1377 case XMLNODE_TYPE_DATA: |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1378 /* Literal text. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1379 inner = g_new0(char, node->data_sz + 1); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1380 strncpy(inner, node->data, node->data_sz); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1381 inner[node->data_sz] = 0; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1382 |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1383 purple_debug_info("msim", " ** node data=%s\n", |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1384 inner ? inner : "(NULL)"); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1385 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1386 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1387 default: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1388 purple_debug_info("msim", |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1389 "msim_convert_xmlnode: strange node\n"); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1390 inner = g_strdup(""); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1391 } |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1392 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1393 if (inner) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1394 g_string_append(final, inner); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1395 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1396 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1397 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1398 /* TODO: Note that msim counts each piece of text enclosed by <f> as |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1399 * a paragraph and will display each on its own line. You actually have |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1400 * to _nest_ <f> tags to intersperse different text in one paragraph! |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1401 * Comment out this line below to see. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1402 g_string_append(final, end); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1403 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1404 purple_debug_info("msim", "msim_markup_xmlnode_to_gtkhtml: RETURNING %s\n", |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1405 (final && final->str) ? final->str : "(NULL)"); |
17946
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1406 |
b3e971b375b5
Support font sizes in sending and receiving formatted text.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17945
diff
changeset
|
1407 return final->str; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1408 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1409 |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1410 /** Convert XML to something based on MSIM_XMLNODE_CONVERT. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1411 static gchar * |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1412 msim_convert_xml(MsimSession *session, const gchar *raw, MSIM_XMLNODE_CONVERT f) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1413 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1414 xmlnode *root; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1415 gchar *str; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1416 gchar *enclosed_raw; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1417 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1418 g_return_val_if_fail(raw != NULL, NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1419 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1420 /* Enclose text in one root tag, to try to make it valid XML for parsing. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1421 enclosed_raw = g_strconcat("<root>", raw, "</root>", NULL); |
17958
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1422 |
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1423 root = xmlnode_from_str(enclosed_raw, -1); |
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1424 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1425 if (!root) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1426 purple_debug_info("msim", "msim_markup_to_html: couldn't parse " |
17958
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1427 "%s as XML, returning raw: %s\n", enclosed_raw, raw); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1428 /* TODO: msim_unrecognized */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1429 g_free(enclosed_raw); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1430 return g_strdup(raw); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1431 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1432 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1433 g_free(enclosed_raw); |
17958
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
1434 |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1435 str = msim_convert_xmlnode(session, root, f); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1436 g_return_val_if_fail(str != NULL, NULL); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1437 purple_debug_info("msim", "msim_markup_to_html: returning %s\n", str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1438 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1439 xmlnode_free(root); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1440 |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1441 return str; |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1442 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1443 |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1444 /** Convert plaintext smileys to <i> markup tags. |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1445 * |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1446 * @param before Original text with ASCII smileys. Will be freed. |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1447 * @return A new string with <i> tags, if applicable. Must be g_free()'d. |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1448 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1449 static gchar * |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1450 msim_convert_smileys_to_markup(gchar *before) |
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1451 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1452 gchar *old, *new, *replacement; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1453 guint i; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1454 struct MSIM_EMOTICON *emote; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1455 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1456 old = before; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1457 new = NULL; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1458 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1459 for (i = 0; (emote = &msim_emoticons[i]) && emote->name != NULL; ++i) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1460 gchar *name, *symbol; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1461 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1462 name = emote->name; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1463 symbol = emote->symbol; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1464 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1465 replacement = g_strdup_printf("<i n=\"%s\"/>", name); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1466 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1467 purple_debug_info("msim", "msim_convert_smileys_to_markup: %s->%s\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1468 symbol ? symbol : "(NULL)", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1469 replacement ? replacement : "(NULL)"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1470 new = str_replace(old, symbol, replacement); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1471 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1472 g_free(replacement); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1473 g_free(old); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1474 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1475 old = new; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1476 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1477 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1478 return new; |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1479 } |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1480 |
17957
3bd88cbdd204
Add support for sending emoticons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17956
diff
changeset
|
1481 |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1482 /** High-level function to convert MySpaceIM markup to Purple (HTML) markup. |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1483 * |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1484 * @return Purple markup string, must be g_free()'d. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1485 static gchar * |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1486 msim_markup_to_html(MsimSession *session, const gchar *raw) |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1487 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1488 return msim_convert_xml(session, raw, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1489 (MSIM_XMLNODE_CONVERT)(msim_markup_tag_to_html)); |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1490 } |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1491 |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1492 /** High-level function to convert Purple (HTML) to MySpaceIM markup. |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1493 * |
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1494 * @return HTML markup string, must be g_free()'d. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1495 static gchar * |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1496 html_to_msim_markup(MsimSession *session, const gchar *raw) |
17938
13bba54b429d
Support sending some formatted text in instant messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17936
diff
changeset
|
1497 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1498 gchar *markup; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1499 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1500 markup = msim_convert_xml(session, raw, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1501 (MSIM_XMLNODE_CONVERT)(html_tag_to_msim_markup)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1502 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1503 if (purple_account_get_bool(session->account, "emoticons", TRUE)) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1504 /* Frees markup and allocates a new one. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1505 markup = msim_convert_smileys_to_markup(markup); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1506 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1507 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1508 return markup; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1509 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1510 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1511 /** Get the MsimUser from a PurpleBuddy, creating it if needed. */ |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1512 static MsimUser * |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1513 msim_get_user_from_buddy(PurpleBuddy *buddy) |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1514 { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1515 MsimUser *user; |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1516 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1517 if (!buddy) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1518 return NULL; |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1519 } |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1520 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1521 if (!buddy->proto_data) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1522 /* TODO: where is this freed? */ |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1523 user = g_new0(MsimUser, 1); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1524 user->buddy = buddy; |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1525 buddy->proto_data = (gpointer)user; |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1526 purple_debug_info("msim_get_user_from_buddy", |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1527 "creating new user for %s to %X\n", |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1528 buddy->name, buddy->proto_data); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1529 } |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1530 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1531 user = (MsimUser *)(buddy->proto_data); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1532 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1533 return user; |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1534 } |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1535 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1536 /** Find and return an MsimUser * representing a user on the buddy list, or NULL. */ |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1537 static MsimUser * |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1538 msim_find_user(MsimSession *session, const gchar *username) |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1539 { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1540 PurpleBuddy *buddy; |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1541 MsimUser *user; |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1542 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1543 buddy = purple_find_buddy(session->account, username); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1544 if (!buddy) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1545 return NULL; |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1546 } |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1547 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1548 user = msim_get_user_from_buddy(buddy); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1549 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1550 return user; |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1551 } |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1552 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1553 |
17955
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1554 /** Record the client version in the buddy list, from an incoming message. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1555 static gboolean |
17955
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1556 msim_incoming_bm_record_cv(MsimSession *session, MsimMessage *msg) |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1557 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1558 gchar *username, *cv; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1559 gboolean ret; |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1560 MsimUser *user; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1561 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1562 username = msim_msg_get_string(msg, "_username"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1563 cv = msim_msg_get_string(msg, "cv"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1564 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1565 g_return_val_if_fail(username != NULL, FALSE); |
18908
6541b0edee26
Fix some assertion failures, that should really not be assertions. Found by using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18907
diff
changeset
|
1566 if (!cv) { |
6541b0edee26
Fix some assertion failures, that should really not be assertions. Found by using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18907
diff
changeset
|
1567 /* No client version to record, don't worry about it. */ |
6541b0edee26
Fix some assertion failures, that should really not be assertions. Found by using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18907
diff
changeset
|
1568 return FALSE; |
6541b0edee26
Fix some assertion failures, that should really not be assertions. Found by using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18907
diff
changeset
|
1569 } |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1570 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1571 user = msim_find_user(session, username); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1572 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1573 if (user) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1574 user->client_cv = atol(cv); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1575 ret = TRUE; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1576 } else { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1577 ret = FALSE; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1578 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1579 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1580 g_free(username); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1581 g_free(cv); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1582 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1583 return ret; |
17955
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1584 } |
9e8943111022
Show official client build in buddy profiles.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17954
diff
changeset
|
1585 |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1586 /** Handle an incoming buddy message. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1587 static gboolean |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1588 msim_incoming_bm(MsimSession *session, MsimMessage *msg) |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1589 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1590 guint bm; |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1591 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1592 bm = msim_msg_get_integer(msg, "bm"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1593 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1594 msim_incoming_bm_record_cv(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1595 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1596 switch (bm) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1597 case MSIM_BM_STATUS: |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1598 return msim_incoming_status(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1599 case MSIM_BM_INSTANT: |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1600 return msim_incoming_im(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1601 case MSIM_BM_ACTION: |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1602 return msim_incoming_action(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1603 case MSIM_BM_MEDIA: |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1604 return msim_incoming_media(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1605 case MSIM_BM_UNOFFICIAL_CLIENT: |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1606 return msim_incoming_unofficial_client(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1607 default: |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1608 /* Not really an IM, but show it for informational |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1609 * purposes during development. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1610 return msim_incoming_im(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1611 } |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1612 } |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1613 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1614 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1615 * Handle an incoming instant message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1616 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1617 * @param session The session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1618 * @param msg Message from the server, containing 'f' (userid from) and 'msg'. |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1619 * Should also contain username in _username from preprocessing. |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1620 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1621 * @return TRUE if successful. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1622 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1623 static gboolean |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1624 msim_incoming_im(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1625 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1626 gchar *username, *msg_msim_markup, *msg_purple_markup; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1627 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1628 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1629 g_return_val_if_fail(msg != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1630 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1631 username = msim_msg_get_string(msg, "_username"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1632 g_return_val_if_fail(username != NULL, FALSE); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1633 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1634 msg_msim_markup = msim_msg_get_string(msg, "msg"); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1635 g_return_val_if_fail(msg_msim_markup != NULL, FALSE); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1636 |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
1637 msg_purple_markup = msim_markup_to_html(session, msg_msim_markup); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1638 g_free(msg_msim_markup); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1639 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1640 serv_got_im(session->gc, username, msg_purple_markup, |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1641 PURPLE_MESSAGE_RECV, time(NULL)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1642 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1643 g_free(username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1644 g_free(msg_purple_markup); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1645 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1646 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1647 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1648 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1649 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1650 * Process unrecognized information. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1651 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1652 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1653 * @param msg An MsimMessage that was unrecognized, or NULL. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1654 * @param note Information on what was unrecognized, or NULL. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1655 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1656 static void |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1657 msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1658 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1659 /* TODO: Some more context, outwardly equivalent to a backtrace, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1660 * for helping figure out what this msg is for. What was going on? |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1661 * But not too much information so that a user |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1662 * posting this dump reveals confidential information. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1663 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1664 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1665 /* TODO: dump unknown msgs to file, so user can send them to me |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1666 * if they wish, to help add support for new messages (inspired |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1667 * by Alexandr Shutko, who maintains OSCAR protocol documentation). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1668 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1669 purple_debug_info("msim", "Unrecognized data on account for %s\n", |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1670 session->account->username ? session->account->username |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1671 : "(NULL)"); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1672 if (note) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1673 purple_debug_info("msim", "(Note: %s)\n", note); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1674 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1675 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1676 if (msg) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1677 msim_msg_dump("Unrecognized message dump: %s\n", msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1678 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1679 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1680 |
17962
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1681 /** Process an incoming zap. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1682 static gboolean |
17962
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1683 msim_incoming_zap(MsimSession *session, MsimMessage *msg) |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1684 { |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1685 gchar *msg_text, *username; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1686 gint zap; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1687 const gchar *zap_past_tense[10]; |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1688 #ifdef MSIM_USE_ATTENTION_API |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1689 PurpleAttentionType attn; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1690 #else |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1691 gchar *zap_text; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1692 #endif |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1693 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1694 zap_past_tense[0] = _("zapped"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1695 zap_past_tense[1] = _("whacked"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1696 zap_past_tense[2] = _("torched"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1697 zap_past_tense[3] = _("smooched"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1698 zap_past_tense[4] = _("hugged"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1699 zap_past_tense[5] = _("bslapped"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1700 zap_past_tense[6] = _("goosed"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1701 zap_past_tense[7] = _("hi-fived"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1702 zap_past_tense[8] = _("punk'd"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1703 zap_past_tense[9] = _("raspberried"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1704 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1705 msg_text = msim_msg_get_string(msg, "msg"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1706 username = msim_msg_get_string(msg, "_username"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1707 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1708 g_return_val_if_fail(msg_text != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1709 g_return_val_if_fail(username != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1710 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1711 g_return_val_if_fail(sscanf(msg_text, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_%d", &zap) == 1, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1712 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1713 zap = CLAMP(zap, 0, sizeof(zap_past_tense) / sizeof(zap_past_tense[0])); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1714 |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1715 /* TODO:ZAP: use msim_attention_types */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1716 #ifdef MSIM_USE_ATTENTION_API |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1717 attn.incoming_description = zap_past_tense[zap]; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1718 attn.outgoing_description = NULL; |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1719 attn.icon = NULL; /* TODO: icon */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1720 |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1721 serv_got_attention(session->gc, username, &attn, TRUE); |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1722 #else |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1723 zap_text = g_strdup_printf(_("*** You have been %s! ***"), zap_past_tense[zap]); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1724 serv_got_im(session->gc, username, zap_text, |
17962
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1725 PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM, time(NULL)); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1726 g_free(zap_text); |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1727 #endif |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
1728 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1729 g_free(msg_text); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1730 g_free(username); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1731 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1732 return TRUE; |
17962
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1733 } |
8e351e08aba0
Support incoming zaps.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17961
diff
changeset
|
1734 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1735 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1736 * Handle an incoming action message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1737 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1738 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1739 * @param msg |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1740 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1741 * @return TRUE if successful. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1742 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1743 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1744 static gboolean |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1745 msim_incoming_action(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1746 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1747 gchar *msg_text, *username; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1748 gboolean rc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1749 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1750 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1751 g_return_val_if_fail(msg != NULL, FALSE); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1752 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1753 msg_text = msim_msg_get_string(msg, "msg"); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1754 g_return_val_if_fail(msg_text != NULL, FALSE); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1755 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1756 username = msim_msg_get_string(msg, "_username"); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1757 g_return_val_if_fail(username != NULL, FALSE); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1758 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1759 purple_debug_info("msim", "msim_incoming_action: action <%s> from <%d>\n", |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1760 msg_text, username); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1761 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
1762 if (strcmp(msg_text, "%typing%") == 0) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1763 /* TODO: find out if msim repeatedly sends typing messages, so we can |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1764 * give it a timeout. Right now, there does seem to be an inordinately |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1765 * amount of time between typing stopped-typing notifications. */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1766 serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1767 rc = TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1768 } else if (strcmp(msg_text, "%stoptyping%") == 0) { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1769 serv_got_typing_stopped(session->gc, username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1770 rc = TRUE; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1771 } else if (strstr(msg_text, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_")) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1772 rc = msim_incoming_zap(session, msg); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1773 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1774 msim_unrecognized(session, msg, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1775 "got to msim_incoming_action but unrecognized value for 'msg'"); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1776 rc = FALSE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1777 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1778 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1779 g_free(msg_text); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1780 g_free(username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1781 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1782 return rc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1783 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1784 |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1785 /* Process an incoming media (buddy icon) message. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1786 static gboolean |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1787 msim_incoming_media(MsimSession *session, MsimMessage *msg) |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1788 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1789 gchar *username, *text; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1790 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1791 username = msim_msg_get_string(msg, "_username"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1792 text = msim_msg_get_string(msg, "msg"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1793 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1794 g_return_val_if_fail(username != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1795 g_return_val_if_fail(text != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1796 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1797 purple_debug_info("msim", "msim_incoming_media: from %s, got msg=%s\n", username, text); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1798 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1799 /* Media messages are sent when the user opens a window to someone. |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1800 * Tell libpurple they started typing and stopped typing, to inform the Psychic |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1801 * Mode plugin so it too can open a window to the user. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1802 serv_got_typing(session->gc, username, 0, PURPLE_TYPING); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1803 serv_got_typing_stopped(session->gc, username); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1804 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1805 g_free(username); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1806 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1807 return TRUE; |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1808 } |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1809 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1810 /* Process an incoming "unofficial client" message. The plugin for |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1811 * Miranda IM sends this message with the plugin information. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1812 static gboolean |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1813 msim_incoming_unofficial_client(MsimSession *session, MsimMessage *msg) |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1814 { |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1815 MsimUser *user; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1816 gchar *username, *client_info; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1817 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1818 username = msim_msg_get_string(msg, "_username"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1819 client_info = msim_msg_get_string(msg, "msg"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1820 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1821 g_return_val_if_fail(username != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1822 g_return_val_if_fail(client_info != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1823 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1824 purple_debug_info("msim", "msim_incoming_unofficial_client: %s is using client %s\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1825 username, client_info); |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1826 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1827 user = msim_find_user(session, username); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1828 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1829 g_return_val_if_fail(user != NULL, FALSE); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1830 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1831 if (user->client_info) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1832 g_free(user->client_info); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1833 } |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1834 user->client_info = client_info; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1835 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1836 g_free(username); |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1837 /* Do not free client_info - the MsimUser now owns it. */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1838 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1839 return TRUE; |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1840 } |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1841 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1842 |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1843 #ifdef MSIM_SEND_CLIENT_VERSION |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1844 /** Send our client version to another unofficial client that understands it. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1845 static gboolean |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1846 msim_send_unofficial_client(MsimSession *session, gchar *username) |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1847 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1848 gchar *our_info; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1849 gboolean ret; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1850 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1851 our_info = g_strdup_printf("Libpurple %d.%d.%d - msimprpl %s", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1852 PURPLE_MAJOR_VERSION, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1853 PURPLE_MINOR_VERSION, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1854 PURPLE_MICRO_VERSION, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1855 MSIM_PRPL_VERSION_STRING); |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1856 |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1857 ret = msim_send_bm(session, username, our_info, MSIM_BM_UNOFFICIAL_CLIENT); |
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1858 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1859 return ret; |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1860 } |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
1861 #endif |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
1862 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1863 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1864 * Handle when our user starts or stops typing to another user. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1865 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1866 * @param gc |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1867 * @param name The buddy name to which our user is typing to |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1868 * @param state PURPLE_TYPING, PURPLE_TYPED, PURPLE_NOT_TYPING |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1869 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1870 * @return 0 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1871 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1872 unsigned int |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1873 msim_send_typing(PurpleConnection *gc, const gchar *name, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1874 PurpleTypingState state) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1875 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1876 const gchar *typing_str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1877 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1878 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1879 g_return_val_if_fail(gc != NULL, 0); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1880 g_return_val_if_fail(name != NULL, 0); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1881 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1882 session = (MsimSession *)gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1883 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1884 g_return_val_if_fail(MSIM_SESSION_VALID(session), 0); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1885 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1886 switch (state) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1887 case PURPLE_TYPING: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1888 typing_str = "%typing%"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1889 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1890 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1891 case PURPLE_TYPED: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1892 case PURPLE_NOT_TYPING: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1893 default: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1894 typing_str = "%stoptyping%"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1895 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1896 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1897 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1898 purple_debug_info("msim", "msim_send_typing(%s): %d (%s)\n", name, state, typing_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1899 msim_send_bm(session, name, typing_str, MSIM_BM_ACTION); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1900 return 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1901 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1902 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1903 /** Format the "now playing" indicator, showing the artist and song. |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1904 * @return Return a new string (must be g_free()'d), or NULL. |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1905 */ |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1906 static gchar * |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1907 msim_format_now_playing(gchar *band, gchar *song) |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1908 { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1909 if ((band && strlen(band)) || (song && strlen(song))) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1910 return g_strdup_printf("%s - %s", |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1911 (band && strlen(band)) ? band : "Unknown Artist", |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1912 (song && strlen(song)) ? song : "Unknown Song"); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1913 } else { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1914 return NULL; |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1915 } |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1916 } |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1917 |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1918 /** Append user information to a PurpleNotifyUserInfo, given an MsimUser. |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1919 * Used by msim_tooltip_text() and msim_get_info_cb() to show a user's profile. |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1920 */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1921 static void |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1922 msim_append_user_info(MsimSession *session, PurpleNotifyUserInfo *user_info, MsimUser *user, gboolean full) |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1923 { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1924 gchar *str; |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1925 guint uid; |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1926 guint cv; |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1927 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1928 /* Useful to identify the account the tooltip refers to. |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1929 * Other prpls show this. */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1930 if (user->username) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1931 purple_notify_user_info_add_pair(user_info, _("User"), user->username); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1932 } |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1933 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1934 uid = purple_blist_node_get_int(&user->buddy->node, "UserID"); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1935 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1936 if (full) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1937 purple_notify_user_info_add_pair(user_info, _("User ID"), g_strdup_printf("%d", uid)); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1938 } |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1939 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1940 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1941 /* a/s/l...the vitals */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1942 if (user->age) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1943 purple_notify_user_info_add_pair(user_info, _("Age"), |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1944 g_strdup_printf("%d", user->age)); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1945 } |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1946 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1947 if (user->gender && strlen(user->gender)) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1948 purple_notify_user_info_add_pair(user_info, _("Gender"), user->gender); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1949 } |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1950 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1951 if (user->location && strlen(user->location)) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1952 purple_notify_user_info_add_pair(user_info, _("Location"), user->location); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1953 } |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1954 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1955 /* Other information */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1956 if (user->headline && strlen(user->headline)) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1957 purple_notify_user_info_add_pair(user_info, _("Headline"), user->headline); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1958 } |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1959 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1960 str = msim_format_now_playing(user->band_name, user->song_name); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1961 if (str && strlen(str)) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1962 purple_notify_user_info_add_pair(user_info, _("Song"), str); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1963 } |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1964 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1965 /* Note: total friends only available if looked up by uid, not username. */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1966 if (user->total_friends) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1967 purple_notify_user_info_add_pair(user_info, _("Total Friends"), |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1968 g_strdup_printf("%d", user->total_friends)); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1969 } |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1970 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1971 if (full) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1972 /* Client information */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1973 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1974 str = user->client_info; |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1975 cv = user->client_cv; |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1976 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1977 if (str && cv != 0) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1978 purple_notify_user_info_add_pair(user_info, _("Client Version"), |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1979 g_strdup_printf("%s (build %d)", str, cv)); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1980 } else if (str) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1981 purple_notify_user_info_add_pair(user_info, _("Client Version"), |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1982 g_strdup(str)); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1983 } else if (cv) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1984 purple_notify_user_info_add_pair(user_info, _("Client Version"), |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1985 g_strdup_printf("Build %d", cv)); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1986 } |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1987 } |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1988 } |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1989 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1990 /** Callback for msim_get_info(), for when user info is received. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1991 static void |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
1992 msim_get_info_cb(MsimSession *session, MsimMessage *user_info_msg, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
1993 gpointer data) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1994 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1995 MsimMessage *msg; |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1996 gchar *username; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
1997 PurpleNotifyUserInfo *user_info; |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
1998 MsimUser *user; |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
1999 gboolean temporary_user; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2000 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2001 g_return_if_fail(MSIM_SESSION_VALID(session)); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2002 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2003 /* Get user{name,id} from msim_get_info, passed as an MsimMessage for |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2004 orthogonality. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2005 msg = (MsimMessage *)data; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2006 g_return_if_fail(msg != NULL); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2007 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2008 username = msim_msg_get_string(msg, "user"); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2009 if (!username) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2010 purple_debug_info("msim", "msim_get_info_cb: no 'user' in msg"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2011 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2012 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2013 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2014 msim_msg_free(msg); |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2015 purple_debug_info("msim", "msim_get_info_cb: got for user: %s\n", username); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2016 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2017 user = msim_find_user(session, username); |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2018 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2019 if (!user) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2020 /* User isn't on blist, create a temporary user to store info. */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2021 temporary_user = TRUE; |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2022 user = g_new0(MsimUser, 1); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2023 } else { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2024 temporary_user = FALSE; |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2025 } |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2026 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2027 /* Update user structure with new information */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2028 msim_store_user_info(session, user_info_msg, user); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2029 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2030 user_info = purple_notify_user_info_new(); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2031 |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2032 /* Append data from MsimUser to PurpleNotifyUserInfo for display, full */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2033 msim_append_user_info(session, user_info, user, TRUE); |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
2034 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2035 purple_notify_userinfo(session->gc, username, user_info, NULL, NULL); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2036 purple_debug_info("msim", "msim_get_info_cb: username=%s\n", username); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2037 |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2038 purple_notify_user_info_destroy(user_info); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2039 /* TODO: do not free username, since it will be used by user_info? */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2040 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2041 if (temporary_user) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2042 g_free(user->client_info); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2043 g_free(user->gender); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2044 g_free(user->location); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2045 g_free(user->headline); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2046 g_free(user->display_name); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2047 g_free(user->username); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2048 g_free(user->band_name); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2049 g_free(user->song_name); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2050 g_free(user->image_url); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2051 g_free(user); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2052 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2053 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2054 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2055 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2056 /** Retrieve a user's profile. |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2057 * @param username Username, user ID, or email address to lookup. |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2058 */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2059 void |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2060 msim_get_info(PurpleConnection *gc, const gchar *username) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2061 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2062 MsimSession *session; |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2063 MsimUser *user; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2064 guint uid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2065 gchar *user_to_lookup; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2066 MsimMessage *user_msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2067 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2068 g_return_if_fail(gc != NULL); |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2069 g_return_if_fail(username != NULL); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2070 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2071 session = (MsimSession *)gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2072 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2073 g_return_if_fail(MSIM_SESSION_VALID(session)); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2074 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2075 /* Obtain uid of buddy. */ |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2076 user = msim_find_user(session, username); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2077 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2078 /* If is on buddy list, lookup by uid since it is faster. */ |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2079 if (user && (uid = purple_blist_node_get_int(&user->buddy->node, "UserID"))) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2080 user_to_lookup = g_strdup_printf("%d", uid); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2081 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2082 /* Looking up buddy not on blist. Lookup by whatever user entered. */ |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2083 user_to_lookup = g_strdup(username); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2084 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2085 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2086 /* Pass the username to msim_get_info_cb(), because since we lookup |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2087 * by userid, the userinfo message will only contain the uid (not |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2088 * the username) but it would be useful to display the username too. |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2089 */ |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
2090 user_msg = msim_msg_new( |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2091 "user", MSIM_TYPE_STRING, g_strdup(username), |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2092 NULL); |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2093 purple_debug_info("msim", "msim_get_info, setting up lookup, user=%s\n", username); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2094 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2095 msim_lookup_user(session, user_to_lookup, msim_get_info_cb, user_msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2096 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2097 g_free(user_to_lookup); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2098 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2099 |
17945
cf55077a3752
Remove MSIM_FAKE_SELF_ONLINE option, since our own status is actually updated
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17944
diff
changeset
|
2100 /** Set your status - callback for when user manually sets it. */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2101 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2102 msim_set_status(PurpleAccount *account, PurpleStatus *status) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2103 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2104 PurpleStatusType *type; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2105 MsimSession *session; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2106 guint status_code; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2107 const gchar *statstring; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2108 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2109 session = (MsimSession *)account->gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2110 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2111 g_return_if_fail(MSIM_SESSION_VALID(session)); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2112 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2113 type = purple_status_get_type(status); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2114 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2115 switch (purple_status_type_get_primitive(type)) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2116 case PURPLE_STATUS_AVAILABLE: |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2117 purple_debug_info("msim", "msim_set_status: available (%d->%d)\n", PURPLE_STATUS_AVAILABLE, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2118 MSIM_STATUS_CODE_ONLINE); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2119 status_code = MSIM_STATUS_CODE_ONLINE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2120 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2121 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2122 case PURPLE_STATUS_INVISIBLE: |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2123 purple_debug_info("msim", "msim_set_status: invisible (%d->%d)\n", PURPLE_STATUS_INVISIBLE, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2124 MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2125 status_code = MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2126 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2127 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2128 case PURPLE_STATUS_AWAY: |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2129 purple_debug_info("msim", "msim_set_status: away (%d->%d)\n", PURPLE_STATUS_AWAY, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2130 MSIM_STATUS_CODE_AWAY); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2131 status_code = MSIM_STATUS_CODE_AWAY; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2132 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2133 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2134 default: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2135 purple_debug_info("msim", "msim_set_status: unknown " |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2136 "status interpreting as online"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2137 status_code = MSIM_STATUS_CODE_ONLINE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2138 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2139 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2140 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2141 statstring = purple_status_get_attr_string(status, "message"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2142 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2143 if (!statstring) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2144 statstring = g_strdup(""); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2145 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2146 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2147 msim_set_status_code(session, status_code, g_strdup(statstring)); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2148 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2149 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2150 /** Go idle. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2151 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2152 msim_set_idle(PurpleConnection *gc, int time) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2153 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2154 MsimSession *session; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2155 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2156 g_return_if_fail(gc != NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2157 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2158 session = (MsimSession *)gc->proto_data; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2159 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2160 g_return_if_fail(MSIM_SESSION_VALID(session)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2161 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2162 if (time == 0) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2163 /* Going back from idle. In msim, idle is mutually exclusive |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2164 * from the other states (you can only be away or idle, but not |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2165 * both, for example), so by going non-idle I go online. |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2166 */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2167 /* TODO: find out how to keep old status string? */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2168 msim_set_status_code(session, MSIM_STATUS_CODE_ONLINE, g_strdup("")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2169 } else { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2170 /* msim doesn't support idle time, so just go idle */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2171 msim_set_status_code(session, MSIM_STATUS_CODE_IDLE, g_strdup("")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2172 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2173 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2174 |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
2175 /** Set status using an MSIM_STATUS_CODE_* value. |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
2176 * @param status_code An MSIM_STATUS_CODE_* value. |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
2177 * @param statstring Status string, must be a dynamic string (will be freed by msim_send). |
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
2178 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2179 static void |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
2180 msim_set_status_code(MsimSession *session, guint status_code, gchar *statstring) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2181 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2182 g_return_if_fail(MSIM_SESSION_VALID(session)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2183 g_return_if_fail(statstring != NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2184 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2185 purple_debug_info("msim", "msim_set_status_code: going to set status to code=%d,str=%s\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2186 status_code, statstring); |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
2187 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2188 if (!msim_send(session, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2189 "status", MSIM_TYPE_INTEGER, status_code, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2190 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
17944
c109b7f1c739
Allow setting status string messages. Known bug: custom status messages always
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17942
diff
changeset
|
2191 "statstring", MSIM_TYPE_STRING, statstring, |
17939
65cf1785e5bf
Fix compile warnings on Unix (missing sentinel and time_t to int typecast).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17938
diff
changeset
|
2192 "locstring", MSIM_TYPE_STRING, g_strdup(""), |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2193 NULL)) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2194 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2195 purple_debug_info("msim", "msim_set_status: failed to set status"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2196 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2197 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2198 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2199 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2200 /** After a uid is resolved to username, tag it with the username and submit for processing. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2201 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2202 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2203 * @param userinfo Response messsage to resolving request. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2204 * @param data MsimMessage *, the message to attach information to. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2205 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2206 static void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2207 msim_incoming_resolved(MsimSession *session, MsimMessage *userinfo, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2208 gpointer data) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2209 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2210 gchar *body_str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2211 GHashTable *body; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2212 gchar *username; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2213 MsimMessage *msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2214 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2215 g_return_if_fail(MSIM_SESSION_VALID(session)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2216 g_return_if_fail(userinfo != NULL); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2217 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2218 body_str = msim_msg_get_string(userinfo, "body"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2219 g_return_if_fail(body_str != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2220 body = msim_parse_body(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2221 g_return_if_fail(body != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2222 g_free(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2223 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2224 username = g_hash_table_lookup(body, "UserName"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2225 g_return_if_fail(username != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2226 |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2227 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2228 msg = (MsimMessage *)data; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2229 g_return_if_fail(msg != NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2230 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2231 /* TODO: more elegant solution than below. attach whole message? */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2232 /* Special elements name beginning with '_', we'll use internally within the |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2233 * program (did not come directly from the wire). */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2234 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
2235 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2236 /* TODO: attach more useful information, like ImageURL */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2237 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2238 msim_process(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2239 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2240 /* TODO: Free copy cloned from msim_preprocess_incoming(). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2241 //XXX msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2242 g_hash_table_destroy(body); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2243 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2244 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2245 /* Lookup a username by userid, from buddy list. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2246 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2247 * @param wanted_uid |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2248 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2249 * @return Username of wanted_uid, if on blist, or NULL. Static string. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2250 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2251 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2252 static const gchar * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2253 msim_uid2username_from_blist(MsimSession *session, guint wanted_uid) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2254 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2255 GSList *buddies, *cur; |
18898
b94f831750e0
Clarify password-too-long error (MySpace limits it, not us), and clean up
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18897
diff
changeset
|
2256 gchar *ret; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2257 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2258 buddies = purple_find_buddies(session->account, NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2259 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2260 if (!buddies) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2261 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2262 purple_debug_info("msim", "msim_uid2username_from_blist: no buddies?"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2263 return NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2264 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2265 |
18898
b94f831750e0
Clarify password-too-long error (MySpace limits it, not us), and clean up
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18897
diff
changeset
|
2266 ret = NULL; |
b94f831750e0
Clarify password-too-long error (MySpace limits it, not us), and clean up
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18897
diff
changeset
|
2267 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2268 for (cur = buddies; cur != NULL; cur = g_slist_next(cur)) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2269 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2270 PurpleBuddy *buddy; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2271 guint uid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2272 const gchar *name; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2273 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2274 /* See finch/gnthistory.c */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2275 buddy = cur->data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2276 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2277 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
18898
b94f831750e0
Clarify password-too-long error (MySpace limits it, not us), and clean up
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18897
diff
changeset
|
2278 name = purple_buddy_get_name(buddy); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2279 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2280 if (uid == wanted_uid) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2281 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2282 ret = g_strdup(name); |
18898
b94f831750e0
Clarify password-too-long error (MySpace limits it, not us), and clean up
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18897
diff
changeset
|
2283 break; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2284 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2285 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2286 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2287 g_slist_free(buddies); |
18898
b94f831750e0
Clarify password-too-long error (MySpace limits it, not us), and clean up
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18897
diff
changeset
|
2288 return ret; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2289 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2290 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2291 /** Preprocess incoming messages, resolving as needed, calling msim_process() when ready to process. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2292 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2293 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2294 * @param msg MsimMessage *, freed by caller. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2295 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2296 static gboolean |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2297 msim_preprocess_incoming(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2298 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2299 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2300 g_return_val_if_fail(msg != NULL, FALSE); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2301 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2302 if (msim_msg_get(msg, "bm") && msim_msg_get(msg, "f")) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2303 guint uid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2304 const gchar *username; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2305 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2306 /* 'f' = userid message is from, in buddy messages */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2307 uid = msim_msg_get_integer(msg, "f"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2308 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2309 username = msim_uid2username_from_blist(session, uid); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2310 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2311 if (username) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2312 /* Know username already, use it. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2313 purple_debug_info("msim", "msim_preprocess_incoming: tagging with _username=%s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2314 username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2315 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2316 return msim_process(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2317 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2318 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2319 gchar *from; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2320 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2321 /* Send lookup request. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2322 /* XXX: where is msim_msg_get_string() freed? make _strdup and _nonstrdup. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2323 purple_debug_info("msim", "msim_incoming: sending lookup, setting up callback\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2324 from = msim_msg_get_string(msg, "f"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2325 msim_lookup_user(session, from, msim_incoming_resolved, msim_msg_clone(msg)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2326 g_free(from); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2327 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2328 /* indeterminate */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2329 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2330 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2331 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2332 /* Nothing to resolve - send directly to processing. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2333 return msim_process(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2334 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2335 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2336 |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2337 #ifdef MSIM_USE_KEEPALIVE |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2338 /** Check if the connection is still alive, based on last communication. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2339 static gboolean |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2340 msim_check_alive(gpointer data) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2341 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2342 MsimSession *session; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2343 time_t delta; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2344 gchar *errmsg; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2345 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2346 session = (MsimSession *)data; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2347 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2348 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2349 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2350 delta = time(NULL) - session->last_comm; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2351 //purple_debug_info("msim", "msim_check_alive: delta=%d\n", delta); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2352 if (delta >= MSIM_KEEPALIVE_INTERVAL) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2353 errmsg = g_strdup_printf(_("Connection to server lost (no data received within %d seconds)"), (int)delta); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2354 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2355 purple_debug_info("msim", "msim_check_alive: %s > interval of %d, presumed dead\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2356 errmsg, MSIM_KEEPALIVE_INTERVAL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2357 purple_connection_error(session->gc, errmsg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2358 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2359 purple_notify_error(session->gc, NULL, errmsg, NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2360 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2361 g_free(errmsg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2362 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2363 return FALSE; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2364 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2365 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2366 return TRUE; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2367 } |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2368 #endif |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2369 |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2370 /** Handle mail reply checks. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2371 static void |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2372 msim_check_inbox_cb(MsimSession *session, MsimMessage *reply, gpointer data) |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2373 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2374 GHashTable *body; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2375 gchar *body_str; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2376 GString *notification; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2377 guint old_inbox_status; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2378 guint i, n; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2379 const gchar *froms[5], *tos[5], *urls[5], *subjects[5]; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2380 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2381 /* Three parallel arrays for each new inbox message type. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2382 static const gchar *inbox_keys[] = |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2383 { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2384 "Mail", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2385 "BlogComment", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2386 "ProfileComment", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2387 "FriendRequest", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2388 "PictureComment" |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2389 }; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2390 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2391 static const guint inbox_bits[] = |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2392 { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2393 MSIM_INBOX_MAIL, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2394 MSIM_INBOX_BLOG_COMMENT, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2395 MSIM_INBOX_PROFILE_COMMENT, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2396 MSIM_INBOX_FRIEND_REQUEST, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2397 MSIM_INBOX_PICTURE_COMMENT |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2398 }; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2399 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2400 static const gchar *inbox_urls[] = |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2401 { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2402 "http://messaging.myspace.com/index.cfm?fuseaction=mail.inbox", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2403 "http://blog.myspace.com/index.cfm?fuseaction=blog", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2404 "http://home.myspace.com/index.cfm?fuseaction=user", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2405 "http://messaging.myspace.com/index.cfm?fuseaction=mail.friendRequests", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2406 "http://home.myspace.com/index.cfm?fuseaction=user" |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2407 }; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2408 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2409 static const gchar *inbox_text[5]; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2410 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2411 /* Can't write _()'d strings in array initializers. Workaround. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2412 inbox_text[0] = _("New mail messages"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2413 inbox_text[1] = _("New blog comments"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2414 inbox_text[2] = _("New profile comments"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2415 inbox_text[3] = _("New friend requests!"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2416 inbox_text[4] = _("New picture comments"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2417 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2418 g_return_if_fail(reply != NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2419 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2420 msim_msg_dump("msim_check_inbox_cb: reply=%s\n", reply); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2421 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2422 body_str = msim_msg_get_string(reply, "body"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2423 g_return_if_fail(body_str != NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2424 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2425 body = msim_parse_body(body_str); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2426 g_free(body_str); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2427 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2428 notification = g_string_new(""); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2429 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2430 old_inbox_status = session->inbox_status; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2431 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2432 n = 0; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2433 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2434 for (i = 0; i < sizeof(inbox_keys) / sizeof(inbox_keys[0]); ++i) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2435 const gchar *key; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2436 guint bit; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2437 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2438 key = inbox_keys[i]; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2439 bit = inbox_bits[i]; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2440 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2441 if (g_hash_table_lookup(body, key)) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2442 /* Notify only on when _changes_ from no mail -> has mail |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2443 * (edge triggered) */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2444 if (!(session->inbox_status & bit)) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2445 purple_debug_info("msim", "msim_check_inbox_cb: got %s, at %d\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2446 key ? key : "(NULL)", n); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2447 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2448 subjects[n] = inbox_text[i]; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2449 froms[n] = _("MySpace"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2450 tos[n] = session->username; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2451 /* TODO: append token, web challenge, so automatically logs in. |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2452 * Would also need to free strings because they won't be static |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2453 */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2454 urls[n] = inbox_urls[i]; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2455 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2456 ++n; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2457 } else { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2458 purple_debug_info("msim", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2459 "msim_check_inbox_cb: already notified of %s\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2460 key ? key : "(NULL)"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2461 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2462 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2463 session->inbox_status |= bit; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2464 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2465 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2466 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2467 if (n) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2468 purple_debug_info("msim", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2469 "msim_check_inbox_cb: notifying of %d\n", n); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2470 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2471 /* TODO: free strings with callback _if_ change to dynamic (w/ token) */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2472 purple_notify_emails(session->gc, /* handle */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2473 n, /* count */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2474 TRUE, /* detailed */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2475 subjects, froms, tos, urls, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2476 NULL, /* PurpleNotifyCloseCallback cb */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2477 NULL); /* gpointer user_data */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2478 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2479 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2480 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2481 g_hash_table_destroy(body); |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2482 } |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2483 |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2484 /* Send request to check if there is new mail. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2485 static gboolean |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2486 msim_check_inbox(gpointer data) |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2487 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2488 MsimSession *session; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2489 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2490 session = (MsimSession *)data; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2491 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2492 purple_debug_info("msim", "msim_check_inbox: checking mail\n"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2493 g_return_val_if_fail(msim_send(session, |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2494 "persist", MSIM_TYPE_INTEGER, 1, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2495 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2496 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_GET, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2497 "dsn", MSIM_TYPE_INTEGER, MG_CHECK_MAIL_DSN, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2498 "lid", MSIM_TYPE_INTEGER, MG_CHECK_MAIL_LID, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2499 "uid", MSIM_TYPE_INTEGER, session->userid, |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2500 "rid", MSIM_TYPE_INTEGER, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2501 msim_new_reply_callback(session, msim_check_inbox_cb, NULL), |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2502 "body", MSIM_TYPE_STRING, g_strdup(""), |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2503 NULL), TRUE); |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2504 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2505 /* Always return true, so that we keep checking for mail. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2506 return TRUE; |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2507 } |
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2508 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2509 /** Called when the session key arrives. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2510 static gboolean |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2511 msim_we_are_logged_on(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2512 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2513 MsimMessage *body; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2514 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2515 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2516 g_return_val_if_fail(msg != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2517 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2518 session->sesskey = msim_msg_get_integer(msg, "sesskey"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2519 purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2520 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2521 /* What is proof? Used to be uid, but now is 52 base64'd bytes... */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2522 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2523 /* Comes with: proof,profileid,userid,uniquenick -- all same values |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2524 * some of the time, but can vary. This is our own user ID. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2525 session->userid = msim_msg_get_integer(msg, "userid"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2526 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2527 /* Not sure what profileid is used for. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2528 if (msim_msg_get_integer(msg, "profileid") != session->userid) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2529 msim_unrecognized(session, msg, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2530 "Profile ID didn't match user ID, don't know why"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2531 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2532 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2533 /* We now know are our own username, only after we're logged in.. |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2534 * which is weird, but happens because you login with your email |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2535 * address and not username. Will be freed in msim_session_destroy(). */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2536 session->username = msim_msg_get_string(msg, "uniquenick"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2537 |
18909
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
2538 /* The session is now set up, ready to be connected. This emits the |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
2539 * signedOn signal, so clients can now do anything with msimprpl, and |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
2540 * we're ready for it (session key, userid, username all setup). */ |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
2541 purple_connection_update_progress(session->gc, _("Connected"), 3, 4); |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
2542 purple_connection_set_state(session->gc, PURPLE_CONNECTED); |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
2543 |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
2544 |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
2545 /* Additional post-connect operations */ |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
2546 |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
2547 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2548 if (msim_msg_get_integer(msg, "uniquenick") == session->userid) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2549 purple_debug_info("msim_we_are_logged_on", "TODO: pick username"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2550 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2551 |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
2552 body = msim_msg_new( |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2553 "UserID", MSIM_TYPE_INTEGER, session->userid, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2554 NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2555 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2556 /* Request IM info about ourself. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2557 msim_send(session, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2558 "persist", MSIM_TYPE_STRING, g_strdup("persist"), |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2559 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2560 "dsn", MSIM_TYPE_INTEGER, MG_OWN_MYSPACE_INFO_DSN, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2561 "uid", MSIM_TYPE_INTEGER, session->userid, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2562 "lid", MSIM_TYPE_INTEGER, MG_OWN_MYSPACE_INFO_LID, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2563 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2564 "body", MSIM_TYPE_DICTIONARY, body, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2565 NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2566 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2567 /* Request MySpace info about ourself. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2568 msim_send(session, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2569 "persist", MSIM_TYPE_STRING, g_strdup("persist"), |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2570 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2571 "dsn", MSIM_TYPE_INTEGER, MG_OWN_IM_INFO_DSN, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2572 "uid", MSIM_TYPE_INTEGER, session->userid, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2573 "lid", MSIM_TYPE_INTEGER, MG_OWN_IM_INFO_LID, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2574 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2575 "body", MSIM_TYPE_STRING, g_strdup(""), |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2576 NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2577 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2578 /* TODO: set options (persist cmd=514,dsn=1,lid=10) */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2579 /* TODO: set blocklist */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2580 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2581 /* Notify servers of our current status. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2582 purple_debug_info("msim", "msim_we_are_logged_on: notifying servers of status\n"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2583 msim_set_status(session->account, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2584 purple_account_get_active_status(session->account)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2585 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2586 /* TODO: setinfo */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2587 /* |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
2588 body = msim_msg_new( |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2589 "TotalFriends", MSIM_TYPE_INTEGER, 666, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2590 NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2591 msim_send(session, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2592 "setinfo", MSIM_TYPE_BOOLEAN, TRUE, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2593 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2594 "info", MSIM_TYPE_DICTIONARY, body, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2595 NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2596 */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2597 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2598 /* Disable due to problems with timeouts. TODO: fix. */ |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2599 #ifdef MSIM_USE_KEEPALIVE |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2600 purple_timeout_add(MSIM_KEEPALIVE_INTERVAL_CHECK, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2601 (GSourceFunc)msim_check_alive, session); |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
2602 #endif |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2603 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2604 purple_timeout_add(MSIM_MAIL_INTERVAL_CHECK, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2605 (GSourceFunc)msim_check_inbox, session); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2606 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2607 msim_check_inbox(session); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2608 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2609 return TRUE; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2610 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2611 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2612 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2613 * Process a message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2614 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2615 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2616 * @param msg A message from the server, ready for processing (possibly with resolved username information attached). Caller frees. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2617 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2618 * @return TRUE if successful. FALSE if processing failed. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2619 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2620 static gboolean |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2621 msim_process(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2622 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2623 g_return_val_if_fail(session != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2624 g_return_val_if_fail(msg != NULL, FALSE); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2625 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2626 #ifdef MSIM_DEBUG_MSG |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2627 msim_msg_dump("ready to process: %s\n", msg); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2628 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2629 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2630 if (msim_msg_get_integer(msg, "lc") == 1) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2631 return msim_login_challenge(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2632 } else if (msim_msg_get_integer(msg, "lc") == 2) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2633 return msim_we_are_logged_on(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2634 } else if (msim_msg_get(msg, "bm")) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2635 return msim_incoming_bm(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2636 } else if (msim_msg_get(msg, "rid")) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2637 return msim_process_reply(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2638 } else if (msim_msg_get(msg, "error")) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2639 return msim_error(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2640 } else if (msim_msg_get(msg, "ka")) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2641 return TRUE; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2642 } else { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2643 msim_unrecognized(session, msg, "in msim_process"); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2644 return FALSE; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2645 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2646 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2647 |
18915
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2648 /** Callback for when a buddy icon finished being downloaded. */ |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2649 static void |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2650 msim_downloaded_buddy_icon(PurpleUtilFetchUrlData *url_data, |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2651 gpointer user_data, |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2652 const gchar *url_text, |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2653 gsize len, |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2654 const gchar *error_message) |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2655 { |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2656 MsimUser *user; |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2657 |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2658 user = (MsimUser *)user_data; |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2659 |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2660 purple_debug_info("msim_downloaded_buddy_icon", |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2661 "Downloaded %d bytes\n", len); |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2662 |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2663 purple_buddy_icons_set_for_user(user->buddy->account, |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2664 user->buddy->name, |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2665 (gchar *)url_text, len, |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2666 /* Use URL itself as buddy icon "checksum" */ |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2667 user->image_url); |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2668 } |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2669 |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2670 /** Store a field of information about a buddy. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2671 static void |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2672 msim_store_user_info_each(gpointer key, gpointer value, gpointer user_data) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2673 { |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2674 MsimUser *user; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2675 gchar *key_str, *value_str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2676 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2677 user = (MsimUser *)user_data; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2678 key_str = (gchar *)key; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2679 value_str = (gchar *)value; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2680 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2681 if (!strcmp(key_str, "UserID")) { |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2682 /* Save to buddy list, if it exists, for quick cached uid lookup with msim_uid2username_from_blist(). */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2683 if (user->buddy) |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2684 { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2685 purple_debug_info("msim", "associating uid %s with username %s\n", key_str, user->buddy->name); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2686 purple_blist_node_set_int(&user->buddy->node, "UserID", atol(value_str)); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2687 } |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2688 /* Need to store in MsimUser, too? What if not on blist? */ |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2689 } else if (!strcmp(key_str, "Age")) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2690 user->age = atol(value_str); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2691 } else if (!strcmp(key_str, "Gender")) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2692 user->gender = g_strdup(value_str); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2693 } else if (!strcmp(key_str, "Location")) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2694 user->location = g_strdup(value_str); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2695 } else if (!strcmp(key_str, "TotalFriends")) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2696 user->total_friends = atol(value_str); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2697 } else if (!strcmp(key_str, "DisplayName")) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2698 user->display_name = g_strdup(value_str); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2699 } else if (!strcmp(key_str, "BandName")) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2700 user->band_name = g_strdup(value_str); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2701 } else if (!strcmp(key_str, "SongName")) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2702 user->song_name = g_strdup(value_str); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2703 } else if (!strcmp(key_str, "UserName")) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2704 /* Ignore because PurpleBuddy knows this already */ |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2705 ; |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2706 } else if (!strcmp(key_str, "ImageURL")) { |
18915
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2707 const gchar *previous_url; |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2708 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2709 user->image_url = g_strdup(value_str); |
18915
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2710 |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2711 previous_url = purple_buddy_icons_get_checksum_for_user(user->buddy); |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2712 |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2713 /* Only download if URL changed */ |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2714 if (!previous_url || strcmp(previous_url, user->image_url)) { |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2715 purple_util_fetch_url(user->image_url, TRUE, NULL, TRUE, msim_downloaded_buddy_icon, (gpointer)user); |
bfc52862d864
Show buddy icons.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18914
diff
changeset
|
2716 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2717 } else { |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2718 /* TODO: other fields in MsimUser */ |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2719 gchar *msg; |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2720 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2721 msg = g_strdup_printf("msim_store_user_info_each: unknown field %s=%s", |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2722 key_str, value_str); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2723 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2724 msim_unrecognized(NULL, NULL, msg); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2725 |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2726 g_free(msg); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2727 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2728 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2729 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2730 /** Save buddy information to the buddy list from a user info reply message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2731 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2732 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2733 * @param msg The user information reply, with any amount of information. |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2734 * @param user The structure to save to, or NULL to save in PurpleBuddy->proto_data. |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2735 * |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2736 * Variable information is saved to the passed MsimUser structure. Permanent |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2737 * information (UserID) is stored in the blist node of the buddy list (and |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2738 * ends up in blist.xml, persisted to disk) if it exists. |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2739 * |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2740 * If the function has no buddy information, this function |
18908
6541b0edee26
Fix some assertion failures, that should really not be assertions. Found by using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18907
diff
changeset
|
2741 * is a no-op (and returns FALSE). |
6541b0edee26
Fix some assertion failures, that should really not be assertions. Found by using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18907
diff
changeset
|
2742 * |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2743 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2744 static gboolean |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2745 msim_store_user_info(MsimSession *session, MsimMessage *msg, MsimUser *user) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2746 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2747 GHashTable *body; |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2748 gchar *username, *body_str; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2749 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2750 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2751 g_return_val_if_fail(msg != NULL, FALSE); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2752 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2753 body_str = msim_msg_get_string(msg, "body"); |
18908
6541b0edee26
Fix some assertion failures, that should really not be assertions. Found by using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18907
diff
changeset
|
2754 if (!body_str) { |
6541b0edee26
Fix some assertion failures, that should really not be assertions. Found by using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18907
diff
changeset
|
2755 return FALSE; |
6541b0edee26
Fix some assertion failures, that should really not be assertions. Found by using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18907
diff
changeset
|
2756 } |
6541b0edee26
Fix some assertion failures, that should really not be assertions. Found by using
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18907
diff
changeset
|
2757 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2758 g_return_val_if_fail(body_str != NULL, FALSE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2759 body = msim_parse_body(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2760 g_free(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2761 |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2762 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2763 /* TODO: implement a better hash-like interface, and use it. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2764 username = g_hash_table_lookup(body, "UserName"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2765 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
2766 if (!username) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2767 purple_debug_info("msim", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2768 "msim_process_reply: not caching body, no UserName\n"); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2769 g_hash_table_destroy(body); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2770 return FALSE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2771 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2772 |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2773 /* Null user = find and store in PurpleBuddy's proto_data */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2774 if (!user) { |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2775 user = msim_find_user(session, username); |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2776 g_return_val_if_fail(user != NULL, FALSE); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2777 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2778 |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2779 g_hash_table_foreach(body, msim_store_user_info_each, user); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2780 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2781 if (msim_msg_get_integer(msg, "dsn") == MG_OWN_IM_INFO_DSN && |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2782 msim_msg_get_integer(msg, "lid") == MG_OWN_IM_INFO_LID) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2783 /* TODO: do something with our own IM info, if we need it for some |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2784 * specific purpose. Otherwise it is available on the buddy list, |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2785 * if the user has themselves as their own buddy. |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2786 * |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2787 * However, much of the info is already available in MsimSession, |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2788 * stored in msim_we_are_logged_on(). */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2789 } else if (msim_msg_get_integer(msg, "dsn") == MG_OWN_MYSPACE_INFO_DSN && |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2790 msim_msg_get_integer(msg, "lid") == MG_OWN_MYSPACE_INFO_LID) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2791 /* TODO: same as above, but for MySpace info. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2792 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2793 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2794 g_hash_table_destroy(body); |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
2795 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2796 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2797 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2798 |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2799 /** Process the initial server information from the server. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2800 static gboolean |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2801 msim_process_server_info(MsimSession *session, MsimMessage *msg) |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2802 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2803 gchar *body_str; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2804 GHashTable *body; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2805 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2806 body_str = msim_msg_get_string(msg, "body"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2807 g_return_val_if_fail(body_str != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2808 body = msim_parse_body(body_str); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2809 g_free(body_str); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2810 g_return_val_if_fail(body != NULL, FALSE); |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2811 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2812 /* Example body: |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2813 AdUnitRefreshInterval=10. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2814 AlertPollInterval=360. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2815 AllowChatRoomEmoticonSharing=False. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2816 ChatRoomUserIDs=78744676;163733130;1300326231;123521495;142663391. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2817 CurClientVersion=673. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2818 EnableIMBrowse=True. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2819 EnableIMStuffAvatars=False. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2820 EnableIMStuffZaps=False. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2821 MaxAddAllFriends=100. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2822 MaxContacts=1000. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2823 MinClientVersion=594. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2824 MySpaceIM_ENGLISH=78744676. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2825 MySpaceNowTimer=720. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2826 PersistenceDataTimeout=900. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2827 UseWebChallenge=1. |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2828 WebTicketGoHome=False |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2829 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2830 Anything useful? TODO: use what is useful, and use it. |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2831 */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2832 purple_debug_info("msim_process_server_info", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2833 "maximum contacts: %s\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2834 g_hash_table_lookup(body, "MaxContacts") ? |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2835 g_hash_table_lookup(body, "MaxContacts") : "(NULL)"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2836 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2837 session->server_info = body; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2838 /* session->server_info freed in msim_session_destroy */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2839 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2840 return TRUE; |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2841 } |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2842 |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2843 /** Process a web challenge, used to login to the web site. */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2844 static gboolean |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2845 msim_web_challenge(MsimSession *session, MsimMessage *msg) |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2846 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2847 /* TODO: web challenge, store token */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2848 return FALSE; |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2849 } |
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
2850 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2851 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2852 * Process a persistance message reply from the server. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2853 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2854 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2855 * @param msg Message reply from server. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2856 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2857 * @return TRUE if successful. |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2858 * |
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
2859 * msim_lookup_user sets callback for here |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2860 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2861 static gboolean |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2862 msim_process_reply(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2863 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2864 MSIM_USER_LOOKUP_CB cb; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2865 gpointer data; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2866 guint rid, cmd, dsn, lid; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2867 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2868 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2869 g_return_val_if_fail(msg != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2870 |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
2871 msim_store_user_info(session, msg, NULL); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2872 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2873 rid = msim_msg_get_integer(msg, "rid"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2874 cmd = msim_msg_get_integer(msg, "cmd"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2875 dsn = msim_msg_get_integer(msg, "dsn"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2876 lid = msim_msg_get_integer(msg, "lid"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2877 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2878 /* Unsolicited messages */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2879 if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_GET)) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2880 if (dsn == MG_SERVER_INFO_DSN && lid == MG_SERVER_INFO_LID) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2881 return msim_process_server_info(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2882 } else if (dsn == MG_WEB_CHALLENGE_DSN && lid == MG_WEB_CHALLENGE_LID) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2883 return msim_web_challenge(session, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2884 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2885 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2886 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2887 /* If a callback is registered for this userid lookup, call it. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2888 cb = g_hash_table_lookup(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2889 data = g_hash_table_lookup(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2890 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2891 if (cb) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2892 purple_debug_info("msim", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2893 "msim_process_body: calling callback now\n"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2894 /* Clone message, so that the callback 'cb' can use it (needs to free it also). */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2895 cb(session, msim_msg_clone(msg), data); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2896 g_hash_table_remove(session->user_lookup_cb, GUINT_TO_POINTER(rid)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2897 g_hash_table_remove(session->user_lookup_cb_data, GUINT_TO_POINTER(rid)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2898 } else { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2899 purple_debug_info("msim", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2900 "msim_process_body: no callback for rid %d\n", rid); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2901 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2902 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2903 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2904 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2905 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2906 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2907 * Handle an error from the server. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2908 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2909 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2910 * @param msg The message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2911 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2912 * @return TRUE if successfully reported error. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2913 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2914 static gboolean |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2915 msim_error(MsimSession *session, MsimMessage *msg) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2916 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2917 gchar *errmsg, *full_errmsg; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2918 guint err; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2919 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2920 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2921 g_return_val_if_fail(msg != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2922 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2923 err = msim_msg_get_integer(msg, "err"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2924 errmsg = msim_msg_get_string(msg, "errmsg"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2925 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2926 full_errmsg = g_strdup_printf(_("Protocol error, code %d: %s"), err, |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2927 errmsg ? errmsg : "no 'errmsg' given"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2928 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2929 g_free(errmsg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2930 |
18909
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
2931 purple_debug_info("msim", "msim_error (sesskey=%d): %s\n", |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
2932 session->sesskey, full_errmsg); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2933 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2934 purple_notify_error(session->account, g_strdup(_("MySpaceIM Error")), |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2935 full_errmsg, NULL); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2936 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2937 /* Destroy session if fatal. */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2938 if (msim_msg_get(msg, "fatal")) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2939 purple_debug_info("msim", "fatal error, closing\n"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2940 purple_connection_error(session->gc, full_errmsg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2941 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2942 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2943 return TRUE; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2944 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2945 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2946 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2947 * Process incoming status messages. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2948 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2949 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2950 * @param msg Status update message. Caller frees. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2951 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2952 * @return TRUE if successful. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2953 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
2954 static gboolean |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
2955 msim_incoming_status(MsimSession *session, MsimMessage *msg) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2956 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2957 PurpleBuddyList *blist; |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2958 MsimUser *user; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2959 GList *list; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2960 gchar *status_headline; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2961 gint status_code, purple_status_code; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2962 gchar *username; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2963 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2964 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2965 g_return_val_if_fail(msg != NULL, FALSE); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2966 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2967 msim_msg_dump("msim_status msg=%s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2968 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2969 /* Helpfully looked up by msim_incoming_resolve() for us. */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2970 username = msim_msg_get_string(msg, "_username"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2971 g_return_val_if_fail(username != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2972 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2973 { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2974 gchar *ss; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2975 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2976 ss = msim_msg_get_string(msg, "msg"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2977 purple_debug_info("msim", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2978 "msim_status: updating status for <%s> to <%s>\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2979 username, ss ? ss : "(NULL)"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2980 g_free(ss); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2981 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2982 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2983 /* Example fields: |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2984 * |s|0|ss|Offline |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2985 * |s|1|ss|:-)|ls||ip|0|p|0 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2986 */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2987 list = msim_msg_get_list(msg, "msg"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2988 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2989 status_code = atoi(g_list_nth_data(list, MSIM_STATUS_ORDINAL_ONLINE)); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
2990 purple_debug_info("msim", "msim_status: %s's status code = %d\n", username, status_code); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2991 status_headline = g_list_nth_data(list, MSIM_STATUS_ORDINAL_HEADLINE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2992 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2993 blist = purple_get_blist(); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2994 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
2995 /* Add buddy if not found */ |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2996 user = msim_find_user(session, username); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2997 if (!user) { |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2998 PurpleBuddy *buddy; |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
2999 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3000 purple_debug_info("msim", |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3001 "msim_status: making new buddy for %s\n", username); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3002 buddy = purple_buddy_new(session->account, username, NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3003 purple_blist_add_buddy(buddy, NULL, NULL, NULL); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3004 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3005 user = msim_get_user_from_buddy(buddy); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3006 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3007 /* All buddies on list should have 'uid' integer associated with them. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3008 purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3009 |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
3010 msim_store_user_info(session, msg, NULL); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3011 } else { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3012 purple_debug_info("msim", "msim_status: found buddy %s\n", username); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3013 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3014 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3015 user->headline = g_strdup(status_headline); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3016 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3017 /* Set user status */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3018 switch (status_code) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3019 case MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN: |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3020 purple_status_code = PURPLE_STATUS_OFFLINE; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3021 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3022 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3023 case MSIM_STATUS_CODE_ONLINE: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3024 purple_status_code = PURPLE_STATUS_AVAILABLE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3025 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3026 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3027 case MSIM_STATUS_CODE_AWAY: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3028 purple_status_code = PURPLE_STATUS_AWAY; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3029 break; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3030 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3031 case MSIM_STATUS_CODE_IDLE: |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3032 /* will be handled below */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3033 purple_status_code = -1; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3034 break; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3035 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3036 default: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3037 purple_debug_info("msim", "msim_status for %s, unknown status code %d, treating as available\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3038 username, status_code); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3039 purple_status_code = PURPLE_STATUS_AVAILABLE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3040 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3041 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3042 purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3043 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3044 if (status_code == MSIM_STATUS_CODE_IDLE) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3045 purple_debug_info("msim", "msim_status: got idle: %s\n", username); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3046 purple_prpl_got_user_idle(session->account, username, TRUE, time(NULL)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3047 } else { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3048 /* All other statuses indicate going back to non-idle. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3049 purple_prpl_got_user_idle(session->account, username, FALSE, time(NULL)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3050 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3051 |
17974
3d400b022acc
Disable sending third-party client version to oncoming buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17973
diff
changeset
|
3052 #ifdef MSIM_SEND_CLIENT_VERSION |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3053 if (status_code == MSIM_STATUS_CODE_ONLINE) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3054 /* Secretly whisper to unofficial clients our own version as they come online */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3055 msim_send_unofficial_client(session, username); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3056 } |
17974
3d400b022acc
Disable sending third-party client version to oncoming buddies.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17973
diff
changeset
|
3057 #endif |
17953
bde17299004b
Support unofficial bm code 200, also used by Miranda IM plugin, to report
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17952
diff
changeset
|
3058 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3059 g_free(username); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3060 msim_msg_list_free(list); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3061 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3062 return TRUE; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3063 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3064 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3065 /** Add a buddy to user's buddy list. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3066 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3067 msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3068 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3069 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3070 MsimMessage *msg; |
18910 | 3071 /* MsimMessage *msg_persist; */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3072 MsimMessage *body; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3073 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3074 session = (MsimSession *)gc->proto_data; |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
3075 purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n", |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3076 buddy->name, (group && group->name) ? group->name : "(no group)"); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3077 |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
3078 msg = msim_msg_new( |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3079 "addbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3080 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3081 /* "newprofileid" will be inserted here with uid. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3082 "reason", MSIM_TYPE_STRING, g_strdup(""), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3083 NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3084 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3085 if (!msim_postprocess_outgoing(session, msg, buddy->name, "newprofileid", "reason")) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3086 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed.")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3087 msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3088 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3089 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3090 msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3091 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3092 /* TODO: if addbuddy fails ('error' message is returned), delete added buddy from |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3093 * buddy list since Purple adds it locally. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3094 |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
3095 body = msim_msg_new( |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3096 "ContactID", MSIM_TYPE_STRING, g_strdup("<uid>"), |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3097 "GroupName", MSIM_TYPE_STRING, g_strdup(group->name), |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3098 "Position", MSIM_TYPE_INTEGER, 1000, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3099 "Visibility", MSIM_TYPE_INTEGER, 1, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3100 "NickName", MSIM_TYPE_STRING, g_strdup(""), |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3101 "NameSelect", MSIM_TYPE_INTEGER, 0, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3102 NULL); |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
3103 |
18885
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
3104 /* TODO: Update blocklist. */ |
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
3105 |
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
3106 #if 0 |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
3107 msg_persist = msim_msg_new( |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3108 "persist", MSIM_TYPE_INTEGER, 1, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3109 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3110 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_PUT, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3111 "dsn", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_DSN, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3112 "lid", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_LID, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3113 /* TODO: Use msim_new_reply_callback to get rid. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3114 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
3115 "body", MSIM_TYPE_DICTIONARY, body, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3116 NULL); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3117 |
18885
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
3118 if (!msim_postprocess_outgoing(session, msg_persist, buddy->name, "body", NULL)) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3119 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3120 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed")); |
18885
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
3121 msim_msg_free(msg_persist); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3122 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3123 } |
18885
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
3124 msim_msg_free(msg_persist); |
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
3125 #endif |
644144f1a5c2
Use the right message in the persistance command for adding buddies, but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18883
diff
changeset
|
3126 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3127 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3128 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3129 /** Perform actual postprocessing on a message, adding userid as specified. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3130 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3131 * @param msg The message to postprocess. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3132 * @param uid_before Name of field where to insert new field before, or NULL for end. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3133 * @param uid_field_name Name of field to add uid to. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3134 * @param uid The userid to insert. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3135 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3136 * If the field named by uid_field_name already exists, then its string contents will |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3137 * be used for the field, except "<uid>" will be replaced by the userid. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3138 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3139 * If the field named by uid_field_name does not exist, it will be added before the |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3140 * field named by uid_before, as an integer, with the userid. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3141 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3142 * Does not handle sending, or scheduling userid lookup. For that, see msim_postprocess_outgoing(). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3143 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3144 static MsimMessage * |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3145 msim_do_postprocessing(MsimMessage *msg, const gchar *uid_before, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3146 const gchar *uid_field_name, guint uid) |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3147 { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3148 msim_msg_dump("msim_do_postprocessing msg: %s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3149 |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
3150 /* First, check - if the field already exists, replace <uid> within it */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3151 if (msim_msg_get(msg, uid_field_name)) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3152 MsimMessageElement *elem; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3153 gchar *fmt_string; |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
3154 gchar *uid_str, *new_str; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3155 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3156 /* Warning: this is a delicate, but safe, operation */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3157 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3158 elem = msim_msg_get(msg, uid_field_name); |
18883
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
3159 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3160 /* Get the packed element, flattening it. This allows <uid> to be |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3161 * replaced within nested data structures, since the replacement is done |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3162 * on the linear, packed data, not on a complicated data structure. |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3163 * |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3164 * For example, if the field was originally a dictionary or a list, you |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3165 * would have to iterate over all the items in it to see what needs to |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3166 * be replaced. But by packing it first, the <uid> marker is easily replaced |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3167 * just by a string replacement. |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3168 */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3169 fmt_string = msim_msg_pack_element_data(elem); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3170 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3171 uid_str = g_strdup_printf("%d", uid); |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
3172 new_str = str_replace(fmt_string, "<uid>", uid_str); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3173 g_free(uid_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3174 g_free(fmt_string); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3175 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3176 /* Free the old element data */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3177 msim_msg_free_element_data(elem->data); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3178 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3179 /* Replace it with our new data */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3180 elem->data = new_str; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3181 elem->type = MSIM_TYPE_RAW; |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
3182 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3183 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3184 /* Otherwise, insert new field into outgoing message. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3185 msg = msim_msg_insert_before(msg, uid_before, uid_field_name, MSIM_TYPE_INTEGER, GUINT_TO_POINTER(uid)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3186 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3187 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3188 msim_msg_dump("msim_postprocess_outgoing_cb: postprocessed msg=%s\n", msg); |
18883
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
3189 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3190 return msg; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3191 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3192 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3193 /** Callback for msim_postprocess_outgoing() to add a userid to a message, and send it (once receiving userid). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3194 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3195 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3196 * @param userinfo The user information reply message, containing the user ID |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3197 * @param data The message to postprocess and send. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3198 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3199 * The data message should contain these fields: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3200 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3201 * _uid_field_name: string, name of field to add with userid from userinfo message |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3202 * _uid_before: string, name of field before field to insert, or NULL for end |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3203 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3204 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3205 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3206 static void |
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3207 msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3208 gpointer data) |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3209 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3210 gchar *body_str; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3211 GHashTable *body; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3212 gchar *uid, *uid_field_name, *uid_before; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3213 MsimMessage *msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3214 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3215 msg = (MsimMessage *)data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3216 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3217 msim_msg_dump("msim_postprocess_outgoing_cb() got msg=%s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3218 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3219 /* Obtain userid from userinfo message. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3220 body_str = msim_msg_get_string(userinfo, "body"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3221 g_return_if_fail(body_str != NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3222 body = msim_parse_body(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3223 g_free(body_str); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3224 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3225 uid = g_strdup(g_hash_table_lookup(body, "UserID")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3226 g_hash_table_destroy(body); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3227 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3228 uid_field_name = msim_msg_get_string(msg, "_uid_field_name"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3229 uid_before = msim_msg_get_string(msg, "_uid_before"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3230 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3231 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, atol(uid)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3232 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3233 /* Send */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3234 if (!msim_msg_send(session, msg)) { |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
3235 msim_msg_dump("msim_postprocess_outgoing_cb: sending failed for message: %s\n", msg); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3236 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3237 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3238 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3239 /* Free field names AFTER sending message, because MsimMessage does NOT copy |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3240 * field names - instead, treats them as static strings (which they usually are). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3241 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3242 g_free(uid_field_name); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3243 g_free(uid_before); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3244 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3245 g_hash_table_destroy(body); |
17947
ac7066ffa109
Add msim_check_mail to check for new mail (called periodically), and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17946
diff
changeset
|
3246 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3247 //msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3248 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3249 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3250 /** Postprocess and send a message. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3251 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3252 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3253 * @param msg Message to postprocess. Will NOT be freed. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3254 * @param username Username to resolve. Assumed to be a static string (will not be freed or copied). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3255 * @param uid_field_name Name of new field to add, containing uid of username. Static string. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3256 * @param uid_before Name of existing field to insert username field before. Static string. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3257 * |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3258 * @return TRUE if successful. |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3259 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3260 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3261 msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3262 const gchar *username, const gchar *uid_field_name, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3263 const gchar *uid_before) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3264 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3265 PurpleBuddy *buddy; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3266 guint uid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3267 gboolean rc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3268 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3269 g_return_val_if_fail(msg != NULL, FALSE); |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3270 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3271 /* Store information for msim_postprocess_outgoing_cb(). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3272 msim_msg_dump("msim_postprocess_outgoing: msg before=%s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3273 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3274 msg = msim_msg_append(msg, "_uid_field_name", MSIM_TYPE_STRING, g_strdup(uid_field_name)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3275 msg = msim_msg_append(msg, "_uid_before", MSIM_TYPE_STRING, g_strdup(uid_before)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3276 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3277 /* First, try the most obvious. If numeric userid is given, use that directly. */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3278 if (msim_is_userid(username)) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3279 uid = atol(username); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3280 } else { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3281 /* Next, see if on buddy list and know uid. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3282 buddy = purple_find_buddy(session->account, username); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3283 if (buddy) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3284 uid = purple_blist_node_get_int(&buddy->node, "UserID"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3285 } else { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3286 uid = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3287 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3288 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3289 if (!buddy || !uid) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3290 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3291 /* Don't have uid offhand - need to ask for it, and wait until hear back before sending. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3292 purple_debug_info("msim", ">>> msim_postprocess_outgoing: couldn't find username %s in blist\n", |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
3293 username ? username : "(NULL)"); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3294 msim_msg_dump("msim_postprocess_outgoing - scheduling lookup, msg=%s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3295 /* TODO: where is cloned message freed? Should be in _cb. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3296 msim_lookup_user(session, username, msim_postprocess_outgoing_cb, msim_msg_clone(msg)); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3297 return TRUE; /* not sure of status yet - haven't sent! */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3298 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3299 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3300 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3301 /* Already have uid, postprocess and send msg immediately. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3302 purple_debug_info("msim", "msim_postprocess_outgoing: found username %s has uid %d\n", |
17976
b2d81d13f015
Be more careful about null strings in %s format specifier in debug messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17974
diff
changeset
|
3303 username ? username : "(NULL)", uid); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3304 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3305 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, uid); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3306 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3307 msim_msg_dump("msim_postprocess_outgoing: msg after (uid immediate)=%s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3308 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3309 rc = msim_msg_send(session, msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3310 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3311 //msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3312 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3313 return rc; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3314 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3315 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3316 /** Remove a buddy from the user's buddy list. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3317 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3318 msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3319 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3320 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3321 MsimMessage *delbuddy_msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3322 MsimMessage *persist_msg; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3323 MsimMessage *blocklist_msg; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3324 GList *blocklist_updates; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3325 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3326 session = (MsimSession *)gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3327 |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
3328 delbuddy_msg = msim_msg_new( |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3329 "delbuddy", MSIM_TYPE_BOOLEAN, TRUE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3330 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3331 /* 'delprofileid' with uid will be inserted here. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3332 NULL); |
17973
acff371d7908
Fix crash when deleting buddies on Windows. This was done by
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17972
diff
changeset
|
3333 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3334 if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL)) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3335 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed")); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3336 msim_msg_free(delbuddy_msg); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3337 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3338 } |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3339 msim_msg_free(delbuddy_msg); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3340 |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
3341 persist_msg = msim_msg_new( |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3342 "persist", MSIM_TYPE_INTEGER, 1, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3343 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3344 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3345 "dsn", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_DSN, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3346 "lid", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_LID, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3347 "uid", MSIM_TYPE_INTEGER, session->userid, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3348 "rid", MSIM_TYPE_INTEGER, session->next_rid++, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3349 /* <uid> will be replaced by postprocessing */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3350 "body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"), |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3351 NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3352 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3353 if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL)) { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3354 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3355 msim_msg_free(persist_msg); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3356 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3357 } |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3358 msim_msg_free(persist_msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3359 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3360 blocklist_updates = NULL; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3361 blocklist_updates = g_list_prepend(blocklist_updates, "a-"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3362 blocklist_updates = g_list_prepend(blocklist_updates, "<uid>"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3363 blocklist_updates = g_list_prepend(blocklist_updates, "b-"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3364 blocklist_updates = g_list_prepend(blocklist_updates, "<uid>"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3365 blocklist_updates = g_list_reverse(blocklist_updates); |
18879
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3366 |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
3367 blocklist_msg = msim_msg_new( |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3368 "blocklist", MSIM_TYPE_BOOLEAN, TRUE, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3369 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
18879
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
3370 /* TODO: MsimMessage lists. Currently <uid> isn't replaced in lists. */ |
18883
0ca629db64a4
Use a list when updating the blocklist when removing the buddy, since
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18881
diff
changeset
|
3371 //"idlist", MSIM_TYPE_STRING, g_strdup("a-|<uid>|b-|<uid>"), |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3372 "idlist", MSIM_TYPE_LIST, blocklist_updates, |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3373 NULL); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3374 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3375 if (!msim_postprocess_outgoing(session, blocklist_msg, buddy->name, "idlist", NULL)) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3376 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("blocklist command failed")); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3377 msim_msg_free(blocklist_msg); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3378 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3379 } |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3380 msim_msg_free(blocklist_msg); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3381 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3382 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3383 /** Return whether the buddy can be messaged while offline. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3384 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3385 * The protocol supports offline messages in just the same way as online |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3386 * messages. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3387 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3388 gboolean |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3389 msim_offline_message(const PurpleBuddy *buddy) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3390 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3391 return TRUE; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3392 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3393 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3394 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3395 * Callback when input available. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3396 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3397 * @param gc_uncasted A PurpleConnection pointer. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3398 * @param source File descriptor. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3399 * @param cond PURPLE_INPUT_READ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3400 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3401 * Reads the input, and calls msim_preprocess_incoming() to handle it. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3402 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3403 static void |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3404 msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3405 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3406 PurpleConnection *gc; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3407 PurpleAccount *account; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3408 MsimSession *session; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3409 gchar *end; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3410 int n; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3411 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3412 g_return_if_fail(gc_uncasted != NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3413 g_return_if_fail(source >= 0); /* Note: 0 is a valid fd */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3414 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3415 gc = (PurpleConnection *)(gc_uncasted); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3416 account = purple_connection_get_account(gc); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3417 session = gc->proto_data; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3418 |
18909
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
3419 /* libpurple/eventloop.h only defines these two */ |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
3420 if (cond != PURPLE_INPUT_READ && cond != PURPLE_INPUT_WRITE) { |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
3421 purple_debug_info("msim_input_cb", "unknown condition=%d\n", cond); |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
3422 purple_connection_error(gc, _("Invalid input condition")); |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
3423 return; |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
3424 } |
c32fcdef2809
Only say we are connected after the MsimSession structure is fully setup.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18908
diff
changeset
|
3425 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3426 g_return_if_fail(cond == PURPLE_INPUT_READ); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3427 g_return_if_fail(MSIM_SESSION_VALID(session)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3428 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3429 /* Mark down that we got data, so don't timeout. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3430 session->last_comm = time(NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3431 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3432 /* Only can handle so much data at once... |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3433 * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE. |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3434 * Should be large enough to hold the largest protocol message. |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3435 */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3436 if (session->rxoff >= MSIM_READ_BUF_SIZE) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3437 purple_debug_error("msim", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3438 "msim_input_cb: %d-byte read buffer full! rxoff=%d\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3439 MSIM_READ_BUF_SIZE, session->rxoff); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3440 purple_connection_error(gc, _("Read buffer full")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3441 return; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3442 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3443 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3444 purple_debug_info("msim", "buffer at %d (max %d), reading up to %d\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3445 session->rxoff, MSIM_READ_BUF_SIZE, |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3446 MSIM_READ_BUF_SIZE - session->rxoff); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3447 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3448 /* Read into buffer. On Win32, need recv() not read(). session->fd also holds |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3449 * the file descriptor, but it sometimes differs from the 'source' parameter. |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3450 */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3451 n = recv(session->fd, session->rxbuf + session->rxoff, MSIM_READ_BUF_SIZE - session->rxoff, 0); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3452 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3453 if (n < 0 && errno == EAGAIN) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3454 return; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3455 } else if (n < 0) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3456 purple_debug_error("msim", "msim_input_cb: read error, ret=%d, " |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3457 "error=%s, source=%d, fd=%d (%X))\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3458 n, strerror(errno), source, session->fd, session->fd); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3459 purple_connection_error(gc, _("Read error")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3460 return; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3461 } else if (n == 0) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3462 purple_debug_info("msim", "msim_input_cb: server disconnected\n"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3463 purple_connection_error(gc, _("Server has disconnected")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3464 return; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3465 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3466 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3467 if (n + session->rxoff >= MSIM_READ_BUF_SIZE) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3468 purple_debug_info("msim_input_cb", "received %d bytes, pushing rxoff to %d, over buffer size of %d\n", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3469 n, n + session->rxoff, MSIM_READ_BUF_SIZE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3470 /* TODO: g_realloc like msn, yahoo, irc, jabber? */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3471 purple_connection_error(gc, _("Read buffer full")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3472 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3473 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3474 /* Null terminate */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3475 purple_debug_info("msim", "msim_input_cb: going to null terminate " |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3476 "at n=%d\n", n); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3477 session->rxbuf[session->rxoff + n] = 0; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3478 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3479 #ifdef MSIM_CHECK_EMBEDDED_NULLS |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3480 /* Check for embedded NULs. I don't handle them, and they shouldn't occur. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3481 if (strlen(session->rxbuf + session->rxoff) != n) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3482 /* Occurs after login, but it is not a null byte. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3483 purple_debug_info("msim", "msim_input_cb: strlen=%d, but read %d bytes" |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3484 "--null byte encountered?\n", |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3485 strlen(session->rxbuf + session->rxoff), n); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3486 //purple_connection_error(gc, "Invalid message - null byte on input"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3487 return; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3488 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3489 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3490 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3491 session->rxoff += n; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3492 purple_debug_info("msim", "msim_input_cb: read=%d\n", n); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3493 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3494 #ifdef MSIM_DEBUG_RXBUF |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3495 purple_debug_info("msim", "buf=<%s>\n", session->rxbuf); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3496 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3497 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3498 /* Look for \\final\\ end markers. If found, process message. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3499 while((end = strstr(session->rxbuf, MSIM_FINAL_STRING))) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3500 MsimMessage *msg; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3501 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3502 #ifdef MSIM_DEBUG_RXBUF |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3503 purple_debug_info("msim", "in loop: buf=<%s>\n", session->rxbuf); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3504 #endif |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3505 *end = 0; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3506 msg = msim_parse(g_strdup(session->rxbuf)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3507 if (!msg) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3508 purple_debug_info("msim", "msim_input_cb: couldn't parse rxbuf\n"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3509 purple_connection_error(gc, _("Unparseable message")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3510 } else { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3511 /* Process message and then free it (processing function should |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3512 * clone message if it wants to keep it afterwards.) */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3513 if (!msim_preprocess_incoming(session, msg)) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3514 msim_msg_dump("msim_input_cb: preprocessing message failed on msg: %s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3515 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3516 msim_msg_free(msg); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3517 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3518 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3519 /* Move remaining part of buffer to beginning. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3520 session->rxoff -= strlen(session->rxbuf) + strlen(MSIM_FINAL_STRING); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3521 memmove(session->rxbuf, end + strlen(MSIM_FINAL_STRING), |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3522 MSIM_READ_BUF_SIZE - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3523 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3524 /* Clear end of buffer */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3525 //memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3526 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3527 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3528 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3529 /* Setup a callback, to be called when a reply is received with the returned rid. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3530 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3531 * @param cb The callback, an MSIM_USER_LOOKUP_CB. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3532 * @param data Arbitrary user data to be passed to callback (probably an MsimMessage *). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3533 * |
17951 | 3534 * @return The request/reply ID, used to link replies with requests, or -1. |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3535 * Put the rid in your request, 'rid' field. |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3536 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3537 * TODO: Make more generic and more specific: |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3538 * 1) MSIM_USER_LOOKUP_CB - make it for PERSIST_REPLY, not just user lookup |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3539 * 2) data - make it an MsimMessage? |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3540 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3541 static guint |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3542 msim_new_reply_callback(MsimSession *session, MSIM_USER_LOOKUP_CB cb, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3543 gpointer data) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3544 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3545 guint rid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3546 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3547 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1); |
17951 | 3548 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3549 rid = session->next_rid++; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3550 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3551 g_hash_table_insert(session->user_lookup_cb, GUINT_TO_POINTER(rid), cb); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3552 g_hash_table_insert(session->user_lookup_cb_data, GUINT_TO_POINTER(rid), data); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3553 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3554 return rid; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3555 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3556 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3557 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3558 * Callback when connected. Sets up input handlers. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3559 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3560 * @param data A PurpleConnection pointer. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3561 * @param source File descriptor. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3562 * @param error_message |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3563 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3564 static void |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3565 msim_connect_cb(gpointer data, gint source, const gchar *error_message) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3566 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3567 PurpleConnection *gc; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3568 MsimSession *session; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3569 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3570 g_return_if_fail(data != NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3571 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3572 gc = (PurpleConnection *)data; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3573 session = (MsimSession *)gc->proto_data; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3574 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3575 if (source < 0) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3576 purple_connection_error(gc, _("Couldn't connect to host")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3577 purple_connection_error(gc, g_strdup_printf( |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3578 _("Couldn't connect to host: %s (%d)"), |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3579 error_message ? error_message : "no message given", |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3580 source)); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3581 return; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3582 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3583 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3584 session->fd = source; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3585 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3586 gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3587 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3588 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3589 /* Session methods */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3590 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3591 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3592 * Create a new MSIM session. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3593 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3594 * @param acct The account to create the session from. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3595 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3596 * @return Pointer to a new session. Free with msim_session_destroy. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3597 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3598 MsimSession * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3599 msim_session_new(PurpleAccount *acct) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3600 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3601 MsimSession *session; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3602 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3603 g_return_val_if_fail(acct != NULL, NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3604 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3605 session = g_new0(MsimSession, 1); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3606 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3607 session->magic = MSIM_SESSION_STRUCT_MAGIC; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3608 session->account = acct; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3609 session->gc = purple_account_get_connection(acct); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3610 session->sesskey = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3611 session->userid = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3612 session->username = NULL; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3613 session->fd = -1; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3614 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3615 /* TODO: Remove. */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3616 session->user_lookup_cb = g_hash_table_new_full(g_direct_hash, |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3617 g_direct_equal, NULL, NULL); /* do NOT free function pointers! (values) */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3618 session->user_lookup_cb_data = g_hash_table_new_full(g_direct_hash, |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3619 g_direct_equal, NULL, NULL);/* TODO: we don't know what the values are, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3620 they could be integers inside gpointers |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3621 or strings, so I don't freed them. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3622 Figure this out, once free cache. */ |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
3623 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3624 /* Created in msim_process_server_info() */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3625 session->server_info = NULL; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3626 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3627 session->rxoff = 0; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3628 session->rxbuf = g_new0(gchar, MSIM_READ_BUF_SIZE); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3629 session->next_rid = 1; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3630 session->last_comm = time(NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3631 session->inbox_status = 0; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3632 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3633 return session; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3634 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3635 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3636 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3637 * Free a session. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3638 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3639 * @param session The session to destroy. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3640 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3641 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3642 msim_session_destroy(MsimSession *session) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3643 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3644 g_return_if_fail(MSIM_SESSION_VALID(session)); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3645 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3646 session->magic = -1; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3647 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3648 g_free(session->rxbuf); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3649 g_free(session->username); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3650 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3651 /* TODO: Remove. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3652 g_hash_table_destroy(session->user_lookup_cb); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3653 g_hash_table_destroy(session->user_lookup_cb_data); |
17966
f1827c3dc65a
Add msim_process_server_info() to save the server information dictionary
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17965
diff
changeset
|
3654 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3655 if (session->server_info) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3656 g_hash_table_destroy(session->server_info); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3657 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3658 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3659 g_free(session); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3660 } |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3661 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3662 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3663 * Close the connection. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3664 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3665 * @param gc The connection. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3666 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3667 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3668 msim_close(PurpleConnection *gc) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3669 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3670 MsimSession *session; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3671 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3672 if (gc == NULL) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3673 return; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3674 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3675 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3676 session = (MsimSession *)gc->proto_data; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3677 if (session == NULL) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3678 return; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3679 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3680 gc->proto_data = NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3681 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3682 if (!MSIM_SESSION_VALID(session)) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3683 return; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3684 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3685 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3686 if (session->gc->inpa) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3687 purple_input_remove(session->gc->inpa); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3688 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3689 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3690 msim_session_destroy(session); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3691 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3692 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3693 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3694 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3695 * Check if a string is a userid (all numeric). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3696 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3697 * @param user The user id, email, or name. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3698 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3699 * @return TRUE if is userid, FALSE if not. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3700 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3701 static gboolean |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3702 msim_is_userid(const gchar *user) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3703 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3704 g_return_val_if_fail(user != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3705 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3706 return strspn(user, "0123456789") == strlen(user); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3707 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3708 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3709 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3710 * Check if a string is an email address (contains an @). |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3711 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3712 * @param user The user id, email, or name. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3713 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3714 * @return TRUE if is an email, FALSE if not. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3715 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3716 * This function is not intended to be used as a generic |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3717 * means of validating email addresses, but to distinguish |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3718 * between a user represented by an email address from |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3719 * other forms of identification. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3720 */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3721 static gboolean |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3722 msim_is_email(const gchar *user) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3723 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3724 g_return_val_if_fail(user != NULL, FALSE); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3725 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3726 return strchr(user, '@') != NULL; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3727 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3728 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3729 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3730 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3731 * Asynchronously lookup user information, calling callback when receive result. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3732 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3733 * @param session |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3734 * @param user The user id, email address, or username. Not freed. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3735 * @param cb Callback, called with user information when available. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3736 * @param data An arbitray data pointer passed to the callback. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3737 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3738 /* TODO: change to not use callbacks */ |
17969
8983b8340fdc
Make msimprpl-internal functions static.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17968
diff
changeset
|
3739 static void |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3740 msim_lookup_user(MsimSession *session, const gchar *user, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3741 MSIM_USER_LOOKUP_CB cb, gpointer data) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3742 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3743 MsimMessage *body; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3744 gchar *field_name; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3745 guint rid, cmd, dsn, lid; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3746 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3747 g_return_if_fail(MSIM_SESSION_VALID(session)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3748 g_return_if_fail(user != NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3749 g_return_if_fail(cb != NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3750 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3751 purple_debug_info("msim", "msim_lookup_userid: " |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3752 "asynchronously looking up <%s>\n", user); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3753 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3754 msim_msg_dump("msim_lookup_user: data=%s\n", (MsimMessage *)data); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3755 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3756 /* Setup callback. Response will be associated with request using 'rid'. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3757 rid = msim_new_reply_callback(session, cb, data); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3758 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3759 /* Send request */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3760 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3761 cmd = MSIM_CMD_GET; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3762 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3763 if (msim_is_userid(user)) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3764 field_name = "UserID"; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3765 dsn = MG_MYSPACE_INFO_BY_ID_DSN; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3766 lid = MG_MYSPACE_INFO_BY_ID_LID; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3767 } else if (msim_is_email(user)) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3768 field_name = "Email"; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3769 dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3770 lid = MG_MYSPACE_INFO_BY_STRING_LID; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3771 } else { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3772 field_name = "UserName"; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3773 dsn = MG_MYSPACE_INFO_BY_STRING_DSN; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3774 lid = MG_MYSPACE_INFO_BY_STRING_LID; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3775 } |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3776 |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
3777 body = msim_msg_new( |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3778 field_name, MSIM_TYPE_STRING, g_strdup(user), |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3779 NULL); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3780 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3781 g_return_if_fail(msim_send(session, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3782 "persist", MSIM_TYPE_INTEGER, 1, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3783 "sesskey", MSIM_TYPE_INTEGER, session->sesskey, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3784 "cmd", MSIM_TYPE_INTEGER, 1, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3785 "dsn", MSIM_TYPE_INTEGER, dsn, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3786 "uid", MSIM_TYPE_INTEGER, session->userid, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3787 "lid", MSIM_TYPE_INTEGER, lid, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3788 "rid", MSIM_TYPE_INTEGER, rid, |
18881
3ec39ff6b407
Use the new dictionary data type when:
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18879
diff
changeset
|
3789 "body", MSIM_TYPE_DICTIONARY, body, |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3790 NULL)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3791 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3792 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3793 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3794 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3795 * Obtain the status text for a buddy. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3796 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3797 * @param buddy The buddy to obtain status text for. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3798 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3799 * @return Status text, or NULL if error. Caller g_free()'s. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3800 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3801 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3802 char * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3803 msim_status_text(PurpleBuddy *buddy) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3804 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3805 MsimSession *session; |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3806 MsimUser *user; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3807 const gchar *display_name, *headline; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3808 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3809 g_return_val_if_fail(buddy != NULL, NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3810 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3811 user = msim_get_user_from_buddy(buddy); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3812 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3813 session = (MsimSession *)buddy->account->gc->proto_data; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3814 g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3815 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3816 display_name = headline = NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3817 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3818 /* Retrieve display name and/or headline, depending on user preference. */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3819 if (purple_account_get_bool(session->account, "show_display_name", TRUE)) { |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3820 display_name = user->display_name; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3821 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3822 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3823 if (purple_account_get_bool(session->account, "show_headline", FALSE)) { |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3824 headline = user->headline; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3825 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3826 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3827 /* Return appropriate combination of display name and/or headline, or neither. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3828 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3829 if (display_name && headline) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3830 return g_strconcat(display_name, " ", headline, NULL); |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3831 } else if (display_name) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3832 return g_strdup(display_name); |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3833 } else if (headline) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3834 return g_strdup(headline); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3835 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3836 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3837 return NULL; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3838 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3839 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3840 /** |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3841 * Obtain the tooltip text for a buddy. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3842 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3843 * @param buddy Buddy to obtain tooltip text on. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3844 * @param user_info Variable modified to have the tooltip text. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3845 * @param full TRUE if should obtain full tooltip text. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3846 * |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3847 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3848 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3849 msim_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3850 gboolean full) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3851 { |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3852 MsimUser *user; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3853 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3854 g_return_if_fail(buddy != NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3855 g_return_if_fail(user_info != NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3856 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3857 user = msim_get_user_from_buddy(buddy); |
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3858 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3859 if (PURPLE_BUDDY_IS_ONLINE(buddy)) { |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3860 MsimSession *session; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3861 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3862 session = (MsimSession *)buddy->account->gc->proto_data; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3863 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3864 g_return_if_fail(MSIM_SESSION_VALID(session)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3865 |
18912
7519560095f7
Use MsimUser structure for storing ephemeral information on users, instead
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18910
diff
changeset
|
3866 /* TODO: if (full), do something different? */ |
18913
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
3867 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
3868 /* TODO: request information? have to figure out how to do |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
3869 * the asynchronous lookup like oscar does (tooltip shows |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
3870 * 'retrieving...' if not yet available, then changes when it is). |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
3871 * |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
3872 * Right now, only show what we have on hand. |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
3873 */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
3874 |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
3875 /* Show abbreviated user info. */ |
1d243e70db35
Refactor msim_tooltip_text() and msim_get_info_cb(), so that they now both use
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18912
diff
changeset
|
3876 msim_append_user_info(session, user_info, user, FALSE); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3877 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3878 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3879 |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3880 /** Actions menu for account. */ |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3881 GList * |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3882 msim_actions(PurplePlugin *plugin, gpointer context) |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3883 { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3884 PurpleConnection *gc; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3885 GList *menu; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3886 //PurplePluginAction *act; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3887 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3888 gc = (PurpleConnection *)context; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3889 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3890 menu = NULL; |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3891 |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3892 #if 0 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3893 /* TODO: find out how */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3894 act = purple_plugin_action_new(_("Find people..."), msim_); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3895 menu = g_list_append(menu, act); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3896 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3897 act = purple_plugin_action_new(_("Import friends..."), NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3898 menu = g_list_append(menu, act); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3899 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3900 act = purple_plugin_action_new(_("Change IM name..."), NULL); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3901 menu = g_list_append(menu, act); |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3902 #endif |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3903 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3904 return menu; |
17965
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3905 } |
e3687194f2b2
Use MsimMessage's new list type for status messages.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17963
diff
changeset
|
3906 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3907 /** Callbacks called by Purple, to access this plugin. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3908 PurplePluginProtocolInfo prpl_info = { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3909 /* options */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3910 OPT_PROTO_USE_POINTSIZE /* specify font size in sane point size */ |
17948
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
3911 | OPT_PROTO_MAIL_CHECK, |
c23122e0af91
Notify of new inbox messages (friend requests, inbox messages, comments),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17947
diff
changeset
|
3912 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3913 /* | OPT_PROTO_IM_IMAGE - TODO: direct images. */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3914 NULL, /* user_splits */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3915 NULL, /* protocol_options */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3916 NO_BUDDY_ICONS, /* icon_spec - TODO: eventually should add this */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3917 msim_list_icon, /* list_icon */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3918 NULL, /* list_emblems */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3919 msim_status_text, /* status_text */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3920 msim_tooltip_text, /* tooltip_text */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3921 msim_status_types, /* status_types */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3922 msim_blist_node_menu, /* blist_node_menu */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3923 NULL, /* chat_info */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3924 NULL, /* chat_info_defaults */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3925 msim_login, /* login */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3926 msim_close, /* close */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3927 msim_send_im, /* send_im */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3928 NULL, /* set_info */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3929 msim_send_typing, /* send_typing */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3930 msim_get_info, /* get_info */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3931 msim_set_status, /* set_status */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3932 msim_set_idle, /* set_idle */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3933 NULL, /* change_passwd */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3934 msim_add_buddy, /* add_buddy */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3935 NULL, /* add_buddies */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3936 msim_remove_buddy, /* remove_buddy */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3937 NULL, /* remove_buddies */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3938 NULL, /* add_permit */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3939 NULL, /* add_deny */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3940 NULL, /* rem_permit */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3941 NULL, /* rem_deny */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3942 NULL, /* set_permit_deny */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3943 NULL, /* join_chat */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3944 NULL, /* reject chat invite */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3945 NULL, /* get_chat_name */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3946 NULL, /* chat_invite */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3947 NULL, /* chat_leave */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3948 NULL, /* chat_whisper */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3949 NULL, /* chat_send */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3950 NULL, /* keepalive */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3951 NULL, /* register_user */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3952 NULL, /* get_cb_info */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3953 NULL, /* get_cb_away */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3954 NULL, /* alias_buddy */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3955 NULL, /* group_buddy */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3956 NULL, /* rename_group */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3957 NULL, /* buddy_free */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3958 NULL, /* convo_closed */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3959 NULL, /* normalize */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3960 NULL, /* set_buddy_icon */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3961 NULL, /* remove_group */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3962 NULL, /* get_cb_real_name */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3963 NULL, /* set_chat_topic */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3964 NULL, /* find_blist_chat */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3965 NULL, /* roomlist_get_list */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3966 NULL, /* roomlist_cancel */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3967 NULL, /* roomlist_expand_category */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3968 NULL, /* can_receive_file */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3969 NULL, /* send_file */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3970 NULL, /* new_xfer */ |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
3971 msim_offline_message, /* offline_message */ |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3972 NULL, /* whiteboard_prpl_ops */ |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
3973 msim_send_really_raw, /* send_raw */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
3974 NULL, /* roomlist_room_serialize */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
3975 #ifdef MSIM_USE_ATTENTION_API |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
3976 msim_send_attention, /* send_attention */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
3977 msim_attention_types, /* attention_types */ |
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
3978 #else |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3979 NULL, /* _purple_reserved1 */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3980 NULL, /* _purple_reserved2 */ |
18916
0f46f13c0805
Proposed "attention" API, a generalization of zaps (MySpaceIM), buzzes
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18915
diff
changeset
|
3981 #endif |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3982 NULL, /* _purple_reserved3 */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3983 NULL /* _purple_reserved4 */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3984 }; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3985 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3986 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3987 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
3988 /** Based on MSN's plugin info comments. */ |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
3989 PurplePluginInfo info = { |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3990 PURPLE_PLUGIN_MAGIC, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3991 PURPLE_MAJOR_VERSION, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3992 PURPLE_MINOR_VERSION, |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3993 PURPLE_PLUGIN_PROTOCOL, /**< type */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3994 NULL, /**< ui_requirement */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3995 0, /**< flags */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3996 NULL, /**< dependencies */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3997 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3998 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
3999 "prpl-myspace", /**< id */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4000 "MySpaceIM", /**< name */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4001 MSIM_PRPL_VERSION_STRING, /**< version */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4002 /** summary */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4003 "MySpaceIM Protocol Plugin", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4004 /** description */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4005 "MySpaceIM Protocol Plugin", |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4006 "Jeff Connelly <jeff2@soc.pidgin.im>", /**< author */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4007 "http://developer.pidgin.im/wiki/MySpaceIM/", /**< homepage */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4008 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4009 msim_load, /**< load */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4010 NULL, /**< unload */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4011 NULL, /**< destroy */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4012 NULL, /**< ui_info */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4013 &prpl_info, /**< extra_info */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4014 NULL, /**< prefs_info */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4015 msim_actions, /**< msim_actions */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4016 NULL, /**< reserved1 */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4017 NULL, /**< reserved2 */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4018 NULL, /**< reserved3 */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4019 NULL /**< reserved4 */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4020 }; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4021 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4022 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4023 #ifdef MSIM_SELF_TEST |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4024 /** Test functions. |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4025 * Used to test or try out the internal workings of msimprpl. If you're reading |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
4026 * this code for the first time, these functions can be instructive in learning |
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
4027 * how msimprpl is architected. |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4028 */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4029 void |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
4030 msim_test_all(void) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4031 guint failures; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4032 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4033 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4034 failures = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4035 failures += msim_test_msg(); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4036 failures += msim_test_escaping(); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4037 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
4038 if (failures) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4039 purple_debug_info("msim", "msim_test_all HAD FAILURES: %d\n", failures); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
4040 } else { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4041 purple_debug_info("msim", "msim_test_all - all tests passed!\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4042 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4043 exit(0); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4044 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4045 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4046 /** Test MsimMessage for basic functionality. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4047 int |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4048 msim_test_msg(void) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4049 { |
18879
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
4050 MsimMessage *msg, *msg_cloned, *msg2; |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4051 GList *list; |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4052 gchar *packed, *packed_expected, *packed_cloned; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4053 guint failures; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4054 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4055 failures = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4056 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4057 purple_debug_info("msim", "\n\nTesting MsimMessage\n"); |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4058 msg = msim_msg_new(NULL); /* Create a new, empty message. */ |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4059 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4060 /* Append some new elements. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4061 msg = msim_msg_append(msg, "bx", MSIM_TYPE_BINARY, g_string_new_len(g_strdup("XXX"), 3)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4062 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v1")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4063 msg = msim_msg_append(msg, "k1", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(42)); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4064 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v43")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4065 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v52/xxx\\yyy")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4066 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v7")); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4067 msim_msg_dump("msg debug str=%s\n", msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4068 packed = msim_msg_pack(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4069 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4070 purple_debug_info("msim", "msg packed=%s\n", packed); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4071 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4072 packed_expected = "\\bx\\WFhY\\k1\\v1\\k1\\42\\k1" |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4073 "\\v43\\k1\\v52/1xxx/2yyy\\k1\\v7\\final\\"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4074 |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
4075 if (0 != strcmp(packed, packed_expected)) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4076 purple_debug_info("msim", "!!!(%d), msim_msg_pack not what expected: %s != %s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4077 ++failures, packed, packed_expected); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4078 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4079 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4080 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4081 msg_cloned = msim_msg_clone(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4082 packed_cloned = msim_msg_pack(msg_cloned); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4083 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4084 purple_debug_info("msim", "msg cloned=%s\n", packed_cloned); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
4085 if (0 != strcmp(packed, packed_cloned)) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4086 purple_debug_info("msim", "!!!(%d), msim_msg_pack on cloned message not equal to original: %s != %s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4087 ++failures, packed_cloned, packed); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4088 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4089 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4090 g_free(packed); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4091 g_free(packed_cloned); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4092 msim_msg_free(msg_cloned); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4093 msim_msg_free(msg); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4094 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4095 /* Try some of the more advanced functionality */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4096 list = NULL; |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4097 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4098 list = g_list_prepend(list, "item3"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4099 list = g_list_prepend(list, "item2"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4100 list = g_list_prepend(list, "item1"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4101 list = g_list_prepend(list, "item0"); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4102 |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4103 msg = msim_msg_new(NULL); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4104 msg = msim_msg_append(msg, "string", MSIM_TYPE_STRING, g_strdup("string value")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4105 msg = msim_msg_append(msg, "raw", MSIM_TYPE_RAW, g_strdup("raw value")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4106 msg = msim_msg_append(msg, "integer", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(3140)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4107 msg = msim_msg_append(msg, "boolean", MSIM_TYPE_BOOLEAN, GUINT_TO_POINTER(FALSE)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4108 msg = msim_msg_append(msg, "list", MSIM_TYPE_LIST, list); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4109 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4110 msim_msg_dump("msg with list=%s\n", msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4111 purple_debug_info("msim", "msg with list packed=%s\n", msim_msg_pack(msg)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4112 |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4113 msg2 = msim_msg_new(NULL); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4114 msg2 = msim_msg_append(msg2, "outer", MSIM_TYPE_STRING, g_strdup("outer value")); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4115 msg2 = msim_msg_append(msg2, "body", MSIM_TYPE_DICTIONARY, msg); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4116 msim_msg_dump("msg with dict=%s\n", msg2); /* msg2 now 'owns' msg */ |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4117 purple_debug_info("msim", "msg with dict packed=%s\n", msim_msg_pack(msg2)); |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4118 |
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4119 msim_msg_free(msg2); |
18879
e0cac5db762b
In msim_msg_pack_element_dict(), separate keys and values with '=' for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17976
diff
changeset
|
4120 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4121 return failures; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4122 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4123 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4124 /** Test protocol-level escaping/unescaping. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4125 int |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4126 msim_test_escaping(void) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4127 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4128 guint failures; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4129 gchar *raw, *escaped, *unescaped, *expected; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4130 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4131 failures = 0; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4132 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4133 purple_debug_info("msim", "\n\nTesting escaping\n"); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4134 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4135 raw = "hello/world\\hello/world"; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4136 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4137 escaped = msim_escape(raw); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4138 purple_debug_info("msim", "msim_test_escaping: raw=%s, escaped=%s\n", raw, escaped); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4139 expected = "hello/1world/2hello/1world"; |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
4140 if (0 != strcmp(escaped, expected)) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4141 purple_debug_info("msim", "!!!(%d), msim_escape failed: %s != %s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4142 ++failures, escaped, expected); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4143 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4144 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4145 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4146 unescaped = msim_unescape(escaped); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4147 g_free(escaped); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4148 purple_debug_info("msim", "msim_test_escaping: unescaped=%s\n", unescaped); |
18890
00499df91ffe
Use cuddled if's etc. everywhere, to better match style of Pidgin/libpurple.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18885
diff
changeset
|
4149 if (0 != strcmp(raw, unescaped)) { |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4150 purple_debug_info("msim", "!!!(%d), msim_unescape failed: %s != %s\n", |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4151 ++failures, raw, unescaped); |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4152 } |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4153 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4154 return failures; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4155 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4156 #endif |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4157 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4158 /** Initialize plugin. */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4159 void |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4160 init_plugin(PurplePlugin *plugin) |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4161 { |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4162 PurpleAccountOption *option; |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4163 #ifdef MSIM_SELF_TEST |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4164 msim_test_all(); |
18905
3f95e691bad2
Rewrite escaping so that it is more correct, in order to fix #2521. Test it.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18904
diff
changeset
|
4165 exit(0); |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4166 #endif /* MSIM_SELF_TEST */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4167 |
18898
b94f831750e0
Clarify password-too-long error (MySpace limits it, not us), and clean up
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18897
diff
changeset
|
4168 |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4169 /* TODO: default to automatically try different ports. Make the user be |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4170 * able to set the first port to try (like LastConnectedPort in Windows client). */ |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4171 option = purple_account_option_string_new(_("Connect server"), "server", MSIM_SERVER); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4172 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4173 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4174 option = purple_account_option_int_new(_("Connect port"), "port", MSIM_PORT); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4175 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4176 |
18914
2b26ba483d87
Conditionally compile out a few advanced configuration options (status text
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18913
diff
changeset
|
4177 #ifdef MSIM_USER_WANTS_TO_CONFIGURE_STATUS_TEXT |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4178 option = purple_account_option_bool_new(_("Show display name in status text"), "show_display_name", TRUE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4179 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4180 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4181 option = purple_account_option_bool_new(_("Show headline in status text"), "show_headline", TRUE); |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4182 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
18914
2b26ba483d87
Conditionally compile out a few advanced configuration options (status text
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18913
diff
changeset
|
4183 #endif |
2b26ba483d87
Conditionally compile out a few advanced configuration options (status text
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18913
diff
changeset
|
4184 |
2b26ba483d87
Conditionally compile out a few advanced configuration options (status text
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18913
diff
changeset
|
4185 #ifdef MSIM_USER_WANTS_TO_DISABLE_EMOTICONS |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4186 option = purple_account_option_bool_new(_("Send emoticons"), "emoticons", FALSE); |
17958
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
4187 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
18914
2b26ba483d87
Conditionally compile out a few advanced configuration options (status text
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18913
diff
changeset
|
4188 #endif |
17958
58c790b37e03
Add account option to send emoticons, defaulting to off since can't currently
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17957
diff
changeset
|
4189 |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
4190 #ifdef MSIM_USER_REALLY_CARES_ABOUT_PRECISE_FONT_SIZES |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4191 option = purple_account_option_int_new(_("Screen resolution (dots per inch)"), "dpi", MSIM_DEFAULT_DPI); |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
4192 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
4193 |
18895
f732d072b118
Change all code to better match the style of libpurple - use 8-space tabs
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18894
diff
changeset
|
4194 option = purple_account_option_int_new(_("Base font size (points)"), "base_font_size", MSIM_BASE_FONT_POINT_SIZE); |
17952
4001661344e4
Make DPI and base font point size configurable in account options. This
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17951
diff
changeset
|
4195 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
17967
c9acdf96e74e
Update login process to more closely match official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17966
diff
changeset
|
4196 #endif |
18897
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4197 |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4198 /* TODO: /zap command. Problem with this is that there are different kinds of zaps, |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4199 * and the selection is best made available in a drop-down menu, instead of forcing |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4200 * the user to type the kind of zap and memorizing available zaps (or putting it in the |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4201 * help menu). A new "attention" API, for zap/buzz/nudge (different protocols) will |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4202 * solve this. */ |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4203 #if 0 |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4204 purple_cmd_register("zap", /* cmd */ |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4205 "w", /* args - accept a single word */ |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4206 PURPLE_CMD_P_PRPL, /* priority */ |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4207 PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY, /* flags */ |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4208 "prpl-myspace", /* prpl_id */ |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4209 msim_cmd_zap, /* func */ |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4210 _("zap: zap a user to get their attention"), /* helpstr */ |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4211 NULL); /* data */ |
d0be4366e876
Change msim_msg_new() and msim_msg_new_v() to accept the first key name as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
18895
diff
changeset
|
4212 #endif |
17936
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4213 } |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4214 |
3c613fec5617
Set status to current status when signing on. This makes the "Sign in as
Jeffrey Connelly <jaconnel@calpoly.edu>
parents:
17935
diff
changeset
|
4215 PURPLE_INIT_PLUGIN(myspace, init_plugin, info); |