annotate libpurple/protocols/myspace/myspace.c @ 22222:433233d3db10

merge of '2e288b76540410af9b0ca21669ffb7e085633d59' and '5cfc19787cb16932e5e50c4034a7c46699fe1c51'
author Mark Doliner <mark@kingant.net>
date Sun, 27 Jan 2008 10:03:26 +0000
parents 6419554aadd9 c0ad8b41ce09
children d2fc168b5e7a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1 /* MySpaceIM Protocol Plugin
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3 * \author Jeff Connelly
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
4 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
5 * Copyright (C) 2007, Jeff Connelly <jeff2@soc.pidgin.im>
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
6 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
7 * Based on Purple's "C Plugin HOWTO" hello world example.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
8 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
9 * Code also drawn from mockprpl:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
10 * http://snarfed.org/space/purple+mock+protocol+plugin
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
11 * Copyright (C) 2004-2007, Ryan Barrett <mockprpl@ryanb.org>
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
12 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
13 * and some constructs also based on existing Purple plugins, which are:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
14 * Copyright (C) 2003, Robbert Haarman <purple@inglorion.net>
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
15 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu>
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
16 * Copyright (C) 2000-2003, Rob Flynn <rob@tgflinux.com>
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
17 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
18 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
19 * This program is free software; you can redistribute it and/or modify
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
20 * it under the terms of the GNU General Public License as published by
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
21 * the Free Software Foundation; either version 2 of the License, or
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
22 * (at your option) any later version.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
23 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
24 * This program is distributed in the hope that it will be useful,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
27 * GNU General Public License for more details.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
28 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
29 * You should have received a copy of the GNU General Public License
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
30 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19660
diff changeset
31 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
32 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
33
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
34 #define PURPLE_PLUGIN
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
35
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
36 #include "myspace.h"
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
37
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
38 /* Internal functions */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
39
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
40 #ifdef MSIM_DEBUG_MSG
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
41 static void print_hash_item(gpointer key, gpointer value, gpointer user_data);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
42 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
43
19435
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
44 static int msim_send_really_raw(PurpleConnection *gc, const char *buf, int total_bytes);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
45 static gboolean msim_login_challenge(MsimSession *session, MsimMessage *msg);
20658
7efdc052539d Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents: 20628
diff changeset
46 static gchar *msim_compute_login_response(const gchar nonce[2 * NONCE_SIZE], const gchar *email, const gchar *password, guint *response_len);
19435
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
47
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
48 static gboolean msim_incoming_bm_record_cv(MsimSession *session, MsimMessage *msg);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
49 static gboolean msim_incoming_bm(MsimSession *session, MsimMessage *msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
50 static gboolean msim_incoming_status(MsimSession *session, MsimMessage *msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
51 static gboolean msim_incoming_im(MsimSession *session, MsimMessage *msg);
19432
210f792efd7c In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19431
diff changeset
52 /* static gboolean msim_incoming_zap(MsimSession *session, MsimMessage *msg); - in zap.c */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
53 static gboolean msim_incoming_action(MsimSession *session, MsimMessage *msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
54 static gboolean msim_incoming_media(MsimSession *session, MsimMessage *msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
55 static gboolean msim_incoming_unofficial_client(MsimSession *session,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
56 MsimMessage *msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
57
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
58 #ifdef MSIM_SEND_CLIENT_VERSION
19435
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
59 static gboolean msim_send_unofficial_client(MsimSession *session, gchar *username);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
60 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
61
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
62 static void msim_get_info_cb(MsimSession *session, MsimMessage *userinfo, gpointer data);
19435
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
63
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
64 static void msim_set_status_code(MsimSession *session, guint code, gchar *statstring);
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
65
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
66 static gboolean msim_process_server_info(MsimSession *session, MsimMessage *msg);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
67 static gboolean msim_web_challenge(MsimSession *session, MsimMessage *msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
68 static gboolean msim_process_reply(MsimSession *session, MsimMessage *msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
69
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
70 static gboolean msim_preprocess_incoming(MsimSession *session, MsimMessage *msg);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
71
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
72 #ifdef MSIM_USE_KEEPALIVE
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
73 static gboolean msim_check_alive(gpointer data);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
74 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
75
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
76 static gboolean msim_we_are_logged_on(MsimSession *session, MsimMessage *msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
77
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
78 static gboolean msim_process(MsimSession *session, MsimMessage *msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
79
19435
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
80 static MsimMessage *msim_do_postprocessing(MsimMessage *msg, const gchar *uid_field_name, const gchar *uid_before, guint uid);
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
81 static void msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo, gpointer data);
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
82 static gboolean msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg, const gchar *username, const gchar *uid_field_name, const gchar *uid_before);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
83
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
84 static gboolean msim_error(MsimSession *session, MsimMessage *msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
85
19435
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
86 static void msim_check_inbox_cb(MsimSession *session, MsimMessage *userinfo, gpointer data);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
87 static gboolean msim_check_inbox(gpointer data);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
88
19435
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
89 static void msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond);
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
90
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
91
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
92 static void msim_connect_cb(gpointer data, gint source, const gchar *error_message);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
93
19249
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
94 static void msim_import_friends(PurplePluginAction *action);
19462
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
95 static void msim_import_friends_cb(MsimSession *session, MsimMessage *reply, gpointer user_data);
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
96 static gboolean msim_get_contact_list(MsimSession *session, int what_to_do_after);
19249
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
97
19441
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
98 static gboolean msim_uri_handler(const gchar *proto, const gchar *cmd, GHashTable *params);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
99 static void msim_uri_handler_addContact_cb(MsimSession *session, MsimMessage *userinfo, gpointer data);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
100 static void msim_uri_handler_sendIM_cb(MsimSession *session, MsimMessage *userinfo, gpointer data);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
101
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
102 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
103 * Load the plugin.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
104 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
105 gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
106 msim_load(PurplePlugin *plugin)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
107 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
108 /* If compiled to use RC4 from libpurple, check if it is really there. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
109 if (!purple_ciphers_find_cipher("rc4")) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
110 purple_debug_error("msim", "rc4 not in libpurple, but it is required - not loading MySpaceIM plugin!\n");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
111 purple_notify_error(plugin, _("Missing Cipher"),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
112 _("The RC4 cipher could not be found"),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
113 _("Upgrade "
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
114 "to a libpurple with RC4 support (>= 2.0.1). MySpaceIM "
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
115 "plugin will not be loaded."));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
116 return FALSE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
117 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
118 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
119 }
22160
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
120
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
121 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
122 * Get possible user status types. Based on mockprpl.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
123 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
124 * @return GList of status types.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
125 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
126 GList *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
127 msim_status_types(PurpleAccount *acct)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
128 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
129 GList *types;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
130 PurpleStatusType *status;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
131
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
132 purple_debug_info("myspace", "returning status types\n");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
133
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
134 types = NULL;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
135
22160
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
136 /* Statuses are almost all the same. Define a macro to reduce code repetition. */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
137 #define _MSIM_ADD_NEW_STATUS(prim) status = \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
138 purple_status_type_new_with_attrs( \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
139 prim, /* PurpleStatusPrimitive */ \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
140 NULL, /* id - use default */ \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
141 NULL, /* name - use default */ \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
142 TRUE, /* savable */ \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
143 TRUE, /* user_settable */ \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
144 FALSE, /* not independent */ \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
145 \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
146 /* Attributes - each status can have a message. */ \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
147 "message", \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
148 _("Message"), \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
149 purple_value_new(PURPLE_TYPE_STRING), \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
150 NULL); \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
151 \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
152 \
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
153 types = g_list_append(types, status)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
154
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
155
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
156 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_AVAILABLE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
157 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_AWAY);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
158 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_OFFLINE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
159 _MSIM_ADD_NEW_STATUS(PURPLE_STATUS_INVISIBLE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
160
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
161
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
162 return types;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
163 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
164
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
165 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
166 * Return the icon name for a buddy and account.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
167 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
168 * @param acct The account to find the icon for, or NULL for protocol icon.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
169 * @param buddy The buddy to find the icon for, or NULL for the account icon.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
170 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
171 * @return The base icon name string.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
172 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
173 const gchar *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
174 msim_list_icon(PurpleAccount *acct, PurpleBuddy *buddy)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
175 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
176 /* Use a MySpace icon submitted by hbons at
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
177 * http://developer.pidgin.im/wiki/MySpaceIM. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
178 return "myspace";
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
179 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
180
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
181 #ifdef MSIM_DEBUG_MSG
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
182 static void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
183 print_hash_item(gpointer key, gpointer value, gpointer user_data)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
184 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
185 purple_debug_info("msim", "%s=%s\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
186 key ? (gchar *)key : "(NULL)",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
187 value ? (gchar *)value : "(NULL)");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
188 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
189 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
190
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
191 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
192 * Send raw data (given as a NUL-terminated string) to the server.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
193 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
194 * @param session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
195 * @param msg The raw data to send, in a NUL-terminated string.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
196 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
197 * @return TRUE if succeeded, FALSE if not.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
198 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
199 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
200 gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
201 msim_send_raw(MsimSession *session, const gchar *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
202 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
203 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
204 g_return_val_if_fail(msg != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
205
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
206 purple_debug_info("msim", "msim_send_raw: writing <%s>\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
207
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
208 return msim_send_really_raw(session->gc, msg, strlen(msg)) ==
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
209 strlen(msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
210 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
211
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
212 /** Send raw data to the server, possibly with embedded NULs.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
213 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
214 * Used in prpl_info struct, so that plugins can have the most possible
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
215 * control of what is sent over the connection. Inside this prpl,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
216 * msim_send_raw() is used, since it sends NUL-terminated strings (easier).
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
217 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
218 * @param gc PurpleConnection
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
219 * @param buf Buffer to send
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
220 * @param total_bytes Size of buffer to send
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
221 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
222 * @return Bytes successfully sent, or -1 on error.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
223 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
224 static int
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
225 msim_send_really_raw(PurpleConnection *gc, const char *buf, int total_bytes)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
226 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
227 int total_bytes_sent;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
228 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
229
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
230 g_return_val_if_fail(gc != NULL, -1);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
231 g_return_val_if_fail(buf != NULL, -1);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
232 g_return_val_if_fail(total_bytes >= 0, -1);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
233
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
234 session = (MsimSession *)gc->proto_data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
235
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
236 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
237
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
238 /* Loop until all data is sent, or a failure occurs. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
239 total_bytes_sent = 0;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
240 do {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
241 int bytes_sent;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
243 bytes_sent = send(session->fd, buf + total_bytes_sent,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
244 total_bytes - total_bytes_sent, 0);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
245
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
246 if (bytes_sent < 0) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
247 purple_debug_info("msim", "msim_send_raw(%s): send() failed: %s\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
248 buf, g_strerror(errno));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
249 return total_bytes_sent;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
250 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
251 total_bytes_sent += bytes_sent;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
252
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
253 } while(total_bytes_sent < total_bytes);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
254
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
255 return total_bytes_sent;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
256 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
257
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
258
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
259 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
260 * Start logging in to the MSIM servers.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
261 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
262 * @param acct Account information to use to login.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
263 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
264 void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
265 msim_login(PurpleAccount *acct)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
266 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
267 PurpleConnection *gc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
268 const gchar *host;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
269 int port;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
270
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
271 g_return_if_fail(acct != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
272 g_return_if_fail(acct->username != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
273
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
274 purple_debug_info("msim", "logging in %s\n", acct->username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
275
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
276 gc = purple_account_get_connection(acct);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
277 gc->proto_data = msim_session_new(acct);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
278 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_URLDESC;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
279
19247
44b9e41bde2a No longer check the length of passwords - instead, pass the password to the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19246
diff changeset
280 #ifdef MSIM_MAX_PASSWORD_LENGTH
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
281 /* Passwords are limited in length. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
282 if (strlen(acct->password) > MSIM_MAX_PASSWORD_LENGTH) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
283 gchar *str;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
284
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
285 str = g_strdup_printf(
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
286 _("Sorry, passwords over %d characters in length (yours is "
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
287 "%d) are not supported by MySpace."),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
288 MSIM_MAX_PASSWORD_LENGTH,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
289 (int)strlen(acct->password));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
290
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
291 /* Notify an error message also, because this is important! */
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20685
diff changeset
292 purple_notify_error(acct, _("MySpaceIM Error"), str, NULL);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
293
20121
e4bcdd9622c2 purple_connection_error_reason-ify myspace
Will Thompson <will.thompson@collabora.co.uk>
parents: 20057
diff changeset
294 purple_connection_error_reason (gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
295 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, str);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
296 g_free(str);
20555
cfc4d2e23c76 It's presumably better not to try to connect right after calling
Will Thompson <will.thompson@collabora.co.uk>
parents: 20057
diff changeset
297 return;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
298 }
19247
44b9e41bde2a No longer check the length of passwords - instead, pass the password to the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19246
diff changeset
299 #endif
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
300
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
301 /* 1. connect to server */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
302 purple_connection_update_progress(gc, _("Connecting"),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
303 0, /* which connection step this is */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
304 4); /* total number of steps */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
305
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
306 host = purple_account_get_string(acct, "server", MSIM_SERVER);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
307 port = purple_account_get_int(acct, "port", MSIM_PORT);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
308
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
309 /* From purple.sf.net/api:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
310 * """Note that this function name can be misleading--although it is called
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
311 * "proxy connect," it is used for establishing any outgoing TCP connection,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
312 * whether through a proxy or not.""" */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
313
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
314 /* Calls msim_connect_cb when connected. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
315 if (!purple_proxy_connect(gc, acct, host, port, msim_connect_cb, gc)) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
316 /* TODO: try other ports if in auto mode, then save
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
317 * working port and try that first next time. */
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
318 purple_connection_error_reason (gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
319 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20121
e4bcdd9622c2 purple_connection_error_reason-ify myspace
Will Thompson <will.thompson@collabora.co.uk>
parents: 20057
diff changeset
320 _("Couldn't create socket"));
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
321 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
322 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
323 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
324
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
325 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
326 * Process a login challenge, sending a response.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
327 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
328 * @param session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
329 * @param msg Login challenge message.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
330 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
331 * @return TRUE if successful, FALSE if not
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
332 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
333 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
334 msim_login_challenge(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
335 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
336 PurpleAccount *account;
20658
7efdc052539d Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents: 20628
diff changeset
337 gchar *response;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
338 guint response_len;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
339 gchar *nc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
340 gsize nc_len;
20658
7efdc052539d Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents: 20628
diff changeset
341 gboolean ret;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
342
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
343 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
344 g_return_val_if_fail(msg != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
345
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
346 g_return_val_if_fail(msim_msg_get_binary(msg, "nc", &nc, &nc_len), FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
347
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
348 account = session->account;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
349
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
350 g_return_val_if_fail(account != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
351
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
352 purple_connection_update_progress(session->gc, _("Reading challenge"), 1, 4);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
353
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
354 purple_debug_info("msim", "nc is %d bytes, decoded\n", nc_len);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
355
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
356 if (nc_len != MSIM_AUTH_CHALLENGE_LENGTH) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
357 purple_debug_info("msim", "bad nc length: %x != 0x%x\n", nc_len, MSIM_AUTH_CHALLENGE_LENGTH);
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
358 purple_connection_error_reason (session->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
359 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20121
e4bcdd9622c2 purple_connection_error_reason-ify myspace
Will Thompson <will.thompson@collabora.co.uk>
parents: 20057
diff changeset
360 _("Unexpected challenge length from server"));
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
361 return FALSE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
362 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
363
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
364 purple_connection_update_progress(session->gc, _("Logging in"), 2, 4);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
365
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
366 response_len = 0;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
367 response = msim_compute_login_response(nc, account->username, account->password, &response_len);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
368
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
369 g_free(nc);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
370
20658
7efdc052539d Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents: 20628
diff changeset
371 ret = msim_send(session,
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
372 "login2", MSIM_TYPE_INTEGER, MSIM_AUTH_ALGORITHM,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
373 /* This is actually user's email address. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
374 "username", MSIM_TYPE_STRING, g_strdup(account->username),
20658
7efdc052539d Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents: 20628
diff changeset
375 /* GString will be freed in msim_msg_free() in msim_send(). */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
376 "response", MSIM_TYPE_BINARY, g_string_new_len(response, response_len),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
377 "clientver", MSIM_TYPE_INTEGER, MSIM_CLIENT_VERSION,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
378 "langid", MSIM_TYPE_INTEGER, MSIM_LANGUAGE_ID_ENGLISH,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
379 "imlang", MSIM_TYPE_STRING, g_strdup(MSIM_LANGUAGE_NAME_ENGLISH),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
380 "reconn", MSIM_TYPE_INTEGER, 0,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
381 "status", MSIM_TYPE_INTEGER, 100,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
382 "id", MSIM_TYPE_INTEGER, 1,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
383 NULL);
20658
7efdc052539d Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents: 20628
diff changeset
384
7efdc052539d Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents: 20628
diff changeset
385 g_free(response);
7efdc052539d Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents: 20628
diff changeset
386
7efdc052539d Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents: 20628
diff changeset
387 return ret;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
388 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
389
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
390 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
391 * Compute the base64'd login challenge response based on username, password, nonce, and IPs.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
392 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
393 * @param nonce The base64 encoded nonce ('nc') field from the server.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
394 * @param email User's email address (used as login name).
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
395 * @param password User's cleartext password.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
396 * @param response_len Will be written with response length.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
397 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
398 * @return Binary login challenge response, ready to send to the server.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
399 * Must be g_free()'d when finished. NULL if error.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
400 */
20658
7efdc052539d Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents: 20628
diff changeset
401 static gchar *
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
402 msim_compute_login_response(const gchar nonce[2 * NONCE_SIZE],
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
403 const gchar *email, const gchar *password, guint *response_len)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
404 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
405 PurpleCipherContext *key_context;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
406 PurpleCipher *sha1;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
407 PurpleCipherContext *rc4;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
408
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
409 guchar hash_pw[HASH_SIZE];
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
410 guchar key[HASH_SIZE];
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
411 gchar *password_utf16le, *password_utf8_lc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
412 guchar *data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
413 guchar *data_out;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
414 size_t data_len, data_out_len;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
415 gsize conv_bytes_read, conv_bytes_written;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
416 GError *conv_error;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
417 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
418 int i;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
419 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
420
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
421 g_return_val_if_fail(nonce != NULL, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
422 g_return_val_if_fail(email != NULL, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
423 g_return_val_if_fail(password != NULL, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
424 g_return_val_if_fail(response_len != NULL, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
425
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
426 /* Convert password to lowercase (required for passwords containing
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
427 * uppercase characters). MySpace passwords are lowercase,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
428 * see ticket #2066. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
429 password_utf8_lc = g_utf8_strdown(password, -1);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
430
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
431 /* Convert ASCII password to UTF16 little endian */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
432 purple_debug_info("msim", "converting password to UTF-16LE\n");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
433 conv_error = NULL;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
434 password_utf16le = g_convert(password_utf8_lc, -1, "UTF-16LE", "UTF-8",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
435 &conv_bytes_read, &conv_bytes_written, &conv_error);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
436 g_free(password_utf8_lc);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
437
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
438 g_return_val_if_fail(conv_bytes_read == strlen(password), NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
439
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
440 if (conv_error != NULL) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
441 purple_debug_error("msim",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
442 "g_convert password UTF8->UTF16LE failed: %s",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
443 conv_error->message);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
444 g_error_free(conv_error);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
445 return NULL;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
446 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
447
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
448 /* Compute password hash */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
449 purple_cipher_digest_region("sha1", (guchar *)password_utf16le,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
450 conv_bytes_written, sizeof(hash_pw), hash_pw, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
451 g_free(password_utf16le);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
452
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
453 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
454 purple_debug_info("msim", "pwhash = ");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
455 for (i = 0; i < sizeof(hash_pw); i++)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
456 purple_debug_info("msim", "%.2x ", hash_pw[i]);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
457 purple_debug_info("msim", "\n");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
458 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
459
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
460 /* key = sha1(sha1(pw) + nonce2) */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
461 sha1 = purple_ciphers_find_cipher("sha1");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
462 key_context = purple_cipher_context_new(sha1, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
463 purple_cipher_context_append(key_context, hash_pw, HASH_SIZE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
464 purple_cipher_context_append(key_context, (guchar *)(nonce + NONCE_SIZE), NONCE_SIZE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
465 purple_cipher_context_digest(key_context, sizeof(key), key, NULL);
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20057
diff changeset
466 purple_cipher_context_destroy(key_context);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
467
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
468 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
469 purple_debug_info("msim", "key = ");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
470 for (i = 0; i < sizeof(key); i++) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
471 purple_debug_info("msim", "%.2x ", key[i]);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
472 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
473 purple_debug_info("msim", "\n");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
474 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
475
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
476 rc4 = purple_cipher_context_new_by_name("rc4", NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
477
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
478 /* Note: 'key' variable is 0x14 bytes (from SHA-1 hash),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
479 * but only first 0x10 used for the RC4 key. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
480 purple_cipher_context_set_option(rc4, "key_len", (gpointer)0x10);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
481 purple_cipher_context_set_key(rc4, key);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
482
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
483 /* TODO: obtain IPs of network interfaces */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
484
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
485 /* rc4 encrypt:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
486 * nonce1+email+IP list */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
487
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
488 data_len = NONCE_SIZE + strlen(email) + MSIM_LOGIN_IP_LIST_LEN;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
489 data = g_new0(guchar, data_len);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
490 memcpy(data, nonce, NONCE_SIZE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
491 memcpy(data + NONCE_SIZE, email, strlen(email));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
492 memcpy(data + NONCE_SIZE + strlen(email), MSIM_LOGIN_IP_LIST, MSIM_LOGIN_IP_LIST_LEN);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
493
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
494 data_out = g_new0(guchar, data_len);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
495
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
496 purple_cipher_context_encrypt(rc4, (const guchar *)data,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
497 data_len, data_out, &data_out_len);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
498 purple_cipher_context_destroy(rc4);
20664
324c25c2daad Remove g_assert() from msimprpl.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20658
diff changeset
499 g_free(data);
324c25c2daad Remove g_assert() from msimprpl.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20658
diff changeset
500
324c25c2daad Remove g_assert() from msimprpl.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20658
diff changeset
501 if (data_out_len != data_len) {
324c25c2daad Remove g_assert() from msimprpl.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20658
diff changeset
502 purple_debug_info("msim", "msim_compute_login_response: "
324c25c2daad Remove g_assert() from msimprpl.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20658
diff changeset
503 "data length mismatch: %d != %d\n",
324c25c2daad Remove g_assert() from msimprpl.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20658
diff changeset
504 data_out_len, data_len);
324c25c2daad Remove g_assert() from msimprpl.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20658
diff changeset
505 }
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
506
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
507 #ifdef MSIM_DEBUG_LOGIN_CHALLENGE
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
508 purple_debug_info("msim", "response=<%s>\n", data_out);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
509 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
510
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
511 *response_len = data_out_len;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
512
20658
7efdc052539d Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents: 20628
diff changeset
513 return (gchar *)data_out;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
514 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
515
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
516 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
517 * Schedule an IM to be sent once the user ID is looked up.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
518 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
519 * @param gc Connection.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
520 * @param who A user id, email, or username to send the message to.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
521 * @param message Instant message text to send.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
522 * @param flags Flags.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
523 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
524 * @return 1 if successful or postponed, -1 if failed
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
525 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
526 * Allows sending to a user by username, email address, or userid. If
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
527 * a username or email address is given, the userid must be looked up.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
528 * This function does that by calling msim_postprocess_outgoing().
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
529 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
530 int
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
531 msim_send_im(PurpleConnection *gc, const gchar *who, const gchar *message,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
532 PurpleMessageFlags flags)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
533 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
534 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
535 gchar *message_msim;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
536 int rc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
537
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
538 g_return_val_if_fail(gc != NULL, -1);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
539 g_return_val_if_fail(who != NULL, -1);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
540 g_return_val_if_fail(message != NULL, -1);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
541
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
542 /* 'flags' has many options, not used here. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
543
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
544 session = (MsimSession *)gc->proto_data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
545
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
546 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
547
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
548 message_msim = html_to_msim_markup(session, message);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
549
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
550 if (msim_send_bm(session, who, message_msim, MSIM_BM_INSTANT)) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
551 /* Return 1 to have Purple show this IM as being sent, 0 to not. I always
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
552 * return 1 even if the message could not be sent, since I don't know if
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
553 * it has failed yet--because the IM is only sent after the userid is
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
554 * retrieved from the server (which happens after this function returns).
22160
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
555 * If an error does occur, it should be logged to the IM window.
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
556 */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
557 rc = 1;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
558 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
559 rc = -1;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
560 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
561
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
562 g_free(message_msim);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
563
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
564 return rc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
565 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
566
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
567 /** Send a buddy message of a given type.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
568 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
569 * @param session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
570 * @param who Username to send message to.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
571 * @param text Message text to send. Not freed; will be copied.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
572 * @param type A MSIM_BM_* constant.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
573 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
574 * @return TRUE if success, FALSE if fail.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
575 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
576 * Buddy messages ('bm') include instant messages, action messages, status messages, etc.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
577 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
578 */
19432
210f792efd7c In msimprpl, move zap-related code to a separate module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19431
diff changeset
579 gboolean
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
580 msim_send_bm(MsimSession *session, const gchar *who, const gchar *text,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
581 int type)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
582 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
583 gboolean rc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
584 MsimMessage *msg;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
585 const gchar *from_username;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
586
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
587 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
588 g_return_val_if_fail(who != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
589 g_return_val_if_fail(text != NULL, FALSE);
22160
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
590
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
591 from_username = session->account->username;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
592
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
593 g_return_val_if_fail(from_username != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
594
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
595 purple_debug_info("msim", "sending %d message from %s to %s: %s\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
596 type, from_username, who, text);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
597
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
598 msg = msim_msg_new(
22160
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
599 "bm", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(type),
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
600 "sesskey", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(session->sesskey),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
601 /* 't' will be inserted here */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
602 "cv", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(MSIM_CLIENT_VERSION),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
603 "msg", MSIM_TYPE_STRING, g_strdup(text),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
604 NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
605
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
606 rc = msim_postprocess_outgoing(session, msg, who, "t", "cv");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
607
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
608 msim_msg_free(msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
609
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
610 return rc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
611 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
612
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
613
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
614 /** Record the client version in the buddy list, from an incoming message. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
615 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
616 msim_incoming_bm_record_cv(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
617 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
618 gchar *username, *cv;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
619 gboolean ret;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
620 MsimUser *user;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
621
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
622 username = msim_msg_get_string(msg, "_username");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
623 cv = msim_msg_get_string(msg, "cv");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
624
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
625 g_return_val_if_fail(username != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
626 if (!cv) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
627 /* No client version to record, don't worry about it. */
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20685
diff changeset
628 g_free(username);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
629 return FALSE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
630 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
631
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
632 user = msim_find_user(session, username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
633
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
634 if (user) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
635 user->client_cv = atol(cv);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
636 ret = TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
637 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
638 ret = FALSE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
639 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
640
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
641 g_free(username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
642 g_free(cv);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
643
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
644 return ret;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
645 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
646
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
647 /** Handle an incoming buddy message. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
648 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
649 msim_incoming_bm(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
650 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
651 guint bm;
22222
433233d3db10 merge of '2e288b76540410af9b0ca21669ffb7e085633d59'
Mark Doliner <mark@kingant.net>
parents: 22195 22162
diff changeset
652
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
653 bm = msim_msg_get_integer(msg, "bm");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
654
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
655 msim_incoming_bm_record_cv(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
656
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
657 switch (bm) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
658 case MSIM_BM_STATUS:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
659 return msim_incoming_status(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
660 case MSIM_BM_INSTANT:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
661 return msim_incoming_im(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
662 case MSIM_BM_ACTION:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
663 return msim_incoming_action(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
664 case MSIM_BM_MEDIA:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
665 return msim_incoming_media(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
666 case MSIM_BM_UNOFFICIAL_CLIENT:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
667 return msim_incoming_unofficial_client(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
668 default:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
669 /* Not really an IM, but show it for informational
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
670 * purposes during development. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
671 return msim_incoming_im(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
672 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
673 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
674
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
675 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
676 * Handle an incoming instant message.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
677 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
678 * @param session The session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
679 * @param msg Message from the server, containing 'f' (userid from) and 'msg'.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
680 * Should also contain username in _username from preprocessing.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
681 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
682 * @return TRUE if successful.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
683 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
684 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
685 msim_incoming_im(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
686 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
687 gchar *username, *msg_msim_markup, *msg_purple_markup;
19570
94a2a1ccd6ec Use the sent timestamp in incoming instant messages instead of the current
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19466
diff changeset
688 time_t time_received;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
689
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
690 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
691 g_return_val_if_fail(msg != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
692
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
693 username = msim_msg_get_string(msg, "_username");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
694 g_return_val_if_fail(username != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
695
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
696 msg_msim_markup = msim_msg_get_string(msg, "msg");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
697 g_return_val_if_fail(msg_msim_markup != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
698
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
699 msg_purple_markup = msim_markup_to_html(session, msg_msim_markup);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
700 g_free(msg_msim_markup);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
701
19570
94a2a1ccd6ec Use the sent timestamp in incoming instant messages instead of the current
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19466
diff changeset
702 time_received = msim_msg_get_integer(msg, "date");
94a2a1ccd6ec Use the sent timestamp in incoming instant messages instead of the current
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19466
diff changeset
703 if (!time_received) {
94a2a1ccd6ec Use the sent timestamp in incoming instant messages instead of the current
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19466
diff changeset
704 time_received = time(NULL);
94a2a1ccd6ec Use the sent timestamp in incoming instant messages instead of the current
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19466
diff changeset
705 }
94a2a1ccd6ec Use the sent timestamp in incoming instant messages instead of the current
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19466
diff changeset
706
94a2a1ccd6ec Use the sent timestamp in incoming instant messages instead of the current
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19466
diff changeset
707 serv_got_im(session->gc, username, msg_purple_markup, PURPLE_MESSAGE_RECV, time_received);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
708
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
709 g_free(username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
710 g_free(msg_purple_markup);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
711
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
712 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
713 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
714
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
715 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
716 * Process unrecognized information.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
717 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
718 * @param session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
719 * @param msg An MsimMessage that was unrecognized, or NULL.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
720 * @param note Information on what was unrecognized, or NULL.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
721 */
19435
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
722 void
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
723 msim_unrecognized(MsimSession *session, MsimMessage *msg, gchar *note)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
724 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
725 /* TODO: Some more context, outwardly equivalent to a backtrace,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
726 * for helping figure out what this msg is for. What was going on?
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
727 * But not too much information so that a user
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
728 * posting this dump reveals confidential information.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
729 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
730
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
731 /* TODO: dump unknown msgs to file, so user can send them to me
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
732 * if they wish, to help add support for new messages (inspired
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
733 * by Alexandr Shutko, who maintains OSCAR protocol documentation).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
734 *
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
735 * Filed enhancement ticket for libpurple as #4688.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
736 */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
737
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
738 purple_debug_info("msim", "Unrecognized data on account for %s\n",
19353
af0e77c44667 MySpace added a new field, LastImageUpdated. Save it in MsimUser.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19352
diff changeset
739 (session && session->account && session->account->username) ?
af0e77c44667 MySpace added a new field, LastImageUpdated. Save it in MsimUser.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19352
diff changeset
740 session->account->username : "(NULL)");
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
741 if (note) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
742 purple_debug_info("msim", "(Note: %s)\n", note);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
743 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
744
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
745 if (msg) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
746 msim_msg_dump("Unrecognized message dump: %s\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
747 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
748 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
749
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
750 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
751 * Handle an incoming action message.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
752 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
753 * @param session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
754 * @param msg
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
755 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
756 * @return TRUE if successful.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
757 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
758 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
759 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
760 msim_incoming_action(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
761 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
762 gchar *msg_text, *username;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
763 gboolean rc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
764
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
765 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
766 g_return_val_if_fail(msg != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
767
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
768 msg_text = msim_msg_get_string(msg, "msg");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
769 g_return_val_if_fail(msg_text != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
770
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
771 username = msim_msg_get_string(msg, "_username");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
772 g_return_val_if_fail(username != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
773
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
774 purple_debug_info("msim", "msim_incoming_action: action <%s> from <%d>\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
775 msg_text, username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
776
19428
1fa10842eb83 In msimprpl, replace !strcmp() with g_str_equal() everywhere.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19427
diff changeset
777 if (g_str_equal(msg_text, "%typing%")) {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
778 serv_got_typing(session->gc, username, 0, PURPLE_TYPING);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
779 rc = TRUE;
19428
1fa10842eb83 In msimprpl, replace !strcmp() with g_str_equal() everywhere.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19427
diff changeset
780 } else if (g_str_equal(msg_text, "%stoptyping%")) {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
781 serv_got_typing_stopped(session->gc, username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
782 rc = TRUE;
22222
433233d3db10 merge of '2e288b76540410af9b0ca21669ffb7e085633d59'
Mark Doliner <mark@kingant.net>
parents: 22195 22162
diff changeset
783 } else if (strstr(msg_text, "!!!ZAP_SEND!!!=RTE_BTN_ZAPS_") == msg_text) {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
784 rc = msim_incoming_zap(session, msg);
22161
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
785 } else if (strstr(msg_text, "!!!GroupCount=")) {
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
786 /* TODO: support group chats. I think the number in msg_text has
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
787 * something to do with the 'gid' field. */
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
788 purple_debug_info("msim", "msim_incoming_action: TODO: implement #4691, group chats: %s\n", msg_text);
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
789
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
790 rc = TRUE;
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
791 } else if (strstr(msg_text, "!!!Offline=")) {
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
792 /* TODO: support group chats. This one might mean a user
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
793 * went offline or exited the chat. */
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
794 purple_debug_info("msim", "msim_incoming_action: TODO: implement #4691, group chats: %s\n", msg_text);
22222
433233d3db10 merge of '2e288b76540410af9b0ca21669ffb7e085633d59'
Mark Doliner <mark@kingant.net>
parents: 22195 22162
diff changeset
795
22161
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
796 rc = TRUE;
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
797 } else if (msim_msg_get_integer(msg, "aid") != 0) {
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
798 purple_debug_info("msim", "TODO: implement #4691, group chat from %d on %d: %s\n",
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
799 msim_msg_get_integer(msg, "aid"),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
800 msim_msg_get_integer(msg, "f"),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
801 msg_text);
22222
433233d3db10 merge of '2e288b76540410af9b0ca21669ffb7e085633d59'
Mark Doliner <mark@kingant.net>
parents: 22195 22162
diff changeset
802
22161
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22160
diff changeset
803 rc = TRUE;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
804 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
805 msim_unrecognized(session, msg,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
806 "got to msim_incoming_action but unrecognized value for 'msg'");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
807 rc = FALSE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
808 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
809
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
810 g_free(msg_text);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
811 g_free(username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
812
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
813 return rc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
814 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
815
19351
5461821ac122 g_memdup() the icon data before setting it as the buddy icon.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19350
diff changeset
816 /* Process an incoming media (message background?) message. */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
817 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
818 msim_incoming_media(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
819 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
820 gchar *username, *text;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
821
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
822 username = msim_msg_get_string(msg, "_username");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
823 text = msim_msg_get_string(msg, "msg");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
824
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
825 g_return_val_if_fail(username != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
826 g_return_val_if_fail(text != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
827
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
828 purple_debug_info("msim", "msim_incoming_media: from %s, got msg=%s\n", username, text);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
829
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
830 /* Media messages are sent when the user opens a window to someone.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
831 * Tell libpurple they started typing and stopped typing, to inform the Psychic
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
832 * Mode plugin so it too can open a window to the user. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
833 serv_got_typing(session->gc, username, 0, PURPLE_TYPING);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
834 serv_got_typing_stopped(session->gc, username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
835
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
836 g_free(username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
837
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
838 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
839 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
840
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
841 /* Process an incoming "unofficial client" message. The plugin for
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
842 * Miranda IM sends this message with the plugin information. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
843 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
844 msim_incoming_unofficial_client(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
845 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
846 MsimUser *user;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
847 gchar *username, *client_info;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
848
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
849 username = msim_msg_get_string(msg, "_username");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
850 client_info = msim_msg_get_string(msg, "msg");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
851
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
852 g_return_val_if_fail(username != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
853 g_return_val_if_fail(client_info != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
854
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
855 purple_debug_info("msim", "msim_incoming_unofficial_client: %s is using client %s\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
856 username, client_info);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
857
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
858 user = msim_find_user(session, username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
859
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
860 g_return_val_if_fail(user != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
861
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
862 if (user->client_info) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
863 g_free(user->client_info);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
864 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
865 user->client_info = client_info;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
866
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
867 g_free(username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
868 /* Do not free client_info - the MsimUser now owns it. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
869
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
870 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
871 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
872
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
873
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
874 #ifdef MSIM_SEND_CLIENT_VERSION
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
875 /** Send our client version to another unofficial client that understands it. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
876 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
877 msim_send_unofficial_client(MsimSession *session, gchar *username)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
878 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
879 gchar *our_info;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
880 gboolean ret;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
881
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
882 our_info = g_strdup_printf("Libpurple %d.%d.%d - msimprpl %s",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
883 PURPLE_MAJOR_VERSION,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
884 PURPLE_MINOR_VERSION,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
885 PURPLE_MICRO_VERSION,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
886 MSIM_PRPL_VERSION_STRING);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
887
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
888 ret = msim_send_bm(session, username, our_info, MSIM_BM_UNOFFICIAL_CLIENT);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
889
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
890 return ret;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
891 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
892 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
893
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
894 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
895 * Handle when our user starts or stops typing to another user.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
896 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
897 * @param gc
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
898 * @param name The buddy name to which our user is typing to
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
899 * @param state PURPLE_TYPING, PURPLE_TYPED, PURPLE_NOT_TYPING
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
900 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
901 * @return 0
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
902 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
903 unsigned int
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
904 msim_send_typing(PurpleConnection *gc, const gchar *name,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
905 PurpleTypingState state)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
906 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
907 const gchar *typing_str;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
908 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
909
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
910 g_return_val_if_fail(gc != NULL, 0);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
911 g_return_val_if_fail(name != NULL, 0);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
912
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
913 session = (MsimSession *)gc->proto_data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
914
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
915 g_return_val_if_fail(MSIM_SESSION_VALID(session), 0);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
916
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
917 switch (state) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
918 case PURPLE_TYPING:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
919 typing_str = "%typing%";
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
920 break;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
921
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
922 case PURPLE_TYPED:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
923 case PURPLE_NOT_TYPING:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
924 default:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
925 typing_str = "%stoptyping%";
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
926 break;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
927 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
928
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
929 purple_debug_info("msim", "msim_send_typing(%s): %d (%s)\n", name, state, typing_str);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
930 msim_send_bm(session, name, typing_str, MSIM_BM_ACTION);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
931 return 0;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
932 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
933
19435
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
934
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
935
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
936 /** Callback for msim_get_info(), for when user info is received. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
937 static void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
938 msim_get_info_cb(MsimSession *session, MsimMessage *user_info_msg,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
939 gpointer data)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
940 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
941 MsimMessage *msg;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
942 gchar *username;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
943 PurpleNotifyUserInfo *user_info;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
944 MsimUser *user;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
945
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
946 g_return_if_fail(MSIM_SESSION_VALID(session));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
947
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
948 /* Get user{name,id} from msim_get_info, passed as an MsimMessage for
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
949 orthogonality. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
950 msg = (MsimMessage *)data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
951 g_return_if_fail(msg != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
952
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
953 username = msim_msg_get_string(msg, "user");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
954 if (!username) {
19653
941965d6fd88 Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19637
diff changeset
955 purple_debug_info("msim", "msim_get_info_cb: no 'user' in msg\n");
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
956 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
957 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
958
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
959 msim_msg_free(msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
960 purple_debug_info("msim", "msim_get_info_cb: got for user: %s\n", username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
961
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
962 user = msim_find_user(session, username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
963
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
964 if (!user) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
965 /* User isn't on blist, create a temporary user to store info. */
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
966 /* TODO: is this legit, or is it somehow responsible for #3444? */
20982
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20861
diff changeset
967 PurpleBuddy *buddy;
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20861
diff changeset
968
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
969 user = g_new0(MsimUser, 1);
20982
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20861
diff changeset
970 user->temporary_user = TRUE;
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20861
diff changeset
971
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20861
diff changeset
972 buddy = purple_buddy_new(session->account, username, NULL);
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20861
diff changeset
973 user->buddy = buddy;
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20861
diff changeset
974 buddy->proto_data = (gpointer)user;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
975 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
976
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
977 /* Update user structure with new information */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
978 msim_store_user_info(session, user_info_msg, user);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
979
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
980 user_info = purple_notify_user_info_new();
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
981
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
982 /* Append data from MsimUser to PurpleNotifyUserInfo for display, full */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
983 msim_append_user_info(session, user_info, user, TRUE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
984
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
985 purple_notify_userinfo(session->gc, username, user_info, NULL, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
986 purple_debug_info("msim", "msim_get_info_cb: username=%s\n", username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
987
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
988 purple_notify_user_info_destroy(user_info);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
989
20982
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20861
diff changeset
990 if (user->temporary_user) {
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20861
diff changeset
991 purple_blist_remove_buddy(user->buddy);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
992 g_free(user->client_info);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
993 g_free(user->gender);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
994 g_free(user->location);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
995 g_free(user->headline);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
996 g_free(user->display_name);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
997 g_free(user->username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
998 g_free(user->band_name);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
999 g_free(user->song_name);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1000 g_free(user->image_url);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1001 g_free(user);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1002 }
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20685
diff changeset
1003 g_free(username);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1004 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1005
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1006 /** Retrieve a user's profile.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1007 * @param username Username, user ID, or email address to lookup.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1008 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1009 void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1010 msim_get_info(PurpleConnection *gc, const gchar *username)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1011 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1012 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1013 MsimUser *user;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1014 guint uid;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1015 gchar *user_to_lookup;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1016 MsimMessage *user_msg;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1017
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1018 g_return_if_fail(gc != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1019 g_return_if_fail(username != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1020
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1021 session = (MsimSession *)gc->proto_data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1022
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1023 g_return_if_fail(MSIM_SESSION_VALID(session));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1024
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1025 /* Obtain uid of buddy. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1026 user = msim_find_user(session, username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1027
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1028 /* If is on buddy list, lookup by uid since it is faster. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1029 if (user && (uid = purple_blist_node_get_int(&user->buddy->node, "UserID"))) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1030 user_to_lookup = g_strdup_printf("%d", uid);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1031 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1032 /* Looking up buddy not on blist. Lookup by whatever user entered. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1033 user_to_lookup = g_strdup(username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1034 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1035
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1036 /* Pass the username to msim_get_info_cb(), because since we lookup
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1037 * by userid, the userinfo message will only contain the uid (not
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1038 * the username) but it would be useful to display the username too.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1039 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1040 user_msg = msim_msg_new(
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1041 "user", MSIM_TYPE_STRING, g_strdup(username),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1042 NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1043 purple_debug_info("msim", "msim_get_info, setting up lookup, user=%s\n", username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1044
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1045 msim_lookup_user(session, user_to_lookup, msim_get_info_cb, user_msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1046
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1047 g_free(user_to_lookup);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1048 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1049
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1050 /** Set your status - callback for when user manually sets it. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1051 void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1052 msim_set_status(PurpleAccount *account, PurpleStatus *status)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1053 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1054 PurpleStatusType *type;
21707
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1055 PurplePresence *pres;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1056 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1057 guint status_code;
21707
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1058 const gchar *message;
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1059 gchar *stripped;
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1060 gchar *unrecognized_msg;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1061
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1062 session = (MsimSession *)account->gc->proto_data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1063
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1064 g_return_if_fail(MSIM_SESSION_VALID(session));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1065
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1066 type = purple_status_get_type(status);
21707
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1067 pres = purple_status_get_presence(status);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1068
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1069 switch (purple_status_type_get_primitive(type)) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1070 case PURPLE_STATUS_AVAILABLE:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1071 purple_debug_info("msim", "msim_set_status: available (%d->%d)\n", PURPLE_STATUS_AVAILABLE,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1072 MSIM_STATUS_CODE_ONLINE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1073 status_code = MSIM_STATUS_CODE_ONLINE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1074 break;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1075
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1076 case PURPLE_STATUS_INVISIBLE:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1077 purple_debug_info("msim", "msim_set_status: invisible (%d->%d)\n", PURPLE_STATUS_INVISIBLE,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1078 MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1079 status_code = MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1080 break;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1081
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1082 case PURPLE_STATUS_AWAY:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1083 purple_debug_info("msim", "msim_set_status: away (%d->%d)\n", PURPLE_STATUS_AWAY,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1084 MSIM_STATUS_CODE_AWAY);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1085 status_code = MSIM_STATUS_CODE_AWAY;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1086 break;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1087
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1088 default:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1089 purple_debug_info("msim", "msim_set_status: unknown "
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1090 "status interpreting as online");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1091 status_code = MSIM_STATUS_CODE_ONLINE;
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1092
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1093 unrecognized_msg = g_strdup_printf("msim_set_status, unrecognized status type: %d\n",
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1094 purple_status_type_get_primitive(type));
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1095 msim_unrecognized(session, NULL, unrecognized_msg);
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1096 g_free(unrecognized_msg);
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1097
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1098 break;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1099 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1100
21709
b2c2e935a150 Remove useless cast I missed before.
Kevin Stange <kevin@simguy.net>
parents: 21707
diff changeset
1101 message = purple_status_get_attr_string(status, "message");
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1102
19592
d6802883e96e Treat status messages as the plaintext that they are.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19570
diff changeset
1103 /* Status strings are plain text. */
21707
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1104 if (message != NULL)
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1105 stripped = purple_markup_strip_html(message);
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1106 else
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1107 stripped = g_strdup("");
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1108
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1109 msim_set_status_code(session, status_code, stripped);
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1110
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1111 /* If we should be idle, set that status. Time is irrelevant here. */
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1112 if (purple_presence_is_idle(pres) && status_code != MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN)
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1113 msim_set_idle(account->gc, 1);
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1114
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1115 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1116
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1117 /** Go idle. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1118 void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1119 msim_set_idle(PurpleConnection *gc, int time)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1120 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1121 MsimSession *session;
21707
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1122 PurpleStatus *status;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1123
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1124 g_return_if_fail(gc != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1125
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1126 session = (MsimSession *)gc->proto_data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1127
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1128 g_return_if_fail(MSIM_SESSION_VALID(session));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1129
21707
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1130 status = purple_account_get_active_status(session->account);
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1131
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1132 if (time == 0) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1133 /* Going back from idle. In msim, idle is mutually exclusive
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1134 * from the other states (you can only be away or idle, but not
21707
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1135 * both, for example), so by going non-idle I go back to what
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1136 * libpurple says I should be.
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1137 */
21707
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1138 msim_set_status(session->account, status);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1139 } else {
21707
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1140 const gchar *message;
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1141 gchar *stripped;
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1142
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1143 /* Set the idle message to the status message from the real
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1144 * current status.
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1145 */
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1146 message = purple_status_get_attr_string(status, "message");
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1147 if (message != NULL)
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1148 stripped = purple_markup_strip_html(message);
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1149 else
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1150 stripped = g_strdup("");
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1151
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1152 /* msim doesn't support idle time, so just go idle */
21707
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1153 msim_set_status_code(session, MSIM_STATUS_CODE_IDLE, stripped);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1154 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1155 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1156
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1157 /** Set status using an MSIM_STATUS_CODE_* value.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1158 * @param status_code An MSIM_STATUS_CODE_* value.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1159 * @param statstring Status string, must be a dynamic string (will be freed by msim_send).
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1160 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1161 static void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1162 msim_set_status_code(MsimSession *session, guint status_code, gchar *statstring)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1163 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1164 g_return_if_fail(MSIM_SESSION_VALID(session));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1165 g_return_if_fail(statstring != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1166
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1167 purple_debug_info("msim", "msim_set_status_code: going to set status to code=%d,str=%s\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1168 status_code, statstring);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1169
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1170 if (!msim_send(session,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1171 "status", MSIM_TYPE_INTEGER, status_code,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1172 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1173 "statstring", MSIM_TYPE_STRING, statstring,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1174 "locstring", MSIM_TYPE_STRING, g_strdup(""),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1175 NULL))
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1176 {
19653
941965d6fd88 Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19637
diff changeset
1177 purple_debug_info("msim", "msim_set_status: failed to set status\n");
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1178 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1179
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1180 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1181
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1182 /** After a uid is resolved to username, tag it with the username and submit for processing.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1183 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1184 * @param session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1185 * @param userinfo Response messsage to resolving request.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1186 * @param data MsimMessage *, the message to attach information to.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1187 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1188 static void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1189 msim_incoming_resolved(MsimSession *session, MsimMessage *userinfo,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1190 gpointer data)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1191 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1192 gchar *username;
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1193 MsimMessage *msg, *body;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1194
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1195 g_return_if_fail(MSIM_SESSION_VALID(session));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1196 g_return_if_fail(userinfo != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1197
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1198 body = msim_msg_get_dictionary(userinfo, "body");
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1199 g_return_if_fail(body != NULL);
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1200
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1201 username = msim_msg_get_string(body, "UserName");
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1202 g_return_if_fail(username != NULL);
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1203 /* Note: username will be owned by 'msg' below. */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1204
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1205 msg = (MsimMessage *)data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1206 g_return_if_fail(msg != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1207
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1208 /* TODO: more elegant solution than below. attach whole message? */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1209 /* Special elements name beginning with '_', we'll use internally within the
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1210 * program (did not come directly from the wire). */
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20685
diff changeset
1211 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, username); /* This makes 'msg' the owner of 'username' */
22222
433233d3db10 merge of '2e288b76540410af9b0ca21669ffb7e085633d59'
Mark Doliner <mark@kingant.net>
parents: 22195 22162
diff changeset
1212
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1213 /* TODO: attach more useful information, like ImageURL */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1214
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1215 msim_process(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1216
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1217 /* TODO: Free copy cloned from msim_preprocess_incoming(). */
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1218 /* msim_msg_free(msg); */
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1219 msim_msg_free(body);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1220 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1221
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1222 /* Lookup a username by userid, from buddy list.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1223 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1224 * @param wanted_uid
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1225 *
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1226 * @return Username of wanted_uid, if on blist, or NULL. Static string.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1227 * TODO: The username string here is a new string from g_strdup(), not
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1228 * a static string that doesn't need to be fixed. Probably leaks. TODO: fix.
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1229 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1230 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1231 static const gchar *
22159
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22158
diff changeset
1232 msim_uid2username_from_blist(PurpleAccount *account, guint wanted_uid)
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1233 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1234 GSList *buddies, *cur;
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
1235 gchar *ret;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1236
22159
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22158
diff changeset
1237 buddies = purple_find_buddies(account, NULL);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1238
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1239 if (!buddies)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1240 {
19653
941965d6fd88 Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19637
diff changeset
1241 purple_debug_info("msim", "msim_uid2username_from_blist: no buddies?\n");
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1242 return NULL;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1243 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1244
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
1245 ret = NULL;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1246
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1247 for (cur = buddies; cur != NULL; cur = g_slist_next(cur))
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1248 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1249 PurpleBuddy *buddy;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1250 guint uid;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1251 const gchar *name;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1252
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1253 /* See finch/gnthistory.c */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1254 buddy = cur->data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1255
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1256 uid = purple_blist_node_get_int(&buddy->node, "UserID");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1257 name = purple_buddy_get_name(buddy);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1258
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1259 if (uid == wanted_uid)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1260 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1261 ret = g_strdup(name);
20150
52dce2882c03 Fix a few memory leaks in #3281 (details in ticket).
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 20057
diff changeset
1262 break;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1263 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1264 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1265
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1266 g_slist_free(buddies);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1267 return ret;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1268 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1269
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1270 /** Preprocess incoming messages, resolving as needed, calling msim_process() when ready to process.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1271 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1272 * @param session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1273 * @param msg MsimMessage *, freed by caller.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1274 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1275 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1276 msim_preprocess_incoming(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1277 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1278 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1279 g_return_val_if_fail(msg != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1280
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1281 if (msim_msg_get(msg, "bm") && msim_msg_get(msg, "f")) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1282 guint uid;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1283 const gchar *username;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1284
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1285 /* 'f' = userid message is from, in buddy messages */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1286 uid = msim_msg_get_integer(msg, "f");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1287
22159
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22158
diff changeset
1288 username = msim_uid2username_from_blist(session->account, uid);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1289
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1290 if (username) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1291 /* Know username already, use it. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1292 purple_debug_info("msim", "msim_preprocess_incoming: tagging with _username=%s\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1293 username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1294 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1295 return msim_process(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1296
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1297 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1298 gchar *from;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1299
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1300 /* Send lookup request. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1301 /* XXX: where is msim_msg_get_string() freed? make _strdup and _nonstrdup. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1302 purple_debug_info("msim", "msim_incoming: sending lookup, setting up callback\n");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1303 from = msim_msg_get_string(msg, "f");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1304 msim_lookup_user(session, from, msim_incoming_resolved, msim_msg_clone(msg));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1305 g_free(from);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1306
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1307 /* indeterminate */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1308 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1309 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1310 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1311 /* Nothing to resolve - send directly to processing. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1312 return msim_process(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1313 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1314 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1315
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1316 #ifdef MSIM_USE_KEEPALIVE
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1317 /** Check if the connection is still alive, based on last communication. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1318 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1319 msim_check_alive(gpointer data)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1320 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1321 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1322 time_t delta;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1323 gchar *errmsg;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1324
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1325 session = (MsimSession *)data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1326
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1327 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1328
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1329 delta = time(NULL) - session->last_comm;
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1330 /* purple_debug_info("msim", "msim_check_alive: delta=%d\n", delta); */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1331 if (delta >= MSIM_KEEPALIVE_INTERVAL) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1332 errmsg = g_strdup_printf(_("Connection to server lost (no data received within %d seconds)"), (int)delta);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1333
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1334 purple_debug_info("msim", "msim_check_alive: %s > interval of %d, presumed dead\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1335 errmsg, MSIM_KEEPALIVE_INTERVAL);
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1336 purple_connection_error_reason(session->gc,
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
1337 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, errmsg);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1338
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1339 purple_notify_error(session->gc, NULL, errmsg, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1340
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1341 g_free(errmsg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1342
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1343 return FALSE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1344 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1345
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1346 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1347 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1348 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1349
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1350 /** Handle mail reply checks. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1351 static void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1352 msim_check_inbox_cb(MsimSession *session, MsimMessage *reply, gpointer data)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1353 {
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1354 MsimMessage *body;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1355 guint old_inbox_status;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1356 guint i, n;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1357 const gchar *froms[5], *tos[5], *urls[5], *subjects[5];
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1358
19430
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1359 /* Information for each new inbox message type. */
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1360 static struct
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1361 {
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1362 const gchar *key;
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1363 guint bit;
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1364 const gchar *url;
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1365 const gchar *text;
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1366 } message_types[] = {
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1367 { "Mail", MSIM_INBOX_MAIL, "http://messaging.myspace.com/index.cfm?fuseaction=mail.inbox", NULL },
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1368 { "BlogComment", MSIM_INBOX_BLOG_COMMENT, "http://blog.myspace.com/index.cfm?fuseaction=blog", NULL },
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1369 { "ProfileComment", MSIM_INBOX_PROFILE_COMMENT, "http://home.myspace.com/index.cfm?fuseaction=user", NULL },
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1370 { "FriendRequest", MSIM_INBOX_FRIEND_REQUEST, "http://messaging.myspace.com/index.cfm?fuseaction=mail.friendRequests", NULL },
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1371 { "PictureComment", MSIM_INBOX_PICTURE_COMMENT, "http://home.myspace.com/index.cfm?fuseaction=user", NULL }
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1372 };
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1373
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1374 /* Can't write _()'d strings in array initializers. Workaround. */
19430
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1375 message_types[0].text = _("New mail messages");
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1376 message_types[1].text = _("New blog comments");
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1377 message_types[2].text = _("New profile comments");
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1378 message_types[3].text = _("New friend requests!");
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1379 message_types[4].text = _("New picture comments");
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1380
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1381 g_return_if_fail(reply != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1382
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1383 msim_msg_dump("msim_check_inbox_cb: reply=%s\n", reply);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1384
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1385 body = msim_msg_get_dictionary(reply, "body");
21758
430827922828 Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents: 21709
diff changeset
1386
430827922828 Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents: 21709
diff changeset
1387 if (body == NULL)
430827922828 Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents: 21709
diff changeset
1388 return;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1389
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1390 old_inbox_status = session->inbox_status;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1391
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1392 n = 0;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1393
19430
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1394 for (i = 0; i < sizeof(message_types) / sizeof(message_types[0]); ++i) {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1395 const gchar *key;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1396 guint bit;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1397
19430
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1398 key = message_types[i].key;
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1399 bit = message_types[i].bit;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1400
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1401 if (msim_msg_get(body, key)) {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1402 /* Notify only on when _changes_ from no mail -> has mail
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1403 * (edge triggered) */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1404 if (!(session->inbox_status & bit)) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1405 purple_debug_info("msim", "msim_check_inbox_cb: got %s, at %d\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1406 key ? key : "(NULL)", n);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1407
19430
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1408 subjects[n] = message_types[i].text;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1409 froms[n] = _("MySpace");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1410 tos[n] = session->username;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1411 /* TODO: append token, web challenge, so automatically logs in.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1412 * Would also need to free strings because they won't be static
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1413 */
19430
0104035fd510 In msimprpl's mail notifications, change four parallel arrays into
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19429
diff changeset
1414 urls[n] = message_types[i].url;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1415
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1416 ++n;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1417 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1418 purple_debug_info("msim",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1419 "msim_check_inbox_cb: already notified of %s\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1420 key ? key : "(NULL)");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1421 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1422
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1423 session->inbox_status |= bit;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1424 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1425 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1426
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1427 if (n) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1428 purple_debug_info("msim",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1429 "msim_check_inbox_cb: notifying of %d\n", n);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1430
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1431 /* TODO: free strings with callback _if_ change to dynamic (w/ token) */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1432 purple_notify_emails(session->gc, /* handle */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1433 n, /* count */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1434 TRUE, /* detailed */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1435 subjects, froms, tos, urls,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1436 NULL, /* PurpleNotifyCloseCallback cb */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1437 NULL); /* gpointer user_data */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1438
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1439 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1440
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1441 msim_msg_free(body);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1442 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1443
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1444 /* Send request to check if there is new mail. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1445 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1446 msim_check_inbox(gpointer data)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1447 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1448 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1449
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1450 session = (MsimSession *)data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1451
21758
430827922828 Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents: 21709
diff changeset
1452 if (!MSIM_SESSION_VALID(session)) {
430827922828 Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents: 21709
diff changeset
1453 purple_debug_info("msim", "msim_check_inbox: session invalid, stopping the mail check.\n");
430827922828 Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents: 21709
diff changeset
1454 return FALSE;
430827922828 Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents: 21709
diff changeset
1455 }
430827922828 Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents: 21709
diff changeset
1456
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1457 purple_debug_info("msim", "msim_check_inbox: checking mail\n");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1458 g_return_val_if_fail(msim_send(session,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1459 "persist", MSIM_TYPE_INTEGER, 1,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1460 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1461 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_GET,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1462 "dsn", MSIM_TYPE_INTEGER, MG_CHECK_MAIL_DSN,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1463 "lid", MSIM_TYPE_INTEGER, MG_CHECK_MAIL_LID,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1464 "uid", MSIM_TYPE_INTEGER, session->userid,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1465 "rid", MSIM_TYPE_INTEGER,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1466 msim_new_reply_callback(session, msim_check_inbox_cb, NULL),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1467 "body", MSIM_TYPE_STRING, g_strdup(""),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1468 NULL), TRUE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1469
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1470 /* Always return true, so that we keep checking for mail. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1471 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1472 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1473
19598
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1474 #ifdef MSIM_CHECK_NEWER_VERSION
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1475 /** Callback for when a currentversion.txt has been downloaded. */
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1476 static void
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1477 msim_check_newer_version_cb(PurpleUtilFetchUrlData *url_data,
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1478 gpointer user_data,
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1479 const gchar *url_text,
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1480 gsize len,
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1481 const gchar *error_message)
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1482 {
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1483 GKeyFile *keyfile;
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1484 GError *error;
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1485 GString *data;
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1486 gchar *newest_filever;
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1487
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1488 if (!url_text) {
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1489 purple_debug_info("msim_check_newer_version_cb",
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1490 "got error: %s\n", error_message);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1491 return;
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1492 }
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1493
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1494 purple_debug_info("msim_check_newer_version_cb",
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1495 "url_text=%s\n", url_text ? url_text : "(NULL)");
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1496
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1497 /* Prepend [group] so that GKeyFile can parse it (requires a group). */
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1498 data = g_string_new(url_text);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1499 purple_debug_info("msim", "data=%s\n", data->str
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1500 ? data->str : "(NULL)");
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1501 data = g_string_prepend(data, "[group]\n");
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1502
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1503 purple_debug_info("msim", "data=%s\n", data->str
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1504 ? data->str : "(NULL)");
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1505
20982
aee8d876fed1 When getting info on a myspace user not on the buddy list, a temporary
Evan Schoenberg <evan.s@dreskin.net>
parents: 20861
diff changeset
1506 /* url_text is variable=data\n...†*/
19598
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1507
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1508 /* Check FILEVER, 1.0.716.0. 716 is build, MSIM_CLIENT_VERSION */
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1509 /* New (english) version can be downloaded from SETUPURL+SETUPFILE */
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1510
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1511 error = NULL;
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1512 keyfile = g_key_file_new();
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1513
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1514 /* Default list seperator is ;, but currentversion.txt doesn't have
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1515 * these, so set to an unused character to avoid parsing problems. */
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1516 g_key_file_set_list_separator(keyfile, '\0');
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1517
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1518 g_key_file_load_from_data(keyfile, data->str, data->len,
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1519 G_KEY_FILE_NONE, &error);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1520 g_string_free(data, TRUE);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1521
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1522 if (error != NULL) {
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1523 purple_debug_info("msim_check_newer_version_cb",
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1524 "couldn't parse, error: %d %d %s\n",
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1525 error->domain, error->code, error->message);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1526 g_error_free(error);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1527 return;
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1528 }
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1529
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1530 gchar **ks;
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1531 guint n;
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1532 ks = g_key_file_get_keys(keyfile, "group", &n, NULL);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1533 purple_debug_info("msim", "n=%d\n", n);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1534 guint i;
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1535 for (i = 0; ks[i] != NULL; ++i)
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1536 {
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1537 purple_debug_info("msim", "%d=%s\n", i, ks[i]);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1538 }
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1539
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1540 newest_filever = g_key_file_get_string(keyfile, "group",
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1541 "FILEVER", &error);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1542
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1543 purple_debug_info("msim_check_newer_version_cb",
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1544 "newest filever: %s\n", newest_filever ?
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1545 newest_filever : "(NULL)");
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1546 if (error != NULL) {
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1547 purple_debug_info("msim_check_newer_version_cb",
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1548 "error: %d %d %s\n",
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1549 error->domain, error->code, error->message);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1550 g_error_free(error);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1551 }
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1552
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1553 g_key_file_free(keyfile);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1554
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1555 exit(0);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1556 }
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1557 #endif
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
1558
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1559 /** Called when the session key arrives. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1560 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1561 msim_we_are_logged_on(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1562 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1563 MsimMessage *body;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1564
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1565 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1566 g_return_val_if_fail(msg != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1567
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1568 session->sesskey = msim_msg_get_integer(msg, "sesskey");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1569 purple_debug_info("msim", "SESSKEY=<%d>\n", session->sesskey);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1570
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1571 /* What is proof? Used to be uid, but now is 52 base64'd bytes... */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1572
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1573 /* Comes with: proof,profileid,userid,uniquenick -- all same values
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1574 * some of the time, but can vary. This is our own user ID. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1575 session->userid = msim_msg_get_integer(msg, "userid");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1576
19436
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
1577 /* Save uid to account so this account can be looked up by uid. */
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
1578 purple_account_set_int(session->account, "uid", session->userid);
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
1579
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1580 /* Not sure what profileid is used for. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1581 if (msim_msg_get_integer(msg, "profileid") != session->userid) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1582 msim_unrecognized(session, msg,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1583 "Profile ID didn't match user ID, don't know why");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1584 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1585
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1586 /* We now know are our own username, only after we're logged in..
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1587 * which is weird, but happens because you login with your email
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1588 * address and not username. Will be freed in msim_session_destroy(). */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1589 session->username = msim_msg_get_string(msg, "uniquenick");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1590
19890
39d620a93907 Use purple_connection_set_display_name() to set the display name to the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19629
diff changeset
1591 /* Set display name to username (otherwise will show email address) */
39d620a93907 Use purple_connection_set_display_name() to set the display name to the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19629
diff changeset
1592 purple_connection_set_display_name(session->gc, session->username);
19442
d7cd580c0753 In msimprpl: if no local alias is set, set it to the username on sign-on.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19441
diff changeset
1593
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1594 /* The session is now set up, ready to be connected. This emits the
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1595 * signedOn signal, so clients can now do anything with msimprpl, and
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1596 * we're ready for it (session key, userid, username all setup). */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1597 purple_connection_update_progress(session->gc, _("Connected"), 3, 4);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1598 purple_connection_set_state(session->gc, PURPLE_CONNECTED);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1599
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1600
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1601 /* Additional post-connect operations */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1602
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1603
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1604 if (msim_msg_get_integer(msg, "uniquenick") == session->userid) {
19653
941965d6fd88 Patch from QuLogic. Fixes #2903 ('Missing newlines in debug messages.')
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19637
diff changeset
1605 purple_debug_info("msim_we_are_logged_on", "TODO: pick username\n");
19629
9968fff36e20 If no username is set, point user to a web page where to set it, and disconnect.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19628
diff changeset
1606 /* No username is set. */
9968fff36e20 If no username is set, point user to a web page where to set it, and disconnect.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19628
diff changeset
1607 purple_notify_error(session->account,
9968fff36e20 If no username is set, point user to a web page where to set it, and disconnect.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19628
diff changeset
1608 _("No username set"),
9968fff36e20 If no username is set, point user to a web page where to set it, and disconnect.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19628
diff changeset
1609 _("Please go to http://editprofile.myspace.com/index.cfm?fuseaction=profile.username and choose a username and try to login again."), NULL);
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
1610 purple_connection_error_reason (session->gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
1611 PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("No username set"));
19629
9968fff36e20 If no username is set, point user to a web page where to set it, and disconnect.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19628
diff changeset
1612 return FALSE;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1613 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1614
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1615 body = msim_msg_new(
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1616 "UserID", MSIM_TYPE_INTEGER, session->userid,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1617 NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1618
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1619 /* Request IM info about ourself. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1620 msim_send(session,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1621 "persist", MSIM_TYPE_STRING, g_strdup("persist"),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1622 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1623 "dsn", MSIM_TYPE_INTEGER, MG_OWN_MYSPACE_INFO_DSN,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1624 "uid", MSIM_TYPE_INTEGER, session->userid,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1625 "lid", MSIM_TYPE_INTEGER, MG_OWN_MYSPACE_INFO_LID,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1626 "rid", MSIM_TYPE_INTEGER, session->next_rid++,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1627 "body", MSIM_TYPE_DICTIONARY, body,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1628 NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1629
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1630 /* Request MySpace info about ourself. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1631 msim_send(session,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1632 "persist", MSIM_TYPE_STRING, g_strdup("persist"),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1633 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1634 "dsn", MSIM_TYPE_INTEGER, MG_OWN_IM_INFO_DSN,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1635 "uid", MSIM_TYPE_INTEGER, session->userid,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1636 "lid", MSIM_TYPE_INTEGER, MG_OWN_IM_INFO_LID,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1637 "rid", MSIM_TYPE_INTEGER, session->next_rid++,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1638 "body", MSIM_TYPE_STRING, g_strdup(""),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1639 NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1640
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1641 /* TODO: set options (persist cmd=514,dsn=1,lid=10) */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1642 /* TODO: set blocklist */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1643
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1644 /* Notify servers of our current status. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1645 purple_debug_info("msim", "msim_we_are_logged_on: notifying servers of status\n");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1646 msim_set_status(session->account,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1647 purple_account_get_active_status(session->account));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1648
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1649 /* TODO: setinfo */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1650 /*
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1651 body = msim_msg_new(
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1652 "TotalFriends", MSIM_TYPE_INTEGER, 666,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1653 NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1654 msim_send(session,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1655 "setinfo", MSIM_TYPE_BOOLEAN, TRUE,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1656 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1657 "info", MSIM_TYPE_DICTIONARY, body,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1658 NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1659 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1660
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1661 /* Disable due to problems with timeouts. TODO: fix. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1662 #ifdef MSIM_USE_KEEPALIVE
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1663 purple_timeout_add(MSIM_KEEPALIVE_INTERVAL_CHECK,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1664 (GSourceFunc)msim_check_alive, session);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1665 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1666
19462
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
1667 /* Check mail if they want to. */
19437
a8c9c42c3572 Only check for mail if "New mail notifications" is enabled in account options.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19436
diff changeset
1668 if (purple_account_get_check_mail(session->account)) {
21758
430827922828 Avoid checking for new message in the inbox when not actually connected.
Kevin Stange <kevin@simguy.net>
parents: 21709
diff changeset
1669 session->inbox_handle = purple_timeout_add(MSIM_MAIL_INTERVAL_CHECK,
19437
a8c9c42c3572 Only check for mail if "New mail notifications" is enabled in account options.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19436
diff changeset
1670 (GSourceFunc)msim_check_inbox, session);
a8c9c42c3572 Only check for mail if "New mail notifications" is enabled in account options.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19436
diff changeset
1671 msim_check_inbox(session);
a8c9c42c3572 Only check for mail if "New mail notifications" is enabled in account options.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19436
diff changeset
1672 }
a8c9c42c3572 Only check for mail if "New mail notifications" is enabled in account options.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19436
diff changeset
1673
19462
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
1674 msim_get_contact_list(session, MSIM_CONTACT_LIST_INITIAL_FRIENDS);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1675
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1676 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1677 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1678
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1679 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1680 * Process a message.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1681 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1682 * @param session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1683 * @param msg A message from the server, ready for processing (possibly with resolved username information attached). Caller frees.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1684 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1685 * @return TRUE if successful. FALSE if processing failed.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1686 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1687 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1688 msim_process(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1689 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1690 g_return_val_if_fail(session != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1691 g_return_val_if_fail(msg != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1692
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1693 #ifdef MSIM_DEBUG_MSG
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1694 msim_msg_dump("ready to process: %s\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1695 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1696
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1697 if (msim_msg_get_integer(msg, "lc") == 1) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1698 return msim_login_challenge(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1699 } else if (msim_msg_get_integer(msg, "lc") == 2) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1700 return msim_we_are_logged_on(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1701 } else if (msim_msg_get(msg, "bm")) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1702 return msim_incoming_bm(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1703 } else if (msim_msg_get(msg, "rid")) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1704 return msim_process_reply(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1705 } else if (msim_msg_get(msg, "error")) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1706 return msim_error(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1707 } else if (msim_msg_get(msg, "ka")) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1708 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1709 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1710 msim_unrecognized(session, msg, "in msim_process");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1711 return FALSE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1712 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1713 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1714
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1715 /** Process the initial server information from the server. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1716 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1717 msim_process_server_info(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1718 {
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1719 MsimMessage *body;
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1720
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1721 body = msim_msg_get_dictionary(msg, "body");
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1722 g_return_val_if_fail(body != NULL, FALSE);
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1723
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1724 /* Example body:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1725 AdUnitRefreshInterval=10.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1726 AlertPollInterval=360.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1727 AllowChatRoomEmoticonSharing=False.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1728 ChatRoomUserIDs=78744676;163733130;1300326231;123521495;142663391.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1729 CurClientVersion=673.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1730 EnableIMBrowse=True.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1731 EnableIMStuffAvatars=False.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1732 EnableIMStuffZaps=False.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1733 MaxAddAllFriends=100.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1734 MaxContacts=1000.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1735 MinClientVersion=594.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1736 MySpaceIM_ENGLISH=78744676.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1737 MySpaceNowTimer=720.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1738 PersistenceDataTimeout=900.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1739 UseWebChallenge=1.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1740 WebTicketGoHome=False
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1741
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1742 Anything useful? TODO: use what is useful, and use it.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1743 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1744 purple_debug_info("msim_process_server_info",
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1745 "maximum contacts: %d\n",
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
1746 msim_msg_get_integer(body, "MaxContacts"));
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1747
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1748 session->server_info = body;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1749 /* session->server_info freed in msim_session_destroy */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1750
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1751 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1752 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1753
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1754 /** Process a web challenge, used to login to the web site. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1755 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1756 msim_web_challenge(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1757 {
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1758 /* TODO: web challenge, store token. #2659. */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1759 return FALSE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1760 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1761
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1762 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1763 * Process a persistance message reply from the server.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1764 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1765 * @param session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1766 * @param msg Message reply from server.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1767 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1768 * @return TRUE if successful.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1769 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1770 * msim_lookup_user sets callback for here
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1771 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1772 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1773 msim_process_reply(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1774 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1775 MSIM_USER_LOOKUP_CB cb;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1776 gpointer data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1777 guint rid, cmd, dsn, lid;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1778
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1779 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1780 g_return_val_if_fail(msg != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1781
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1782 msim_store_user_info(session, msg, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1783
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1784 rid = msim_msg_get_integer(msg, "rid");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1785 cmd = msim_msg_get_integer(msg, "cmd");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1786 dsn = msim_msg_get_integer(msg, "dsn");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1787 lid = msim_msg_get_integer(msg, "lid");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1788
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1789 /* Unsolicited messages */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1790 if (cmd == (MSIM_CMD_BIT_REPLY | MSIM_CMD_GET)) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1791 if (dsn == MG_SERVER_INFO_DSN && lid == MG_SERVER_INFO_LID) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1792 return msim_process_server_info(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1793 } else if (dsn == MG_WEB_CHALLENGE_DSN && lid == MG_WEB_CHALLENGE_LID) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1794 return msim_web_challenge(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1795 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1796 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1797
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1798 /* If a callback is registered for this userid lookup, call it. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1799 cb = g_hash_table_lookup(session->user_lookup_cb, GUINT_TO_POINTER(rid));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1800 data = g_hash_table_lookup(session->user_lookup_cb_data, GUINT_TO_POINTER(rid));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1801
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1802 if (cb) {
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
1803 purple_debug_info("msim", "msim_process_reply: calling callback now\n");
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
1804 msim_msg_dump("for msg=%s\n", msg);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1805 /* Clone message, so that the callback 'cb' can use it (needs to free it also). */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1806 cb(session, msim_msg_clone(msg), data);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1807 g_hash_table_remove(session->user_lookup_cb, GUINT_TO_POINTER(rid));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1808 g_hash_table_remove(session->user_lookup_cb_data, GUINT_TO_POINTER(rid));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1809 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1810 purple_debug_info("msim",
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
1811 "msim_process_reply: no callback for rid %d\n", rid);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1812 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1813
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1814 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1815 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1816
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1817 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1818 * Handle an error from the server.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1819 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1820 * @param session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1821 * @param msg The message.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1822 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1823 * @return TRUE if successfully reported error.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1824 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1825 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1826 msim_error(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1827 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1828 gchar *errmsg, *full_errmsg;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1829 guint err;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1830
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1831 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1832 g_return_val_if_fail(msg != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1833
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1834 err = msim_msg_get_integer(msg, "err");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1835 errmsg = msim_msg_get_string(msg, "errmsg");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1836
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1837 full_errmsg = g_strdup_printf(_("Protocol error, code %d: %s"), err,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1838 errmsg ? errmsg : "no 'errmsg' given");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1839
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1840 g_free(errmsg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1841
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1842 purple_debug_info("msim", "msim_error (sesskey=%d): %s\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1843 session->sesskey, full_errmsg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1844
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1845 /* Destroy session if fatal. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1846 if (msim_msg_get(msg, "fatal")) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
1847 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1848 purple_debug_info("msim", "fatal error, closing\n");
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1849
20590
a2cb2a2fe424 Clear the password consistently when we get a "Signed-On elsewhere" or a "Invalid Password" disconnection. Disconnection reason codes will take care of this in the core, but until then, this is ok.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20580
diff changeset
1850 switch (err) {
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1851 case MSIM_ERROR_INCORRECT_PASSWORD: /* Incorrect password */
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
1852 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
20776
f3cfcbbac3d8 propagate from branch 'im.pidgin.pidgin' (head 294731552d0baf5f1f37a45e0c119b2188f34ba8)
Will Thompson <will.thompson@collabora.co.uk>
parents: 20753 20121
diff changeset
1853 if (!purple_account_get_remember_password(session->account))
f3cfcbbac3d8 propagate from branch 'im.pidgin.pidgin' (head 294731552d0baf5f1f37a45e0c119b2188f34ba8)
Will Thompson <will.thompson@collabora.co.uk>
parents: 20753 20121
diff changeset
1854 purple_account_set_password(session->account, NULL);
f3cfcbbac3d8 propagate from branch 'im.pidgin.pidgin' (head 294731552d0baf5f1f37a45e0c119b2188f34ba8)
Will Thompson <will.thompson@collabora.co.uk>
parents: 20753 20121
diff changeset
1855 break;
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1856 case MSIM_ERROR_LOGGED_IN_ELSEWHERE: /* Logged in elsewhere */
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
1857 reason = PURPLE_CONNECTION_ERROR_NAME_IN_USE;
20590
a2cb2a2fe424 Clear the password consistently when we get a "Signed-On elsewhere" or a "Invalid Password" disconnection. Disconnection reason codes will take care of this in the core, but until then, this is ok.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20580
diff changeset
1858 if (!purple_account_get_remember_password(session->account))
a2cb2a2fe424 Clear the password consistently when we get a "Signed-On elsewhere" or a "Invalid Password" disconnection. Disconnection reason codes will take care of this in the core, but until then, this is ok.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20580
diff changeset
1859 purple_account_set_password(session->account, NULL);
a2cb2a2fe424 Clear the password consistently when we get a "Signed-On elsewhere" or a "Invalid Password" disconnection. Disconnection reason codes will take care of this in the core, but until then, this is ok.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20580
diff changeset
1860 break;
19637
5ee8869b5130 Ka-Hing reminded me that we should set the password to NULL when
Mark Doliner <mark@kingant.net>
parents: 19636
diff changeset
1861 }
20121
e4bcdd9622c2 purple_connection_error_reason-ify myspace
Will Thompson <will.thompson@collabora.co.uk>
parents: 20057
diff changeset
1862 purple_connection_error_reason (session->gc, reason, full_errmsg);
19636
e6548df6262e Three small changes:
Mark Doliner <mark@kingant.net>
parents: 19627
diff changeset
1863 } else {
20753
61045691aa72 Fix a few more memory leaks. Someone who has a myspace account should stare
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20685
diff changeset
1864 purple_notify_error(session->account, _("MySpaceIM Error"), full_errmsg, NULL);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1865 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1866
19636
e6548df6262e Three small changes:
Mark Doliner <mark@kingant.net>
parents: 19627
diff changeset
1867 g_free(full_errmsg);
e6548df6262e Three small changes:
Mark Doliner <mark@kingant.net>
parents: 19627
diff changeset
1868
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1869 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1870 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1871
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1872 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1873 * Process incoming status messages.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1874 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1875 * @param session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1876 * @param msg Status update message. Caller frees.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1877 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1878 * @return TRUE if successful.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1879 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1880 static gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1881 msim_incoming_status(MsimSession *session, MsimMessage *msg)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1882 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1883 PurpleBuddyList *blist;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1884 MsimUser *user;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1885 GList *list;
19592
d6802883e96e Treat status messages as the plaintext that they are.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19570
diff changeset
1886 gchar *status_headline, *status_headline_escaped;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1887 gint status_code, purple_status_code;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1888 gchar *username;
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1889 gchar *unrecognized_msg;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1890
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1891 g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1892 g_return_val_if_fail(msg != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1893
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1894 msim_msg_dump("msim_status msg=%s\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1895
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1896 /* Helpfully looked up by msim_incoming_resolve() for us. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1897 username = msim_msg_get_string(msg, "_username");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1898 g_return_val_if_fail(username != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1899
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1900 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1901 gchar *ss;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1902
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1903 ss = msim_msg_get_string(msg, "msg");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1904 purple_debug_info("msim",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1905 "msim_status: updating status for <%s> to <%s>\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1906 username, ss ? ss : "(NULL)");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1907 g_free(ss);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1908 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1909
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1910 /* Example fields:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1911 * |s|0|ss|Offline
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1912 * |s|1|ss|:-)|ls||ip|0|p|0
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1913 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1914 list = msim_msg_get_list(msg, "msg");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1915
19431
3b7539c7402e Now that MsimMessageElement's are more accessible outside message.c,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19430
diff changeset
1916 status_code = msim_msg_get_integer_from_element(g_list_nth_data(list, MSIM_STATUS_ORDINAL_ONLINE));
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1917 purple_debug_info("msim", "msim_status: %s's status code = %d\n", username, status_code);
19431
3b7539c7402e Now that MsimMessageElement's are more accessible outside message.c,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19430
diff changeset
1918 status_headline = msim_msg_get_string_from_element(g_list_nth_data(list, MSIM_STATUS_ORDINAL_HEADLINE));
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1919
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1920 blist = purple_get_blist();
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1921
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1922 /* Add buddy if not found.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1923 * TODO: Could this be responsible for #3444? */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1924 user = msim_find_user(session, username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1925 if (!user) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1926 PurpleBuddy *buddy;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1927
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1928 purple_debug_info("msim",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1929 "msim_status: making new buddy for %s\n", username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1930 buddy = purple_buddy_new(session->account, username, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1931 purple_blist_add_buddy(buddy, NULL, NULL, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1932
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1933 user = msim_get_user_from_buddy(buddy);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1934
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1935 /* All buddies on list should have a UserID integer associated with them. */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1936 purple_blist_node_set_int(&buddy->node, "UserID", msim_msg_get_integer(msg, "f"));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1937
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1938 msim_store_user_info(session, msg, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1939 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1940 purple_debug_info("msim", "msim_status: found buddy %s\n", username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1941 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1942
21707
9ef51d894456 This fixes some idle-related behavior with the MySpace prpl, most particularly
Kevin Stange <kevin@simguy.net>
parents: 21418
diff changeset
1943 if (status_headline && strcmp(status_headline, "") != 0) {
19628
4c5e7db85e29 For status messages, make sure NULL isn't passed to g_markup_escape_text().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19627
diff changeset
1944 /* The status headline is plaintext, but libpurple treats it as HTML,
4c5e7db85e29 For status messages, make sure NULL isn't passed to g_markup_escape_text().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19627
diff changeset
1945 * so escape any HTML characters to their entity equivalents. */
4c5e7db85e29 For status messages, make sure NULL isn't passed to g_markup_escape_text().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19627
diff changeset
1946 status_headline_escaped = g_markup_escape_text(status_headline, strlen(status_headline));
4c5e7db85e29 For status messages, make sure NULL isn't passed to g_markup_escape_text().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19627
diff changeset
1947 } else {
4c5e7db85e29 For status messages, make sure NULL isn't passed to g_markup_escape_text().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19627
diff changeset
1948 status_headline_escaped = NULL;
4c5e7db85e29 For status messages, make sure NULL isn't passed to g_markup_escape_text().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19627
diff changeset
1949 }
4c5e7db85e29 For status messages, make sure NULL isn't passed to g_markup_escape_text().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19627
diff changeset
1950
19592
d6802883e96e Treat status messages as the plaintext that they are.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19570
diff changeset
1951 g_free(status_headline);
d6802883e96e Treat status messages as the plaintext that they are.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19570
diff changeset
1952
d6802883e96e Treat status messages as the plaintext that they are.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19570
diff changeset
1953 if (user->headline)
d6802883e96e Treat status messages as the plaintext that they are.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19570
diff changeset
1954 g_free(user->headline);
d6802883e96e Treat status messages as the plaintext that they are.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19570
diff changeset
1955
19431
3b7539c7402e Now that MsimMessageElement's are more accessible outside message.c,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19430
diff changeset
1956 /* don't copy; let the MsimUser own the headline, memory-wise */
19592
d6802883e96e Treat status messages as the plaintext that they are.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19570
diff changeset
1957 user->headline = status_headline_escaped;
22160
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
1958
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1959 /* Set user status */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1960 switch (status_code) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1961 case MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1962 purple_status_code = PURPLE_STATUS_OFFLINE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1963 break;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1964
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1965 case MSIM_STATUS_CODE_ONLINE:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1966 purple_status_code = PURPLE_STATUS_AVAILABLE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1967 break;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1968
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1969 case MSIM_STATUS_CODE_AWAY:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1970 purple_status_code = PURPLE_STATUS_AWAY;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1971 break;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1972
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1973 case MSIM_STATUS_CODE_IDLE:
21759
41489d141def This makes myspace treat idle as an available status, which avoids idle
Kevin Stange <kevin@simguy.net>
parents: 21758
diff changeset
1974 /* Treat idle as an available status. */
41489d141def This makes myspace treat idle as an available status, which avoids idle
Kevin Stange <kevin@simguy.net>
parents: 21758
diff changeset
1975 purple_status_code = PURPLE_STATUS_AVAILABLE;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1976 break;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1977
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1978 default:
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1979 purple_debug_info("msim", "msim_incoming_status for %s, unknown status code %d, treating as available\n",
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1980 username, status_code);
19429
5e2a2fc55631 Lookup a user's information when their status changes to anything but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19428
diff changeset
1981 purple_status_code = PURPLE_STATUS_AVAILABLE;
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1982
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1983 unrecognized_msg = g_strdup_printf("msim_incoming_status, unrecognized status code: %d\n",
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1984 status_code);
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1985 msim_unrecognized(session, NULL, unrecognized_msg);
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1986 g_free(unrecognized_msg);
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
1987
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1988 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1989
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1990 purple_prpl_got_user_status(session->account, username, purple_primitive_get_id_from_type(purple_status_code), NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1991
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1992 if (status_code == MSIM_STATUS_CODE_IDLE) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1993 purple_debug_info("msim", "msim_status: got idle: %s\n", username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1994 purple_prpl_got_user_idle(session->account, username, TRUE, time(NULL));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1995 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1996 /* All other statuses indicate going back to non-idle. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1997 purple_prpl_got_user_idle(session->account, username, FALSE, time(NULL));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1998 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
1999
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2000 #ifdef MSIM_SEND_CLIENT_VERSION
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2001 if (status_code == MSIM_STATUS_CODE_ONLINE) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2002 /* Secretly whisper to unofficial clients our own version as they come online */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2003 msim_send_unofficial_client(session, username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2004 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2005 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2006
19429
5e2a2fc55631 Lookup a user's information when their status changes to anything but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19428
diff changeset
2007 if (status_code != MSIM_STATUS_CODE_OFFLINE_OR_HIDDEN) {
5e2a2fc55631 Lookup a user's information when their status changes to anything but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19428
diff changeset
2008 /* Get information when they come online.
5e2a2fc55631 Lookup a user's information when their status changes to anything but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19428
diff changeset
2009 * TODO: periodically refresh?
5e2a2fc55631 Lookup a user's information when their status changes to anything but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19428
diff changeset
2010 */
5e2a2fc55631 Lookup a user's information when their status changes to anything but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19428
diff changeset
2011 purple_debug_info("msim_incoming_status", "%s came online, looking up\n", username);
5e2a2fc55631 Lookup a user's information when their status changes to anything but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19428
diff changeset
2012 msim_lookup_user(session, username, NULL, NULL);
5e2a2fc55631 Lookup a user's information when their status changes to anything but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19428
diff changeset
2013 }
5e2a2fc55631 Lookup a user's information when their status changes to anything but
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19428
diff changeset
2014
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2015 g_free(username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2016 msim_msg_list_free(list);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2017
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2018 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2019 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2020
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2021 /** Add a buddy to user's buddy list. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2022 void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2023 msim_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2024 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2025 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2026 MsimMessage *msg;
19597
1b22d4c6fe47 Add uid field to add buddy persistance request. Now adding buddies to the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19594
diff changeset
2027 MsimMessage *msg_persist;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2028 MsimMessage *body;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2029
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2030 session = (MsimSession *)gc->proto_data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2031 purple_debug_info("msim", "msim_add_buddy: want to add %s to %s\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2032 buddy->name, (group && group->name) ? group->name : "(no group)");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2033
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2034 msg = msim_msg_new(
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2035 "addbuddy", MSIM_TYPE_BOOLEAN, TRUE,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2036 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2037 /* "newprofileid" will be inserted here with uid. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2038 "reason", MSIM_TYPE_STRING, g_strdup(""),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2039 NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2040
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2041 if (!msim_postprocess_outgoing(session, msg, buddy->name, "newprofileid", "reason")) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2042 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("'addbuddy' command failed."));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2043 msim_msg_free(msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2044 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2045 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2046 msim_msg_free(msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2047
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2048 /* TODO: if addbuddy fails ('error' message is returned), delete added buddy from
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2049 * buddy list since Purple adds it locally. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2050
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2051 body = msim_msg_new(
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2052 "ContactID", MSIM_TYPE_STRING, g_strdup("<uid>"),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2053 "GroupName", MSIM_TYPE_STRING, g_strdup(group->name),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2054 "Position", MSIM_TYPE_INTEGER, 1000,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2055 "Visibility", MSIM_TYPE_INTEGER, 1,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2056 "NickName", MSIM_TYPE_STRING, g_strdup(""),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2057 "NameSelect", MSIM_TYPE_INTEGER, 0,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2058 NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2059
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2060 /* TODO: Update blocklist. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2061
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2062 msg_persist = msim_msg_new(
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2063 "persist", MSIM_TYPE_INTEGER, 1,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2064 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2065 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_PUT,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2066 "dsn", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_DSN,
19597
1b22d4c6fe47 Add uid field to add buddy persistance request. Now adding buddies to the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19594
diff changeset
2067 "uid", MSIM_TYPE_INTEGER, session->userid,
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2068 "lid", MSIM_TYPE_INTEGER, MC_CONTACT_INFO_LID,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2069 /* TODO: Use msim_new_reply_callback to get rid. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2070 "rid", MSIM_TYPE_INTEGER, session->next_rid++,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2071 "body", MSIM_TYPE_DICTIONARY, body,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2072 NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2073
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2074 if (!msim_postprocess_outgoing(session, msg_persist, buddy->name, "body", NULL))
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2075 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2076 purple_notify_error(NULL, NULL, _("Failed to add buddy"), _("persist command failed"));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2077 msim_msg_free(msg_persist);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2078 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2079 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2080 msim_msg_free(msg_persist);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2081
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2082 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2083
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2084 /** Perform actual postprocessing on a message, adding userid as specified.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2085 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2086 * @param msg The message to postprocess.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2087 * @param uid_before Name of field where to insert new field before, or NULL for end.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2088 * @param uid_field_name Name of field to add uid to.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2089 * @param uid The userid to insert.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2090 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2091 * If the field named by uid_field_name already exists, then its string contents will
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2092 * be used for the field, except "<uid>" will be replaced by the userid.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2093 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2094 * If the field named by uid_field_name does not exist, it will be added before the
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2095 * field named by uid_before, as an integer, with the userid.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2096 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2097 * Does not handle sending, or scheduling userid lookup. For that, see msim_postprocess_outgoing().
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2098 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2099 static MsimMessage *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2100 msim_do_postprocessing(MsimMessage *msg, const gchar *uid_before,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2101 const gchar *uid_field_name, guint uid)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2102 {
20861
9c2ec10933b2 Fix CID 342 (which wasn't wrong, but was inefficient and confusing.)
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20753
diff changeset
2103 MsimMessageElement *elem;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2104 msim_msg_dump("msim_do_postprocessing msg: %s\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2105
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2106 /* First, check - if the field already exists, replace <uid> within it */
20861
9c2ec10933b2 Fix CID 342 (which wasn't wrong, but was inefficient and confusing.)
Daniel Atallah <daniel.atallah@gmail.com>
parents: 20753
diff changeset
2107 if ((elem = msim_msg_get(msg, uid_field_name)) != NULL) {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2108 gchar *fmt_string;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2109 gchar *uid_str, *new_str;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2110
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2111 /* Get the packed element, flattening it. This allows <uid> to be
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2112 * replaced within nested data structures, since the replacement is done
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2113 * on the linear, packed data, not on a complicated data structure.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2114 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2115 * For example, if the field was originally a dictionary or a list, you
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2116 * would have to iterate over all the items in it to see what needs to
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2117 * be replaced. But by packing it first, the <uid> marker is easily replaced
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2118 * just by a string replacement.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2119 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2120 fmt_string = msim_msg_pack_element_data(elem);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2121
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2122 uid_str = g_strdup_printf("%d", uid);
19466
11c727b19201 Replace homegrown str_replace() with purple_strreplace(), after discovering it.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19462
diff changeset
2123 new_str = purple_strreplace(fmt_string, "<uid>", uid_str);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2124 g_free(uid_str);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2125 g_free(fmt_string);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2126
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2127 /* Free the old element data */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2128 msim_msg_free_element_data(elem->data);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2129
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2130 /* Replace it with our new data */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2131 elem->data = new_str;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2132 elem->type = MSIM_TYPE_RAW;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2133
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2134 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2135 /* Otherwise, insert new field into outgoing message. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2136 msg = msim_msg_insert_before(msg, uid_before, uid_field_name, MSIM_TYPE_INTEGER, GUINT_TO_POINTER(uid));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2137 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2138
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2139 msim_msg_dump("msim_postprocess_outgoing_cb: postprocessed msg=%s\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2140
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2141 return msg;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2142 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2143
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2144 /** Callback for msim_postprocess_outgoing() to add a userid to a message, and send it (once receiving userid).
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2145 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2146 * @param session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2147 * @param userinfo The user information reply message, containing the user ID
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2148 * @param data The message to postprocess and send.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2149 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2150 * The data message should contain these fields:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2151 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2152 * _uid_field_name: string, name of field to add with userid from userinfo message
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2153 * _uid_before: string, name of field before field to insert, or NULL for end
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2154 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2155 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2156 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2157 static void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2158 msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2159 gpointer data)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2160 {
19350
8839775bad3e If a username cannot be looked up in postprocessing, throw up an error.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19256
diff changeset
2161 gchar *uid_field_name, *uid_before, *username;
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
2162 guint uid;
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
2163 MsimMessage *msg, *body;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2164
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2165 msg = (MsimMessage *)data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2166
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2167 msim_msg_dump("msim_postprocess_outgoing_cb() got msg=%s\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2168
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2169 /* Obtain userid from userinfo message. */
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
2170 body = msim_msg_get_dictionary(userinfo, "body");
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
2171 g_return_if_fail(body != NULL);
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
2172
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
2173 uid = msim_msg_get_integer(body, "UserID");
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
2174 msim_msg_free(body);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2175
19350
8839775bad3e If a username cannot be looked up in postprocessing, throw up an error.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19256
diff changeset
2176 username = msim_msg_get_string(msg, "_username");
8839775bad3e If a username cannot be looked up in postprocessing, throw up an error.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19256
diff changeset
2177
8839775bad3e If a username cannot be looked up in postprocessing, throw up an error.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19256
diff changeset
2178 if (!uid) {
8839775bad3e If a username cannot be looked up in postprocessing, throw up an error.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19256
diff changeset
2179 gchar *msg;
8839775bad3e If a username cannot be looked up in postprocessing, throw up an error.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19256
diff changeset
2180
8839775bad3e If a username cannot be looked up in postprocessing, throw up an error.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19256
diff changeset
2181 msg = g_strdup_printf(_("No such user: %s"), username);
22160
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
2182 if (!purple_conv_present_error(username, session->account, msg)) {
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
2183 purple_notify_error(NULL, NULL, _("User lookup"), msg);
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
2184 }
22157
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22156
diff changeset
2185
19350
8839775bad3e If a username cannot be looked up in postprocessing, throw up an error.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19256
diff changeset
2186 g_free(msg);
8839775bad3e If a username cannot be looked up in postprocessing, throw up an error.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19256
diff changeset
2187 g_free(username);
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2188 /* TODO: free
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2189 * msim_msg_free(msg);
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2190 */
19350
8839775bad3e If a username cannot be looked up in postprocessing, throw up an error.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19256
diff changeset
2191 return;
8839775bad3e If a username cannot be looked up in postprocessing, throw up an error.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19256
diff changeset
2192 }
8839775bad3e If a username cannot be looked up in postprocessing, throw up an error.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19256
diff changeset
2193
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2194 uid_field_name = msim_msg_get_string(msg, "_uid_field_name");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2195 uid_before = msim_msg_get_string(msg, "_uid_before");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2196
19251
78558930d9f3 Replace msim_parse_body(), which returns a GHashTable * and takes a gchar *,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19249
diff changeset
2197 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, uid);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2198
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2199 /* Send */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2200 if (!msim_msg_send(session, msg)) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2201 msim_msg_dump("msim_postprocess_outgoing_cb: sending failed for message: %s\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2202 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2203
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2204
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2205 /* Free field names AFTER sending message, because MsimMessage does NOT copy
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2206 * field names - instead, treats them as static strings (which they usually are).
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2207 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2208 g_free(uid_field_name);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2209 g_free(uid_before);
19350
8839775bad3e If a username cannot be looked up in postprocessing, throw up an error.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19256
diff changeset
2210 g_free(username);
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2211 /* TODO: free
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2212 * msim_msg_free(msg);
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2213 */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2214 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2215
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2216 /** Postprocess and send a message.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2217 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2218 * @param session
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2219 * @param msg Message to postprocess. Will NOT be freed.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2220 * @param username Username to resolve. Assumed to be a static string (will not be freed or copied).
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2221 * @param uid_field_name Name of new field to add, containing uid of username. Static string.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2222 * @param uid_before Name of existing field to insert username field before. Static string.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2223 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2224 * @return TRUE if successful.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2225 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2226 gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2227 msim_postprocess_outgoing(MsimSession *session, MsimMessage *msg,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2228 const gchar *username, const gchar *uid_field_name,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2229 const gchar *uid_before)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2230 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2231 PurpleBuddy *buddy;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2232 guint uid;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2233 gboolean rc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2234
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2235 g_return_val_if_fail(msg != NULL, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2236
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2237 /* Store information for msim_postprocess_outgoing_cb(). */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2238 msim_msg_dump("msim_postprocess_outgoing: msg before=%s\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2239 msg = msim_msg_append(msg, "_username", MSIM_TYPE_STRING, g_strdup(username));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2240 msg = msim_msg_append(msg, "_uid_field_name", MSIM_TYPE_STRING, g_strdup(uid_field_name));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2241 msg = msim_msg_append(msg, "_uid_before", MSIM_TYPE_STRING, g_strdup(uid_before));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2243 /* First, try the most obvious. If numeric userid is given, use that directly. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2244 if (msim_is_userid(username)) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2245 uid = atol(username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2246 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2247 /* Next, see if on buddy list and know uid. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2248 buddy = purple_find_buddy(session->account, username);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2249 if (buddy) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2250 uid = purple_blist_node_get_int(&buddy->node, "UserID");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2251 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2252 uid = 0;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2253 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2254
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2255 if (!buddy || !uid) {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2256 /* Don't have uid offhand - need to ask for it, and wait until hear back before sending. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2257 purple_debug_info("msim", ">>> msim_postprocess_outgoing: couldn't find username %s in blist\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2258 username ? username : "(NULL)");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2259 msim_msg_dump("msim_postprocess_outgoing - scheduling lookup, msg=%s\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2260 /* TODO: where is cloned message freed? Should be in _cb. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2261 msim_lookup_user(session, username, msim_postprocess_outgoing_cb, msim_msg_clone(msg));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2262 return TRUE; /* not sure of status yet - haven't sent! */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2263 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2264 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2265
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2266 /* Already have uid, postprocess and send msg immediately. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2267 purple_debug_info("msim", "msim_postprocess_outgoing: found username %s has uid %d\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2268 username ? username : "(NULL)", uid);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2269
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2270 msg = msim_do_postprocessing(msg, uid_before, uid_field_name, uid);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2271
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2272 msim_msg_dump("msim_postprocess_outgoing: msg after (uid immediate)=%s\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2273
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2274 rc = msim_msg_send(session, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2275
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2276 /* TODO: free
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2277 * msim_msg_free(msg);
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2278 */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2279
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2280 return rc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2281 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2282
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2283 /** Remove a buddy from the user's buddy list. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2284 void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2285 msim_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2286 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2287 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2288 MsimMessage *delbuddy_msg;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2289 MsimMessage *persist_msg;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2290 MsimMessage *blocklist_msg;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2291 GList *blocklist_updates;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2292
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2293 session = (MsimSession *)gc->proto_data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2294
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2295 delbuddy_msg = msim_msg_new(
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2296 "delbuddy", MSIM_TYPE_BOOLEAN, TRUE,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2297 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2298 /* 'delprofileid' with uid will be inserted here. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2299 NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2300
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2301 if (!msim_postprocess_outgoing(session, delbuddy_msg, buddy->name, "delprofileid", NULL)) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2302 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("'delbuddy' command failed"));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2303 msim_msg_free(delbuddy_msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2304 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2305 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2306 msim_msg_free(delbuddy_msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2307
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2308 persist_msg = msim_msg_new(
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2309 "persist", MSIM_TYPE_INTEGER, 1,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2310 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2311 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_BIT_ACTION | MSIM_CMD_DELETE,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2312 "dsn", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_DSN,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2313 "lid", MSIM_TYPE_INTEGER, MD_DELETE_BUDDY_LID,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2314 "uid", MSIM_TYPE_INTEGER, session->userid,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2315 "rid", MSIM_TYPE_INTEGER, session->next_rid++,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2316 /* <uid> will be replaced by postprocessing */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2317 "body", MSIM_TYPE_STRING, g_strdup("ContactID=<uid>"),
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2318 NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2319
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2320 if (!msim_postprocess_outgoing(session, persist_msg, buddy->name, "body", NULL)) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2321 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("persist command failed"));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2322 msim_msg_free(persist_msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2323 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2324 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2325 msim_msg_free(persist_msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2326
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2327 blocklist_updates = NULL;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2328 blocklist_updates = g_list_prepend(blocklist_updates, "a-");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2329 blocklist_updates = g_list_prepend(blocklist_updates, "<uid>");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2330 blocklist_updates = g_list_prepend(blocklist_updates, "b-");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2331 blocklist_updates = g_list_prepend(blocklist_updates, "<uid>");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2332 blocklist_updates = g_list_reverse(blocklist_updates);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2333
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2334 blocklist_msg = msim_msg_new(
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2335 "blocklist", MSIM_TYPE_BOOLEAN, TRUE,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2336 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2337 /* TODO: MsimMessage lists. Currently <uid> isn't replaced in lists. */
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2338 /* "idlist", MSIM_TYPE_STRING, g_strdup("a-|<uid>|b-|<uid>"), */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2339 "idlist", MSIM_TYPE_LIST, blocklist_updates,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2340 NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2341
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2342 if (!msim_postprocess_outgoing(session, blocklist_msg, buddy->name, "idlist", NULL)) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2343 purple_notify_error(NULL, NULL, _("Failed to remove buddy"), _("blocklist command failed"));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2344 msim_msg_free(blocklist_msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2345 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2346 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2347 msim_msg_free(blocklist_msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2348 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2349
22100
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2350 /**
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2351 * Returns a string of a username in canonical form. Basically removes all the
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2352 * spaces, lowercases the string, and looks up user IDs to usernames.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2353 * Normalizing tom, TOM, Tom, and 6221 wil all return 'tom'.
22100
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2354 *
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2355 * Borrowed this code from oscar_normalize. Added checking for
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2356 * "if userid, get name before normalizing"
22100
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2357 */
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2358 const char *msim_normalize(const PurpleAccount *account, const char *str) {
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2359 static char normalized[BUF_LEN];
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2360 char *tmp1, *tmp2;
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2361 int i, j;
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2362 guint id;
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2363
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2364 g_return_val_if_fail(str != NULL, NULL);
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2365
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2366 if (msim_is_userid(str)) {
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2367 /* Have user ID, we need to get their username first :) */
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2368 const char *username;
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2369
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2370 /* If the account does not exist, we can't look up the user. */
22160
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
2371 if (!account)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
2372 return str;
22159
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22158
diff changeset
2373
22100
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2374 id = atol(str);
22160
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
2375 username = msim_uid2username_from_blist((PurpleAccount *)account, id);
22100
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2376 if (!username) {
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2377 /* Not in buddy list... scheisse... TODO: Manual Lookup! Bug #4631 */
22100
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2378 /* Note: manual lookup using msim_lookup_user() is a problem inside
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2379 * msim_normalize(), because msim_lookup_user() calls a callback function
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2380 * when the user information has been looked up, but msim_normalize() expects
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2381 * the result immediately. */
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2382 strncpy(normalized, str, BUF_LEN);
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2383 } else {
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2384 strncpy(normalized, username, BUF_LEN);
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2385 }
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2386 } else {
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2387 /* Have username. */
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2388 strncpy(normalized, str, BUF_LEN);
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2389 }
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2390
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2391 /* Strip spaces. */
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2392 for (i=0, j=0; normalized[j]; i++, j++) {
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2393 while (normalized[j] == ' ')
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2394 j++;
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2395 normalized[i] = normalized[j];
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2396 }
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2397 normalized[i] = '\0';
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2398
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2399 /* Lowercase and perform UTF-8 normalization. */
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2400 tmp1 = g_utf8_strdown(normalized, -1);
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2401 tmp2 = g_utf8_normalize(tmp1, -1, G_NORMALIZE_DEFAULT);
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2402 g_snprintf(normalized, sizeof(normalized), "%s", tmp2);
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2403 g_free(tmp2);
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2404 g_free(tmp1);
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2405
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2406 /* TODO: re-add caps and spacing back to what the user wanted.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2407 * User can format their own names, for example 'msimprpl' is shown
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2408 * as 'MsIm PrPl' in the official client.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2409 *
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2410 * TODO: file a ticket to add this enhancement.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2411 */
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2412
22100
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2413 return normalized;
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2414 }
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
2415
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2416 /** Return whether the buddy can be messaged while offline.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2417 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2418 * The protocol supports offline messages in just the same way as online
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2419 * messages.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2420 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2421 gboolean
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2422 msim_offline_message(const PurpleBuddy *buddy)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2423 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2424 return TRUE;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2425 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2426
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2427 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2428 * Callback when input available.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2429 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2430 * @param gc_uncasted A PurpleConnection pointer.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2431 * @param source File descriptor.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2432 * @param cond PURPLE_INPUT_READ
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2433 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2434 * Reads the input, and calls msim_preprocess_incoming() to handle it.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2435 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2436 static void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2437 msim_input_cb(gpointer gc_uncasted, gint source, PurpleInputCondition cond)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2438 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2439 PurpleConnection *gc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2440 PurpleAccount *account;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2441 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2442 gchar *end;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2443 int n;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2444
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2445 g_return_if_fail(gc_uncasted != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2446 g_return_if_fail(source >= 0); /* Note: 0 is a valid fd */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2447
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2448 gc = (PurpleConnection *)(gc_uncasted);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2449 account = purple_connection_get_account(gc);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2450 session = gc->proto_data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2451
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2452 /* libpurple/eventloop.h only defines these two */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2453 if (cond != PURPLE_INPUT_READ && cond != PURPLE_INPUT_WRITE) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2454 purple_debug_info("msim_input_cb", "unknown condition=%d\n", cond);
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2455 purple_connection_error_reason (gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2456 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20121
e4bcdd9622c2 purple_connection_error_reason-ify myspace
Will Thompson <will.thompson@collabora.co.uk>
parents: 20057
diff changeset
2457 _("Invalid input condition"));
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2458 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2459 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2460
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2461 g_return_if_fail(cond == PURPLE_INPUT_READ);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2462 g_return_if_fail(MSIM_SESSION_VALID(session));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2463
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2464 /* Mark down that we got data, so we don't timeout. */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2465 session->last_comm = time(NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2466
22162
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2467 /* If approaching end of buffer, reallocate some more memory. */
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2468 if (session->rxsize < session->rxoff + MSIM_READ_BUF_SIZE) {
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2469 purple_debug_info("msim",
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2470 "msim_input_cb: %d-byte read buffer full, rxoff=%d, " "growing by %d bytes\n",
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2471 session->rxsize, session->rxoff, MSIM_READ_BUF_SIZE);
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2472 session->rxsize += MSIM_READ_BUF_SIZE;
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2473 session->rxbuf = g_realloc(session->rxbuf, session->rxsize);
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2474
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2475 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2476 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2477
22162
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2478 purple_debug_info("msim", "dynamic buffer at %d (max %d), reading up to %d\n",
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2479 session->rxoff, session->rxsize,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2480 MSIM_READ_BUF_SIZE - session->rxoff - 1);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2481
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2482 /* Read into buffer. On Win32, need recv() not read(). session->fd also holds
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2483 * the file descriptor, but it sometimes differs from the 'source' parameter.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2484 */
22162
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2485 n = recv(session->fd,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2486 session->rxbuf + session->rxoff,
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2487 session->rxsize - session->rxoff - 1, 0);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2488
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2489 if (n < 0 && errno == EAGAIN) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2490 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2491 } else if (n < 0) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2492 purple_debug_error("msim", "msim_input_cb: read error, ret=%d, "
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2493 "error=%s, source=%d, fd=%d (%X))\n",
21121
35b4f1dc4c8d replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents: 21000
diff changeset
2494 n, g_strerror(errno), source, session->fd, session->fd);
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2495 purple_connection_error_reason (gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2496 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20121
e4bcdd9622c2 purple_connection_error_reason-ify myspace
Will Thompson <will.thompson@collabora.co.uk>
parents: 20057
diff changeset
2497 _("Read error"));
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2498 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2499 } else if (n == 0) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2500 purple_debug_info("msim", "msim_input_cb: server disconnected\n");
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2501 purple_connection_error_reason (gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2502 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20121
e4bcdd9622c2 purple_connection_error_reason-ify myspace
Will Thompson <will.thompson@collabora.co.uk>
parents: 20057
diff changeset
2503 _("Server has disconnected"));
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2504 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2505 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2506
22162
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2507 if (n + session->rxoff > session->rxsize) {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2508 purple_debug_info("msim_input_cb", "received %d bytes, pushing rxoff to %d, over buffer size of %d\n",
22162
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2509 n, n + session->rxoff, session->rxsize);
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2510 purple_connection_error_reason (gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2511 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
22162
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2512 _("Read buffer full (2)"));
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2513 return;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2514 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2515
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2516 /* Null terminate */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2517 purple_debug_info("msim", "msim_input_cb: going to null terminate "
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2518 "at n=%d\n", n);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2519 session->rxbuf[session->rxoff + n] = 0;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2520
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2521 #ifdef MSIM_CHECK_EMBEDDED_NULLS
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2522 /* Check for embedded NULs. I don't handle them, and they shouldn't occur. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2523 if (strlen(session->rxbuf + session->rxoff) != n) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2524 /* Occurs after login, but it is not a null byte. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2525 purple_debug_info("msim", "msim_input_cb: strlen=%d, but read %d bytes"
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2526 "--null byte encountered?\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2527 strlen(session->rxbuf + session->rxoff), n);
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2528 /*purple_connection_error_reason (gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2529 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20121
e4bcdd9622c2 purple_connection_error_reason-ify myspace
Will Thompson <will.thompson@collabora.co.uk>
parents: 20057
diff changeset
2530 "Invalid message - null byte on input"); */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2531 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2532 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2533 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2534
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2535 session->rxoff += n;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2536 purple_debug_info("msim", "msim_input_cb: read=%d\n", n);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2537
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2538 #ifdef MSIM_DEBUG_RXBUF
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2539 purple_debug_info("msim", "buf=<%s>\n", session->rxbuf);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2540 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2541
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2542 /* Look for \\final\\ end markers. If found, process message. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2543 while((end = strstr(session->rxbuf, MSIM_FINAL_STRING))) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2544 MsimMessage *msg;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2545
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2546 #ifdef MSIM_DEBUG_RXBUF
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2547 purple_debug_info("msim", "in loop: buf=<%s>\n", session->rxbuf);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2548 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2549 *end = 0;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2550 msg = msim_parse(g_strdup(session->rxbuf));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2551 if (!msg) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2552 purple_debug_info("msim", "msim_input_cb: couldn't parse rxbuf\n");
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2553 purple_connection_error_reason (gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2554 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20121
e4bcdd9622c2 purple_connection_error_reason-ify myspace
Will Thompson <will.thompson@collabora.co.uk>
parents: 20057
diff changeset
2555 _("Unparseable message"));
22162
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2556 break;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2557 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2558 /* Process message and then free it (processing function should
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2559 * clone message if it wants to keep it afterwards.) */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2560 if (!msim_preprocess_incoming(session, msg)) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2561 msim_msg_dump("msim_input_cb: preprocessing message failed on msg: %s\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2562 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2563 msim_msg_free(msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2564 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2565
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2566 /* Move remaining part of buffer to beginning. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2567 session->rxoff -= strlen(session->rxbuf) + strlen(MSIM_FINAL_STRING);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2568 memmove(session->rxbuf, end + strlen(MSIM_FINAL_STRING),
22162
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22161
diff changeset
2569 session->rxsize - (end + strlen(MSIM_FINAL_STRING) - session->rxbuf));
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2570
22156
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2571 /* Clear end of buffer
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2572 * memset(end, 0, MSIM_READ_BUF_SIZE - (end - session->rxbuf));
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22100
diff changeset
2573 */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2574 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2575 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2576
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2577 /* Setup a callback, to be called when a reply is received with the returned rid.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2578 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2579 * @param cb The callback, an MSIM_USER_LOOKUP_CB.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2580 * @param data Arbitrary user data to be passed to callback (probably an MsimMessage *).
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2581 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2582 * @return The request/reply ID, used to link replies with requests, or -1.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2583 * Put the rid in your request, 'rid' field.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2584 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2585 * TODO: Make more generic and more specific:
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2586 * 1) MSIM_USER_LOOKUP_CB - make it for PERSIST_REPLY, not just user lookup
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2587 * 2) data - make it an MsimMessage?
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2588 */
19435
bddc6a6fddf0 In msimprpl, move user-related code to a new user module, and move other
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19434
diff changeset
2589 guint
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2590 msim_new_reply_callback(MsimSession *session, MSIM_USER_LOOKUP_CB cb,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2591 gpointer data)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2592 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2593 guint rid;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2594
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2595 g_return_val_if_fail(MSIM_SESSION_VALID(session), -1);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2596
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2597 rid = session->next_rid++;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2598
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2599 g_hash_table_insert(session->user_lookup_cb, GUINT_TO_POINTER(rid), cb);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2600 g_hash_table_insert(session->user_lookup_cb_data, GUINT_TO_POINTER(rid), data);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2601
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2602 return rid;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2603 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2604
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2605 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2606 * Callback when connected. Sets up input handlers.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2607 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2608 * @param data A PurpleConnection pointer.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2609 * @param source File descriptor.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2610 * @param error_message
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2611 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2612 static void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2613 msim_connect_cb(gpointer data, gint source, const gchar *error_message)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2614 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2615 PurpleConnection *gc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2616 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2617
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2618 g_return_if_fail(data != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2619
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2620 gc = (PurpleConnection *)data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2621 session = (MsimSession *)gc->proto_data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2622
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2623 if (source < 0) {
21358
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2624 purple_connection_error_reason (gc,
ba41f2a60253 Rename:
Will Thompson <will.thompson@collabora.co.uk>
parents: 20892
diff changeset
2625 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20121
e4bcdd9622c2 purple_connection_error_reason-ify myspace
Will Thompson <will.thompson@collabora.co.uk>
parents: 20057
diff changeset
2626 g_strdup_printf(_("Couldn't connect to host: %s (%d)"),
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2627 error_message ? error_message : "no message given",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2628 source));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2629 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2630 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2631
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2632 session->fd = source;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2633
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2634 gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, msim_input_cb, gc);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2635 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2636
19433
9a1b28a10c95 In msimprpl, move session-related functions to a new session module.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19432
diff changeset
2637
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2638 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2639 * Close the connection.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2640 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2641 * @param gc The connection.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2642 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2643 void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2644 msim_close(PurpleConnection *gc)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2645 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2646 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2647
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2648 if (gc == NULL) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2649 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2650 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2651
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2652 session = (MsimSession *)gc->proto_data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2653 if (session == NULL)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2654 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2655
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2656 gc->proto_data = NULL;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2657
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2658 if (!MSIM_SESSION_VALID(session)) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2659 return;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2660 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2661
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2662 if (session->gc->inpa) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2663 purple_input_remove(session->gc->inpa);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2664 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2665
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2666 msim_session_destroy(session);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2667 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2668
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2669
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2670 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2671 * Obtain the status text for a buddy.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2672 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2673 * @param buddy The buddy to obtain status text for.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2674 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2675 * @return Status text, or NULL if error. Caller g_free()'s.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2676 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2677 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2678 char *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2679 msim_status_text(PurpleBuddy *buddy)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2680 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2681 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2682 MsimUser *user;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2683 const gchar *display_name, *headline;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2684
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2685 g_return_val_if_fail(buddy != NULL, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2686
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2687 user = msim_get_user_from_buddy(buddy);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2688
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2689 session = (MsimSession *)buddy->account->gc->proto_data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2690 g_return_val_if_fail(MSIM_SESSION_VALID(session), NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2691
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2692 display_name = headline = NULL;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2693
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2694 /* Retrieve display name and/or headline, depending on user preference. */
20996
ec3736fe2e4e There's an #ifdef in MSIM which, if enabled, allows the user to specify
Kevin Stange <kevin@simguy.net>
parents: 20982
diff changeset
2695 if (purple_account_get_bool(session->account, "show_headline", TRUE)) {
ec3736fe2e4e There's an #ifdef in MSIM which, if enabled, allows the user to specify
Kevin Stange <kevin@simguy.net>
parents: 20982
diff changeset
2696 headline = user->headline;
ec3736fe2e4e There's an #ifdef in MSIM which, if enabled, allows the user to specify
Kevin Stange <kevin@simguy.net>
parents: 20982
diff changeset
2697 }
ec3736fe2e4e There's an #ifdef in MSIM which, if enabled, allows the user to specify
Kevin Stange <kevin@simguy.net>
parents: 20982
diff changeset
2698
ec3736fe2e4e There's an #ifdef in MSIM which, if enabled, allows the user to specify
Kevin Stange <kevin@simguy.net>
parents: 20982
diff changeset
2699 if (purple_account_get_bool(session->account, "show_display_name", FALSE)) {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2700 display_name = user->display_name;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2701 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2702
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2703 /* Return appropriate combination of display name and/or headline, or neither. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2704
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2705 if (display_name && headline) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2706 return g_strconcat(display_name, " ", headline, NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2707 } else if (display_name) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2708 return g_strdup(display_name);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2709 } else if (headline) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2710 return g_strdup(headline);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2711 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2712
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2713 return NULL;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2714 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2715
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2716 /**
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2717 * Obtain the tooltip text for a buddy.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2718 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2719 * @param buddy Buddy to obtain tooltip text on.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2720 * @param user_info Variable modified to have the tooltip text.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2721 * @param full TRUE if should obtain full tooltip text.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2722 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2723 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2724 void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2725 msim_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2726 gboolean full)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2727 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2728 MsimUser *user;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2729
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2730 g_return_if_fail(buddy != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2731 g_return_if_fail(user_info != NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2732
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2733 user = msim_get_user_from_buddy(buddy);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2734
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2735 if (PURPLE_BUDDY_IS_ONLINE(buddy)) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2736 MsimSession *session;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2737
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2738 session = (MsimSession *)buddy->account->gc->proto_data;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2739
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2740 g_return_if_fail(MSIM_SESSION_VALID(session));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2741
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2742 /* TODO: if (full), do something different? */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2743
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2744 /* TODO: request information? have to figure out how to do
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2745 * the asynchronous lookup like oscar does (tooltip shows
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2746 * 'retrieving...' if not yet available, then changes when it is).
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2747 *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2748 * Right now, only show what we have on hand.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2749 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2750
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2751 /* Show abbreviated user info. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2752 msim_append_user_info(session, user_info, user, FALSE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2753 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2754 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2755
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2756 /** Add contact from server to buddy list, after looking up username.
19256
34a1957de14b Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19255
diff changeset
2757 * Callback from msim_add_contact_from_server().
34a1957de14b Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19255
diff changeset
2758 *
34a1957de14b Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19255
diff changeset
2759 * @param data An MsimMessage * of the contact information. Will be freed.
34a1957de14b Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19255
diff changeset
2760 */
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2761 static void
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2762 msim_add_contact_from_server_cb(MsimSession *session, MsimMessage *user_lookup_info, gpointer data)
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2763 {
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2764 MsimMessage *contact_info, *user_lookup_info_body;
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2765 PurpleGroup *group;
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2766 PurpleBuddy *buddy;
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2767 MsimUser *user;
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2768 gchar *username, *group_name;
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2769 guint uid;
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2770
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2771 contact_info = (MsimMessage *)data;
19256
34a1957de14b Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19255
diff changeset
2772 purple_debug_info("msim_add_contact_from_server_cb", "contact_info addr=%X\n", contact_info);
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2773 uid = msim_msg_get_integer(contact_info, "ContactID");
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2774
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2775 if (!user_lookup_info) {
22159
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22158
diff changeset
2776 username = g_strdup(msim_uid2username_from_blist(session->account, uid));
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2777 g_return_if_fail(username != NULL);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2778 } else {
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2779 user_lookup_info_body = msim_msg_get_dictionary(user_lookup_info, "body");
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2780 username = msim_msg_get_string(user_lookup_info_body, "UserName");
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2781 msim_msg_free(user_lookup_info_body);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2782 g_return_if_fail(username != NULL);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2783 }
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2784
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2785 purple_debug_info("msim_add_contact_from_server_cb",
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2786 "*** about to add/update username=%s\n", username);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2787
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2788 /* 1. Creates a new group, or gets existing group if it exists (or so
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2789 * the documentation claims). */
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2790 group_name = msim_msg_get_string(contact_info, "GroupName");
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2791 if (group_name) {
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2792 group = purple_group_new(group_name);
19354
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2793 purple_debug_info("msim_add_contact_from_server_cb",
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2794 "adding to GroupName: %s\n", group_name);
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2795 g_free(group_name);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2796 } else {
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2797 group = purple_group_new(_("IM Friends"));
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2798 }
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2799
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2800 /* 2. Get or create buddy */
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2801 buddy = purple_find_buddy(session->account, username);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2802 if (!buddy) {
19354
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2803 purple_debug_info("msim_add_contact_from_server_cb",
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2804 "creating new buddy: %s\n", username);
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2805 buddy = purple_buddy_new(session->account, username, NULL);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2806 }
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2807
19354
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2808 /* Add group to beginning. See #2752. */
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2809 purple_blist_add_group(group, NULL);
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2810
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2811 /* TODO: use 'Position' in contact_info to take into account where buddy is */
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2812 purple_blist_add_buddy(buddy, NULL, group, NULL /* insertion point */);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2813
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2814 /* 3. Update buddy information */
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2815 user = msim_get_user_from_buddy(buddy);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2816
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2817 /* All buddies on list should have 'uid' integer associated with them. */
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2818 purple_blist_node_set_int(&buddy->node, "UserID", uid);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2819
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2820 /* Stores a few fields in the MsimUser, relevant to the buddy itself.
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2821 * AvatarURL, Headline, ContactID. */
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2822 msim_store_user_info(session, contact_info, NULL);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2823
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2824 /* TODO: other fields, store in 'user' */
19256
34a1957de14b Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19255
diff changeset
2825
34a1957de14b Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19255
diff changeset
2826 msim_msg_free(contact_info);
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2827 }
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2828
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2829 /** Add first ContactID in contact_info to buddy's list. Used to add
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2830 * server-side buddies to client-side list.
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2831 *
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2832 * @return TRUE if added.
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2833 * */
19354
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2834 static gboolean
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2835 msim_add_contact_from_server(MsimSession *session, MsimMessage *contact_info)
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2836 {
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2837 guint uid;
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2838 const gchar *username;
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2839
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2840 uid = msim_msg_get_integer(contact_info, "ContactID");
19354
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2841 g_return_val_if_fail(uid != 0, FALSE);
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2842
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2843 /* Lookup the username, since NickName and IMName is unreliable */
22159
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22158
diff changeset
2844 username = msim_uid2username_from_blist(session->account, uid);
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2845 if (!username) {
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2846 gchar *uid_str;
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2847
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2848 uid_str = g_strdup_printf("%d", uid);
19256
34a1957de14b Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19255
diff changeset
2849 purple_debug_info("msim_add_contact_from_server",
34a1957de14b Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19255
diff changeset
2850 "contact_info addr=%X\n", contact_info);
34a1957de14b Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19255
diff changeset
2851 msim_lookup_user(session, uid_str, msim_add_contact_from_server_cb, (gpointer)msim_msg_clone(contact_info));
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2852 g_free(uid_str);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2853 } else {
19256
34a1957de14b Fix crashes. In myspace.c, clone the contact_info message before sending it to
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19255
diff changeset
2854 msim_add_contact_from_server_cb(session, NULL, (gpointer)msim_msg_clone(contact_info));
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2855 }
19354
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2856
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2857 /* Say that the contact was added, even if we're still looking up
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2858 * their username. */
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2859 return TRUE;
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2860 }
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2861
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2862 /** Called when contact list is received from server. */
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2863 static void
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2864 msim_got_contact_list(MsimSession *session, MsimMessage *reply, gpointer user_data)
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2865 {
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2866 MsimMessage *body, *body_node;
19354
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2867 gchar *msg;
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2868 guint buddy_count;
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2869
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2870 msim_msg_dump("msim_got_contact_list: reply=%s", reply);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2871
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2872 body = msim_msg_get_dictionary(reply, "body");
22160
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
2873 if (!body) {
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
2874 /* No friends. Not an error. */
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
2875 return;
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 22159
diff changeset
2876 }
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2877
19354
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2878 buddy_count = 0;
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2879
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2880 for (body_node = body;
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2881 body_node != NULL;
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2882 body_node = msim_msg_get_next_element_node(body_node))
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2883 {
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2884 MsimMessageElement *elem;
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2885
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2886 elem = (MsimMessageElement *)body_node->data;
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2887
19428
1fa10842eb83 In msimprpl, replace !strcmp() with g_str_equal() everywhere.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19427
diff changeset
2888 if (g_str_equal(elem->name, "ContactID"))
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2889 {
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2890 /* Will look for first contact in body_node */
19354
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2891 if (msim_add_contact_from_server(session, body_node)) {
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2892 ++buddy_count;
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2893 }
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2894 }
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2895 }
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2896
19462
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2897 switch (GPOINTER_TO_UINT(user_data)) {
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2898 case MSIM_CONTACT_LIST_IMPORT_ALL_FRIENDS:
19594
30625863ae2b Clarify message about contacts added from server, for #2918.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19592
diff changeset
2899 msg = g_strdup_printf(_("%d buddies were added or updated from the server (including buddies already on the server-side list)"), buddy_count);
19462
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2900 purple_notify_info(session->account, _("Add contacts from server"), msg, NULL);
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2901 g_free(msg);
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2902 break;
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2903
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2904 case MSIM_CONTACT_LIST_IMPORT_TOP_FRIENDS:
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2905 /* TODO */
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2906 break;
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2907
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2908 case MSIM_CONTACT_LIST_INITIAL_FRIENDS:
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2909 /* Nothing */
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2910 break;
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2911 }
19354
b22a33d3fc95 Improve buddy importing. Count number of buddies being added, and
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19353
diff changeset
2912
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2913 msim_msg_free(body);
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2914 }
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2915
19462
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2916 /* Get contact list, calling msim_got_contact_list() with what_to_do_after as user_data gpointer. */
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2917 static gboolean
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2918 msim_get_contact_list(MsimSession *session, int what_to_do_after)
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2919 {
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2920 return msim_send(session,
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2921 "persist", MSIM_TYPE_INTEGER, 1,
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2922 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2923 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_GET,
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2924 "dsn", MSIM_TYPE_INTEGER, MG_LIST_ALL_CONTACTS_DSN,
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2925 "lid", MSIM_TYPE_INTEGER, MG_LIST_ALL_CONTACTS_LID,
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2926 "uid", MSIM_TYPE_INTEGER, session->userid,
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2927 "rid", MSIM_TYPE_INTEGER,
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2928 msim_new_reply_callback(session, msim_got_contact_list, GUINT_TO_POINTER(what_to_do_after)),
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2929 "body", MSIM_TYPE_STRING, g_strdup(""),
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2930 NULL);
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2931 }
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2932
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2933
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2934 /** Called when friends have been imported to buddy list on server. */
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2935 static void
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2936 msim_import_friends_cb(MsimSession *session, MsimMessage *reply, gpointer user_data)
19249
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2937 {
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2938 MsimMessage *body;
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2939 gchar *completed;
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2940 msim_msg_dump("msim_import_friends_cb=%s", reply);
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2941
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2942 /* Check if the friends were imported successfully. */
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2943 body = msim_msg_get_dictionary(reply, "body");
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2944 g_return_if_fail(body != NULL);
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2945 completed = msim_msg_get_string(body, "Completed");
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2946 g_return_if_fail(body != NULL);
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2947 msim_msg_free(body);
19428
1fa10842eb83 In msimprpl, replace !strcmp() with g_str_equal() everywhere.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19427
diff changeset
2948 if (!g_str_equal(completed, "True"))
19249
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2949 {
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2950 purple_debug_info("msim_import_friends_cb",
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2951 "failed to import friends: %s", completed);
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2952 purple_notify_error(session->account, _("Add friends from MySpace.com"),
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2953 _("Importing friends failed"), NULL);
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2954 g_free(completed);
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2955 return;
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2956 }
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2957 g_free(completed);
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2958
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2959 purple_debug_info("msim_import_friends_cb",
19255
1ea47b06f1a6 Initial implementation of friend importing. Not well tested.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19251
diff changeset
2960 "added friends to server-side buddy list, requesting new contacts from server");
19249
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2961
19462
105305518622 On login, get contacts from server using msim_get_contact_list().
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19442
diff changeset
2962 msim_get_contact_list(session, MSIM_CONTACT_LIST_IMPORT_ALL_FRIENDS);
19249
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2963
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2964 /* TODO: show, X friends have been added */
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2965 }
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2966
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2967 /** Import friends from myspace.com. */
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2968 static void msim_import_friends(PurplePluginAction *action)
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2969 {
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2970 PurpleConnection *gc;
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2971 MsimSession *session;
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2972 gchar *group_name;
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2973
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2974 gc = (PurpleConnection *)action->context;
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2975 session = (MsimSession *)gc->proto_data;
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2976
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2977 group_name = "MySpace Friends";
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2978
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2979 g_return_if_fail(msim_send(session,
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2980 "persist", MSIM_TYPE_INTEGER, 1,
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2981 "sesskey", MSIM_TYPE_INTEGER, session->sesskey,
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2982 "cmd", MSIM_TYPE_INTEGER, MSIM_CMD_PUT,
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2983 "dsn", MSIM_TYPE_INTEGER, MC_IMPORT_ALL_FRIENDS_DSN,
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2984 "lid", MSIM_TYPE_INTEGER, MC_IMPORT_ALL_FRIENDS_LID,
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2985 "uid", MSIM_TYPE_INTEGER, session->userid,
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2986 "rid", MSIM_TYPE_INTEGER,
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2987 msim_new_reply_callback(session, msim_import_friends_cb, NULL),
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2988 "body", MSIM_TYPE_STRING,
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2989 g_strdup_printf("GroupName=%s", group_name),
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2990 NULL));
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2991
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2992
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2993 }
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
2994
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2995 /** Actions menu for account. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2996 GList *
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2997 msim_actions(PurplePlugin *plugin, gpointer context)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2998 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
2999 PurpleConnection *gc;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3000 GList *menu;
19249
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
3001 PurplePluginAction *act;
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3002
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3003 gc = (PurpleConnection *)context;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3004
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3005 menu = NULL;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3006
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3007 #if 0
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3008 /* TODO: find out how */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3009 act = purple_plugin_action_new(_("Find people..."), msim_);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3010 menu = g_list_append(menu, act);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3011
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3012 act = purple_plugin_action_new(_("Change IM name..."), NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3013 menu = g_list_append(menu, act);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3014 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3015
21950
d357ce994bd6 Fixed a leak
Evan Schoenberg <evan.s@dreskin.net>
parents: 21759
diff changeset
3016 act = purple_plugin_action_new(_("Add friends from MySpace.com"), msim_import_friends);
19249
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
3017 menu = g_list_append(menu, act);
9d921dde9d9f First half of "Add friends from MySpace.com" support: add msim_import_friends(),
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19247
diff changeset
3018
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3019 return menu;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3020 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3021
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3022 /** Callbacks called by Purple, to access this plugin. */
20057
27754fc4d72e static this.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19926
diff changeset
3023 static PurplePluginProtocolInfo prpl_info = {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3024 /* options */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3025 OPT_PROTO_USE_POINTSIZE /* specify font size in sane point size */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3026 | OPT_PROTO_MAIL_CHECK,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3027
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3028 /* | OPT_PROTO_IM_IMAGE - TODO: direct images. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3029 NULL, /* user_splits */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3030 NULL, /* protocol_options */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3031 NO_BUDDY_ICONS, /* icon_spec - TODO: eventually should add this */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3032 msim_list_icon, /* list_icon */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3033 NULL, /* list_emblems */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3034 msim_status_text, /* status_text */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3035 msim_tooltip_text, /* tooltip_text */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3036 msim_status_types, /* status_types */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3037 msim_blist_node_menu, /* blist_node_menu */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3038 NULL, /* chat_info */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3039 NULL, /* chat_info_defaults */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3040 msim_login, /* login */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3041 msim_close, /* close */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3042 msim_send_im, /* send_im */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3043 NULL, /* set_info */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3044 msim_send_typing, /* send_typing */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3045 msim_get_info, /* get_info */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3046 msim_set_status, /* set_status */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3047 msim_set_idle, /* set_idle */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3048 NULL, /* change_passwd */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3049 msim_add_buddy, /* add_buddy */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3050 NULL, /* add_buddies */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3051 msim_remove_buddy, /* remove_buddy */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3052 NULL, /* remove_buddies */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3053 NULL, /* add_permit */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3054 NULL, /* add_deny */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3055 NULL, /* rem_permit */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3056 NULL, /* rem_deny */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3057 NULL, /* set_permit_deny */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3058 NULL, /* join_chat */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3059 NULL, /* reject chat invite */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3060 NULL, /* get_chat_name */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3061 NULL, /* chat_invite */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3062 NULL, /* chat_leave */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3063 NULL, /* chat_whisper */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3064 NULL, /* chat_send */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3065 NULL, /* keepalive */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3066 NULL, /* register_user */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3067 NULL, /* get_cb_info */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3068 NULL, /* get_cb_away */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3069 NULL, /* alias_buddy */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3070 NULL, /* group_buddy */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3071 NULL, /* rename_group */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3072 NULL, /* buddy_free */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3073 NULL, /* convo_closed */
22100
1226083ed7e2 Implement prpl_info->normalize for msimprpl, modified patch from Jaywalker.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 21950
diff changeset
3074 msim_normalize, /* normalize */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3075 NULL, /* set_buddy_icon */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3076 NULL, /* remove_group */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3077 NULL, /* get_cb_real_name */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3078 NULL, /* set_chat_topic */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3079 NULL, /* find_blist_chat */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3080 NULL, /* roomlist_get_list */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3081 NULL, /* roomlist_cancel */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3082 NULL, /* roomlist_expand_category */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3083 NULL, /* can_receive_file */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3084 NULL, /* send_file */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3085 NULL, /* new_xfer */
19243
a242e014ab8c Re-apply the msimprpl-specific parts of revision
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19242
diff changeset
3086 msim_offline_message, /* offline_message */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3087 NULL, /* whiteboard_prpl_ops */
19243
a242e014ab8c Re-apply the msimprpl-specific parts of revision
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19242
diff changeset
3088 msim_send_really_raw, /* send_raw */
a242e014ab8c Re-apply the msimprpl-specific parts of revision
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19242
diff changeset
3089 NULL, /* roomlist_room_serialize */
19712
eabc8a32b1e4 Fix up an apparently bad merge with the reserved fields here.
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
3090 NULL, /* unregister_user */
19243
a242e014ab8c Re-apply the msimprpl-specific parts of revision
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19242
diff changeset
3091 msim_send_attention, /* send_attention */
a242e014ab8c Re-apply the msimprpl-specific parts of revision
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19242
diff changeset
3092 msim_attention_types, /* attention_types */
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3093 NULL /* _purple_reserved4 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3094 };
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3095
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3096
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3097
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3098 /** Based on MSN's plugin info comments. */
19720
b2d213681176 Protocol's (and other plugin's) PurplePluginInfo structs should really be
Etan Reisner <pidgin@unreliablesource.net>
parents: 19713
diff changeset
3099 static PurplePluginInfo info = {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3100 PURPLE_PLUGIN_MAGIC,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3101 PURPLE_MAJOR_VERSION,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3102 PURPLE_MINOR_VERSION,
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3103 PURPLE_PLUGIN_PROTOCOL, /**< type */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3104 NULL, /**< ui_requirement */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3105 0, /**< flags */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3106 NULL, /**< dependencies */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3107 PURPLE_PRIORITY_DEFAULT, /**< priority */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3108
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3109 "prpl-myspace", /**< id */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3110 "MySpaceIM", /**< name */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3111 MSIM_PRPL_VERSION_STRING, /**< version */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3112 /** summary */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3113 "MySpaceIM Protocol Plugin",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3114 /** description */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3115 "MySpaceIM Protocol Plugin",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3116 "Jeff Connelly <jeff2@soc.pidgin.im>", /**< author */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3117 "http://developer.pidgin.im/wiki/MySpaceIM/", /**< homepage */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3118
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3119 msim_load, /**< load */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3120 NULL, /**< unload */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3121 NULL, /**< destroy */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3122 NULL, /**< ui_info */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3123 &prpl_info, /**< extra_info */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3124 NULL, /**< prefs_info */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3125 msim_actions, /**< msim_actions */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3126 NULL, /**< reserved1 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3127 NULL, /**< reserved2 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3128 NULL, /**< reserved3 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3129 NULL /**< reserved4 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3130 };
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3131
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3132
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3133 #ifdef MSIM_SELF_TEST
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3134 /** Test functions.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3135 * Used to test or try out the internal workings of msimprpl. If you're reading
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3136 * this code for the first time, these functions can be instructive in learning
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3137 * how msimprpl is architected.
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3138 */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3139 void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3140 msim_test_all(void) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3141 guint failures;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3142
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3143
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3144 failures = 0;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3145 failures += msim_test_msg();
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3146 failures += msim_test_escaping();
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3147
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3148 if (failures) {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3149 purple_debug_info("msim", "msim_test_all HAD FAILURES: %d\n", failures);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3150 } else {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3151 purple_debug_info("msim", "msim_test_all - all tests passed!\n");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3152 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3153 exit(0);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3154 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3155
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3156 /** Test MsimMessage for basic functionality. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3157 int
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3158 msim_test_msg(void)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3159 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3160 MsimMessage *msg, *msg_cloned, *msg2;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3161 GList *list;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3162 gchar *packed, *packed_expected, *packed_cloned;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3163 guint failures;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3164
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3165 failures = 0;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3166
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3167 purple_debug_info("msim", "\n\nTesting MsimMessage\n");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3168 msg = msim_msg_new(NULL); /* Create a new, empty message. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3169
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3170 /* Append some new elements. */
20658
7efdc052539d Fix lots of little memory leaks in the MySpace protocol plugin.
Mark Doliner <mark@kingant.net>
parents: 20628
diff changeset
3171 msg = msim_msg_append(msg, "bx", MSIM_TYPE_BINARY, g_string_new_len("XXX", 3));
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3172 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v1"));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3173 msg = msim_msg_append(msg, "k1", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(42));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3174 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v43"));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3175 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v52/xxx\\yyy"));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3176 msg = msim_msg_append(msg, "k1", MSIM_TYPE_STRING, g_strdup("v7"));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3177 msim_msg_dump("msg debug str=%s\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3178 packed = msim_msg_pack(msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3179
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3180 purple_debug_info("msim", "msg packed=%s\n", packed);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3181
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3182 packed_expected = "\\bx\\WFhY\\k1\\v1\\k1\\42\\k1"
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3183 "\\v43\\k1\\v52/1xxx/2yyy\\k1\\v7\\final\\";
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3184
19428
1fa10842eb83 In msimprpl, replace !strcmp() with g_str_equal() everywhere.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19427
diff changeset
3185 if (!g_str_equal(packed, packed_expected)) {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3186 purple_debug_info("msim", "!!!(%d), msim_msg_pack not what expected: %s != %s\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3187 ++failures, packed, packed_expected);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3188 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3189
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3190
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3191 msg_cloned = msim_msg_clone(msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3192 packed_cloned = msim_msg_pack(msg_cloned);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3193
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3194 purple_debug_info("msim", "msg cloned=%s\n", packed_cloned);
19428
1fa10842eb83 In msimprpl, replace !strcmp() with g_str_equal() everywhere.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19427
diff changeset
3195 if (!g_str_equal(packed, packed_cloned)) {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3196 purple_debug_info("msim", "!!!(%d), msim_msg_pack on cloned message not equal to original: %s != %s\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3197 ++failures, packed_cloned, packed);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3198 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3199
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3200 g_free(packed);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3201 g_free(packed_cloned);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3202 msim_msg_free(msg_cloned);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3203 msim_msg_free(msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3204
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3205 /* Try some of the more advanced functionality */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3206 list = NULL;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3207
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3208 list = g_list_prepend(list, "item3");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3209 list = g_list_prepend(list, "item2");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3210 list = g_list_prepend(list, "item1");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3211 list = g_list_prepend(list, "item0");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3212
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3213 msg = msim_msg_new(NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3214 msg = msim_msg_append(msg, "string", MSIM_TYPE_STRING, g_strdup("string value"));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3215 msg = msim_msg_append(msg, "raw", MSIM_TYPE_RAW, g_strdup("raw value"));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3216 msg = msim_msg_append(msg, "integer", MSIM_TYPE_INTEGER, GUINT_TO_POINTER(3140));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3217 msg = msim_msg_append(msg, "boolean", MSIM_TYPE_BOOLEAN, GUINT_TO_POINTER(FALSE));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3218 msg = msim_msg_append(msg, "list", MSIM_TYPE_LIST, list);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3219
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3220 msim_msg_dump("msg with list=%s\n", msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3221 purple_debug_info("msim", "msg with list packed=%s\n", msim_msg_pack(msg));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3222
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3223 msg2 = msim_msg_new(NULL);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3224 msg2 = msim_msg_append(msg2, "outer", MSIM_TYPE_STRING, g_strdup("outer value"));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3225 msg2 = msim_msg_append(msg2, "body", MSIM_TYPE_DICTIONARY, msg);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3226 msim_msg_dump("msg with dict=%s\n", msg2); /* msg2 now 'owns' msg */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3227 purple_debug_info("msim", "msg with dict packed=%s\n", msim_msg_pack(msg2));
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3228
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3229 msim_msg_free(msg2);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3230
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3231 return failures;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3232 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3233
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3234 /** Test protocol-level escaping/unescaping. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3235 int
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3236 msim_test_escaping(void)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3237 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3238 guint failures;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3239 gchar *raw, *escaped, *unescaped, *expected;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3240
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3241 failures = 0;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3243 purple_debug_info("msim", "\n\nTesting escaping\n");
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3244
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3245 raw = "hello/world\\hello/world";
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3246
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3247 escaped = msim_escape(raw);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3248 purple_debug_info("msim", "msim_test_escaping: raw=%s, escaped=%s\n", raw, escaped);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3249 expected = "hello/1world/2hello/1world";
19428
1fa10842eb83 In msimprpl, replace !strcmp() with g_str_equal() everywhere.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19427
diff changeset
3250 if (!g_str_equal(escaped, expected)) {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3251 purple_debug_info("msim", "!!!(%d), msim_escape failed: %s != %s\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3252 ++failures, escaped, expected);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3253 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3254
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3255
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3256 unescaped = msim_unescape(escaped);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3257 g_free(escaped);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3258 purple_debug_info("msim", "msim_test_escaping: unescaped=%s\n", unescaped);
19428
1fa10842eb83 In msimprpl, replace !strcmp() with g_str_equal() everywhere.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19427
diff changeset
3259 if (!g_str_equal(raw, unescaped)) {
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3260 purple_debug_info("msim", "!!!(%d), msim_unescape failed: %s != %s\n",
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3261 ++failures, raw, unescaped);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3262 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3263
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3264 return failures;
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3265 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3266 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3267
19436
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3268 static gboolean
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3269 msim_uri_handler(const gchar *proto, const gchar *cmd, GHashTable *params)
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3270 {
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3271 PurpleAccount *account;
19441
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3272 MsimSession *session;
19436
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3273 GList *l;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3274 gchar *uid_str, *cid_str;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3275 guint uid, cid;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3276
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3277 if (g_ascii_strcasecmp(proto, "myim"))
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3278 return FALSE;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3279
19439
0202145e3465 In msimprpl, fix the msim_uri_handler(). The sendIM and addContact commands
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19437
diff changeset
3280 /* Parameters are case-insensitive. */
0202145e3465 In msimprpl, fix the msim_uri_handler(). The sendIM and addContact commands
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19437
diff changeset
3281 uid_str = g_hash_table_lookup(params, "uid");
0202145e3465 In msimprpl, fix the msim_uri_handler(). The sendIM and addContact commands
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19437
diff changeset
3282 cid_str = g_hash_table_lookup(params, "cid");
19436
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3283
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3284 uid = uid_str ? atol(uid_str) : 0;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3285 cid = cid_str ? atol(cid_str) : 0;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3286
19439
0202145e3465 In msimprpl, fix the msim_uri_handler(). The sendIM and addContact commands
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19437
diff changeset
3287 /* Need a contact. */
0202145e3465 In msimprpl, fix the msim_uri_handler(). The sendIM and addContact commands
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19437
diff changeset
3288 g_return_val_if_fail(cid != 0, FALSE);
0202145e3465 In msimprpl, fix the msim_uri_handler(). The sendIM and addContact commands
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19437
diff changeset
3289
19442
d7cd580c0753 In msimprpl: if no local alias is set, set it to the username on sign-on.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19441
diff changeset
3290 /* TODO: if auto=true, "Add all the people on this page to my IM List!", on
d7cd580c0753 In msimprpl: if no local alias is set, set it to the username on sign-on.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19441
diff changeset
3291 * http://collect.myspace.com/index.cfm?fuseaction=im.friendslist. Don't need a cid. */
d7cd580c0753 In msimprpl: if no local alias is set, set it to the username on sign-on.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19441
diff changeset
3292
19441
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3293 /* Convert numeric contact ID back to a string. Needed for looking up. Don't just
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3294 * directly use cid directly from parameters, because it might not be numeric.
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3295 * It is trivial to change this to allow cID to be a username, but that's not how
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3296 * the official MySpaceIM client works, so don't provide that functionality. */
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3297 cid_str = g_strdup_printf("%d", cid);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3298
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3299
19436
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3300 /* Find our account with specified user id, or use first connected account if uid=0. */
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3301 account = NULL;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3302 l = purple_accounts_get_all();
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3303 while (l) {
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3304 if (purple_account_is_connected(l->data) &&
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3305 (uid == 0 || purple_account_get_int(l->data, "uid", 0) == uid)) {
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3306 account = l->data;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3307 break;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3308 }
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3309 l = l->next;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3310 }
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3311
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3312 if (!account) {
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3313 purple_notify_error(NULL, _("myim URL handler"),
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3314 _("No suitable MySpaceIM account could be found to open this myim URL."),
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3315 _("Enable the proper MySpaceIM account and try again."));
19441
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3316 g_free(cid_str);
19436
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3317 return FALSE;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3318 }
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3319
19441
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3320 session = (MsimSession *)account->gc->proto_data;
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3321 g_return_val_if_fail(session != NULL, FALSE);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3322
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3323 /* Lookup userid to username. TODO: push this down, to IM sending/contact
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3324 * adding functions. */
19439
0202145e3465 In msimprpl, fix the msim_uri_handler(). The sendIM and addContact commands
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19437
diff changeset
3325
19436
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3326 /* myim:sendIM?uID=USERID&cID=CONTACTID */
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3327 if (!g_ascii_strcasecmp(cmd, "sendIM")) {
19441
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3328 msim_lookup_user(session, cid_str, (MSIM_USER_LOOKUP_CB)msim_uri_handler_sendIM_cb, NULL);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3329 g_free(cid_str);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3330 return TRUE;
19436
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3331
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3332 /* myim:addContact?uID=USERID&cID=CONTACTID */
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3333 } else if (!g_ascii_strcasecmp(cmd, "addContact")) {
19441
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3334 msim_lookup_user(session, cid_str, (MSIM_USER_LOOKUP_CB)msim_uri_handler_addContact_cb, NULL);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3335 g_free(cid_str);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3336 return TRUE;
19436
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3337 }
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3338
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3339 return FALSE;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3340 }
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3341
19441
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3342 /* TODO: move uid->username resolving to IM sending and buddy adding functions,
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3343 * so that user can manually add or IM by userid and username automatically
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3344 * looked up if possible? */
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3345
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3346 /** Handle a myim:sendIM URI command, after username has been looked up. */
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3347 static void
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3348 msim_uri_handler_sendIM_cb(MsimSession *session, MsimMessage *userinfo, gpointer data)
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3349 {
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3350 PurpleConversation *conv;
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3351 MsimMessage *body;
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3352 gchar *username;
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3353
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3354 body = msim_msg_get_dictionary(userinfo, "body");
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3355 username = msim_msg_get_string(body, "UserName");
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3356 msim_msg_free(body);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3357
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3358 if (!username) {
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3359 guint uid;
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3360
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3361 uid = msim_msg_get_integer(userinfo, "UserID");
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3362 g_return_if_fail(uid != 0);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3363
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3364 username = g_strdup_printf("%d", uid);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3365 }
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3366
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3367
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3368 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, username, session->account);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3369 if (!conv) {
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3370 purple_debug_info("msim_uri_handler", "creating new conversation for %s\n", username);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3371 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, session->account, username);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3372 }
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3373
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3374 /* Just open the window so the user can send an IM. */
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3375 purple_conversation_present(conv);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3376
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3377 g_free(username);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3378 }
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3379
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3380 /** Handle a myim:addContact command, after username has been looked up. */
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3381 static void
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3382 msim_uri_handler_addContact_cb(MsimSession *session, MsimMessage *userinfo, gpointer data)
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3383 {
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3384 MsimMessage *body;
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3385 gchar *username;
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3386
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3387 body = msim_msg_get_dictionary(userinfo, "body");
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3388 username = msim_msg_get_string(body, "UserName");
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3389 msim_msg_free(body);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3390
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3391 if (!username) {
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3392 guint uid;
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3393
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3394 uid = msim_msg_get_integer(userinfo, "UserID");
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3395 g_return_if_fail(uid != 0);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3396
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3397 username = g_strdup_printf("%d", uid);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3398 }
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3399
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3400
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3401 purple_blist_request_add_buddy(session->account, username, _("Buddies"), NULL);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3402
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3403 g_free(username);
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3404 }
bbb205c49228 For myim: (MySpaceIM) URLs, lookup the contact ID into a username before
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19439
diff changeset
3405
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3406 /** Initialize plugin. */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3407 void
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3408 init_plugin(PurplePlugin *plugin)
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3409 {
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3410 #ifdef MSIM_SELF_TEST
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3411 msim_test_all();
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3412 exit(0);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3413 #endif /* MSIM_SELF_TEST */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3414
19436
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3415 PurpleAccountOption *option;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3416 static gboolean initialized = FALSE;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3417
19598
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
3418 #ifdef MSIM_CHECK_NEWER_VERSION
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
3419 /* PROBLEM: MySpace's servers always return Content-Location, and
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
3420 * libpurple redirects to it, infinitely, even though it is the same
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
3421 * location we requested! */
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
3422 purple_util_fetch_url("http://im.myspace.com/nsis/currentversion.txt",
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
3423 FALSE, /* not full URL */
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
3424 "MSIMAutoUpdateAgent", /* user agent */
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
3425 TRUE, /* use HTTP/1.1 */
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
3426 msim_check_newer_version_cb, NULL);
339c7c8c0e08 If MSIM_CHECK_NEWER_VERSION is defined (off by default), run (incomplete)
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19597
diff changeset
3427 #endif
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3428
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3429 /* TODO: default to automatically try different ports. Make the user be
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3430 * able to set the first port to try (like LastConnectedPort in Windows client). */
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3431 option = purple_account_option_string_new(_("Connect server"), "server", MSIM_SERVER);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3432 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3433
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3434 option = purple_account_option_int_new(_("Connect port"), "port", MSIM_PORT);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3435 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3436
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3437 #ifdef MSIM_USER_WANTS_TO_CONFIGURE_STATUS_TEXT
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3438 option = purple_account_option_bool_new(_("Show display name in status text"), "show_display_name", TRUE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3439 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3440
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3441 option = purple_account_option_bool_new(_("Show headline in status text"), "show_headline", TRUE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3442 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3443 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3444
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3445 #ifdef MSIM_USER_WANTS_TO_DISABLE_EMOTICONS
19733
0844b0638f0b The 'Send Emoticons' preferences (which is only configurable if MSIM_USER_WANTS_TO_DISABLE_EMOTICONS is defined) defaults to TRUE when used, a reasonable default. The preference, if MSIM_USER_WANTS_TO_DISABLE_EMOTICONS is defined, should do the same.
Evan Schoenberg <evan.s@dreskin.net>
parents: 19720
diff changeset
3446 option = purple_account_option_bool_new(_("Send emoticons"), "emoticons", TRUE);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3447 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3448 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3449
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3450 #ifdef MSIM_USER_REALLY_CARES_ABOUT_PRECISE_FONT_SIZES
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3451 option = purple_account_option_int_new(_("Screen resolution (dots per inch)"), "dpi", MSIM_DEFAULT_DPI);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3452 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3453
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3454 option = purple_account_option_int_new(_("Base font size (points)"), "base_font_size", MSIM_BASE_FONT_POINT_SIZE);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3455 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3456 #endif
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3457
19436
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3458 /* Code below only runs once. Based on oscar.c's oscar_init(). */
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3459 if (initialized)
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3460 return;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3461
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3462 initialized = TRUE;
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3463
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3464 purple_signal_connect(purple_get_core(), "uri-handler", &initialized,
a62c9b9c4596 Add msim_uri_handler() to handle myim: URLs, sendIM and addContact commands.
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 19435
diff changeset
3465 PURPLE_CALLBACK(msim_uri_handler), NULL);
19242
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3466 }
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3467
f60192409e7f merge of '0ae78c5d891099ade8e599dc2087ff9411b98d5f'
Jeffrey Connelly <jaconnel@calpoly.edu>
parents: 18918 18917
diff changeset
3468 PURPLE_INIT_PLUGIN(myspace, init_plugin, info);