Tue, 13 Apr 2004 04:08:22 +0000
[gaim-migrate @ 9398]
Added a patch by shx to clean up the message-handling code and split the
command stuff from it, among a few other things. Also, I fixed a crash in
message parsing, which I think may close a couple bug reports.
committer: Christian Hammond <chipx86@chipx86.com>
| 4542 | 1 | /** |
| 2 | * @file switchboard.c MSN switchboard functions | |
| 3 | * | |
| 4 | * gaim | |
| 5 | * | |
| 6 | * Copyright (C) 2003, Christian Hammond <chipx86@gnupdate.org> | |
|
6668
15875d5cecc4
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
7 | * |
| 4542 | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
8207
62f5bc66e39f
[gaim-migrate @ 8930]
Christian Hammond <chipx86@chipx86.com>
parents:
7639
diff
changeset
|
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 4542 | 21 | */ |
| 22 | #include "msn.h" | |
|
6786
096ebddea1f3
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
23 | #include "msnslp.h" |
|
5626
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
24 | #include "prefs.h" |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
25 | #include "switchboard.h" |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
26 | #include "utils.h" |
| 4542 | 27 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
28 | static GHashTable *switchboard_commands = NULL; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
29 | static GHashTable *switchboard_msg_types = NULL; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
30 | |
|
5316
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
31 | /************************************************************************** |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
32 | * Utility functions |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
33 | **************************************************************************/ |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
34 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
35 | send_clientcaps(MsnSwitchBoard *swboard) |
|
5316
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
36 | { |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
37 | MsnMessage *msg; |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
38 | |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
39 | msg = msn_message_new(); |
|
5475
a2f856cac665
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
40 | msn_message_set_content_type(msg, "text/x-clientcaps"); |
|
5316
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
41 | msn_message_set_charset(msg, NULL); |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
42 | msn_message_set_attr(msg, "User-Agent", NULL); |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
43 | msn_message_set_body(msg, MSN_CLIENTINFO); |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
44 | |
|
6827
df4411142ece
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
45 | if (!msn_switchboard_send_msg(swboard, msg)) |
|
df4411142ece
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
46 | { |
|
6826
986589449e69
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6802
diff
changeset
|
47 | gaim_debug_warning("msn", |
|
986589449e69
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6802
diff
changeset
|
48 | "Unable to send clientcaps. " |
|
986589449e69
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6802
diff
changeset
|
49 | "Disconnecting from switchboard.\n"); |
|
5316
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
50 | msn_switchboard_destroy(swboard); |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
51 | |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
52 | msn_message_destroy(msg); |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
53 | |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
54 | return FALSE; |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
55 | } |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
56 | |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
57 | msn_message_destroy(msg); |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
58 | |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
59 | return TRUE; |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
60 | } |
|
4546
d14ad00fe294
[gaim-migrate @ 4825]
Herman Bloggs <herman@bluedigits.com>
parents:
4542
diff
changeset
|
61 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
62 | /************************************************************************** |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
63 | * Catch-all commands |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
64 | **************************************************************************/ |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
65 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
66 | blank_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
67 | size_t param_count) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
68 | { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
69 | return TRUE; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
70 | } |
|
4546
d14ad00fe294
[gaim-migrate @ 4825]
Herman Bloggs <herman@bluedigits.com>
parents:
4542
diff
changeset
|
71 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
72 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
73 | unknown_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
74 | size_t param_count) |
| 4542 | 75 | { |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
76 | gaim_debug(GAIM_DEBUG_ERROR, "msg", |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
77 | "Handled switchboard message: %s\n", command); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
78 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
79 | return FALSE; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
80 | } |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
81 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
82 | /************************************************************************** |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
83 | * Switchboard Commands |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
84 | **************************************************************************/ |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
85 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
86 | ans_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
87 | size_t param_count) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
88 | { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
89 | MsnSwitchBoard *swboard = servconn->data; |
|
6800
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
90 | MsnSession *session = servconn->session; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
91 | |
|
7475
987384816492
[gaim-migrate @ 8088]
Mark Doliner <markdoliner@pidgin.im>
parents:
7288
diff
changeset
|
92 | /*send_clientcaps(swboard);*/ |
|
6800
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
93 | |
|
7594
43f52fd49362
[gaim-migrate @ 8212]
Christian Hammond <chipx86@chipx86.com>
parents:
7591
diff
changeset
|
94 | if (0 && session->protocol_ver >= 9) |
|
6800
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
95 | { |
|
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
96 | MsnUser *local_user, *remote_user; |
|
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
97 | |
|
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
98 | remote_user = msn_user_new(session, |
|
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
99 | msn_user_get_passport(msn_switchboard_get_user(swboard)), |
|
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
100 | NULL); |
|
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
101 | local_user = msn_user_new(session, |
|
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
102 | gaim_account_get_username(session->account), |
|
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
103 | NULL); |
|
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
104 | |
|
6831
05de70e7b430
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
105 | if (msn_user_get_object(remote_user) != NULL) |
|
05de70e7b430
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
106 | { |
|
05de70e7b430
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
107 | swboard->slp_session = msn_slp_session_new(swboard, TRUE); |
|
6800
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
108 | |
|
6831
05de70e7b430
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
109 | msn_slp_session_request_user_display(swboard->slp_session, |
|
05de70e7b430
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
110 | local_user, remote_user, |
|
05de70e7b430
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
111 | msn_user_get_object(remote_user)); |
|
05de70e7b430
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
112 | } |
|
6800
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
113 | } |
|
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
114 | |
|
6826
986589449e69
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6802
diff
changeset
|
115 | return TRUE; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
116 | } |
| 4542 | 117 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
118 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
119 | bye_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
120 | size_t param_count) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
121 | { |
|
6640
007eb21016b4
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6622
diff
changeset
|
122 | GaimAccount *account = servconn->session->account; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
123 | MsnSwitchBoard *swboard = servconn->data; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
124 | const char *user = params[0]; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
125 | |
|
5351
cb12105b532b
[gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
5342
diff
changeset
|
126 | if (swboard->hidden) |
|
cb12105b532b
[gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
5342
diff
changeset
|
127 | return TRUE; |
|
cb12105b532b
[gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
5342
diff
changeset
|
128 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
129 | if (swboard->chat != NULL) |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
130 | gaim_conv_chat_remove_user(GAIM_CONV_CHAT(swboard->chat), user, NULL); |
|
8372
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
131 | else |
|
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
132 | { |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
133 | const char *username; |
| 5679 | 134 | GaimConversation *conv; |
| 6695 | 135 | GaimBuddy *b; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
136 | char buf[MSN_BUF_LEN]; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
137 | |
|
6640
007eb21016b4
[gaim-migrate @ 7165]
Christian Hammond <chipx86@chipx86.com>
parents:
6622
diff
changeset
|
138 | if ((b = gaim_find_buddy(account, user)) != NULL) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
139 | username = gaim_get_buddy_alias(b); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
140 | else |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
141 | username = user; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
142 | |
|
5626
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
143 | *buf = '\0'; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
144 | |
|
8372
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
145 | if (param_count == 2 && atoi(params[1]) == 1) |
|
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
146 | { |
|
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
147 | if (gaim_prefs_get_bool("/plugins/prpl/msn/conv_timeout_notice")) |
|
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
148 | { |
|
5626
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
149 | g_snprintf(buf, sizeof(buf), |
|
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
150 | _("The conversation has become inactive " |
|
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
151 | "and timed out.")); |
|
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
152 | } |
|
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
153 | } |
|
8372
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
154 | else |
|
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
155 | { |
|
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
156 | if (gaim_prefs_get_bool("/plugins/prpl/msn/conv_close_notice")) |
|
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
157 | { |
|
5626
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
158 | g_snprintf(buf, sizeof(buf), |
|
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
159 | _("%s has closed the conversation window."), |
|
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
160 | username); |
|
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
161 | } |
|
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
162 | } |
|
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
163 | |
|
8372
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
164 | if (*buf != '\0' && |
|
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
165 | (conv = gaim_find_conversation_with_account(user, account)) != NULL) |
|
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
166 | { |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6917
diff
changeset
|
167 | gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
168 | time(NULL)); |
|
5626
6e6fc61ea2db
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
169 | } |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
170 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
171 | msn_switchboard_destroy(swboard); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
172 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
173 | return FALSE; |
| 4542 | 174 | } |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
175 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
176 | return TRUE; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
177 | } |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
178 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
179 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
180 | iro_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
181 | size_t param_count) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
182 | { |
|
5566
7ebd31a6f5da
[gaim-migrate @ 5968]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
183 | GaimAccount *account = servconn->session->account; |
|
7ebd31a6f5da
[gaim-migrate @ 5968]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
184 | GaimConnection *gc = account->gc; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
185 | MsnSwitchBoard *swboard = servconn->data; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
186 | |
|
6148
e3e81ed229c2
[gaim-migrate @ 6622]
Christian Hammond <chipx86@chipx86.com>
parents:
6028
diff
changeset
|
187 | swboard->total_users = atoi(params[2]) + 1; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
188 | |
|
6148
e3e81ed229c2
[gaim-migrate @ 6622]
Christian Hammond <chipx86@chipx86.com>
parents:
6028
diff
changeset
|
189 | if (swboard->total_users > 2) { |
|
6025
b6a61196105d
[gaim-migrate @ 6475]
Christian Hammond <chipx86@chipx86.com>
parents:
6022
diff
changeset
|
190 | if (swboard->chat == NULL) { |
|
6026
b11d9f2fd725
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
191 | GaimConversation *conv; |
|
b11d9f2fd725
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
192 | |
|
8372
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
193 | conv = gaim_find_conversation_with_account( |
|
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
194 | msn_user_get_passport(swboard->user), account); |
|
6026
b11d9f2fd725
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
195 | |
| 8499 | 196 | servconn->session->last_chat_id++; |
| 197 | swboard->chat_id = servconn->session->last_chat_id; | |
| 198 | swboard->chat = serv_got_joined_chat(gc, swboard->chat_id, | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
199 | "MSN Chat"); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
200 | |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
201 | gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->chat), |
|
6025
b6a61196105d
[gaim-migrate @ 6475]
Christian Hammond <chipx86@chipx86.com>
parents:
6022
diff
changeset
|
202 | gaim_account_get_username(account), NULL); |
|
6026
b11d9f2fd725
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
203 | |
|
b11d9f2fd725
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
204 | gaim_conversation_destroy(conv); |
|
6025
b6a61196105d
[gaim-migrate @ 6475]
Christian Hammond <chipx86@chipx86.com>
parents:
6022
diff
changeset
|
205 | } |
|
b6a61196105d
[gaim-migrate @ 6475]
Christian Hammond <chipx86@chipx86.com>
parents:
6022
diff
changeset
|
206 | |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
207 | gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->chat), params[3], NULL); |
| 4542 | 208 | } |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
209 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
210 | return TRUE; |
| 4542 | 211 | } |
| 212 | ||
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
213 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
214 | joi_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
215 | size_t param_count) |
| 4542 | 216 | { |
|
5566
7ebd31a6f5da
[gaim-migrate @ 5968]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
217 | GaimAccount *account = servconn->session->account; |
|
7ebd31a6f5da
[gaim-migrate @ 5968]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
218 | GaimConnection *gc = account->gc; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
219 | MsnSwitchBoard *swboard = servconn->data; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
220 | const char *passport; |
| 4542 | 221 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
222 | passport = params[0]; |
| 4542 | 223 | |
|
6148
e3e81ed229c2
[gaim-migrate @ 6622]
Christian Hammond <chipx86@chipx86.com>
parents:
6028
diff
changeset
|
224 | if (swboard->total_users == 2 && swboard->chat == NULL) { |
|
6026
b11d9f2fd725
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
225 | GaimConversation *conv; |
|
b11d9f2fd725
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
226 | |
|
6831
05de70e7b430
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
227 | conv = gaim_find_conversation_with_account( |
|
05de70e7b430
[gaim-migrate @ 7376]
Christian Hammond <chipx86@chipx86.com>
parents:
6827
diff
changeset
|
228 | msn_user_get_passport(swboard->user), account); |
|
6026
b11d9f2fd725
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
229 | |
| 8499 | 230 | servconn->session->last_chat_id++; |
| 231 | swboard->chat_id = servconn->session->last_chat_id; | |
| 232 | swboard->chat = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat"); | |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
233 | gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->chat), |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
234 | msn_user_get_passport(swboard->user), NULL); |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
235 | gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->chat), |
|
6025
b6a61196105d
[gaim-migrate @ 6475]
Christian Hammond <chipx86@chipx86.com>
parents:
6022
diff
changeset
|
236 | gaim_account_get_username(account), NULL); |
| 4542 | 237 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
238 | msn_user_unref(swboard->user); |
|
6026
b11d9f2fd725
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
239 | |
|
b11d9f2fd725
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
240 | gaim_conversation_destroy(conv); |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
241 | } |
| 4542 | 242 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
243 | if (swboard->chat != NULL) |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
244 | gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->chat), passport, NULL); |
| 4542 | 245 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
246 | swboard->total_users++; |
| 4542 | 247 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
248 | while (servconn->txqueue) { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
249 | char *buf = servconn->txqueue->data; |
| 4542 | 250 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
251 | servconn->txqueue = g_slist_remove(servconn->txqueue, buf); |
| 4542 | 252 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
253 | if (msn_servconn_write(swboard->servconn, buf, strlen(buf)) < 0) { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
254 | msn_switchboard_destroy(swboard); |
| 4542 | 255 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
256 | return FALSE; |
| 4542 | 257 | } |
| 258 | } | |
| 259 | ||
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
260 | return send_clientcaps(swboard); |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
261 | } |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
262 | |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
263 | static void |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
264 | msg_cmd_post(MsnServConn *servconn, char *payload, size_t len) |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
265 | { |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
266 | MsnMessage *msg = msn_message_new(); |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
267 | |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
268 | msg->passport = servconn->msg_passport; |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
269 | |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
270 | msn_message_parse_payload(msg, payload, len); |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
271 | |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
272 | msn_servconn_process_message(servconn, msg); |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
273 | |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
274 | msn_message_destroy(msg); |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
275 | } |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
276 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
277 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
278 | msg_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
279 | size_t param_count) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
280 | { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
281 | gaim_debug(GAIM_DEBUG_INFO, "msn", "Found message. Parsing.\n"); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
282 | |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
283 | servconn->payload_cb = msg_cmd_post; |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
284 | servconn->payload_len = atoi(params[2]); |
|
6802
aed1ec5fc336
[gaim-migrate @ 7342]
Christian Hammond <chipx86@chipx86.com>
parents:
6800
diff
changeset
|
285 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
286 | servconn->msg_passport = g_strdup(params[0]); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
287 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
288 | return TRUE; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
289 | } |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
290 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
291 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
292 | nak_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
293 | size_t param_count) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
294 | { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
295 | /* |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
296 | * TODO: Investigate this, as it seems to occur frequently with |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
297 | * the old prpl. |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
298 | */ |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5351
diff
changeset
|
299 | gaim_notify_error(servconn->session->account->gc, NULL, |
|
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5351
diff
changeset
|
300 | _("An MSN message may not have been received."), NULL); |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
301 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
302 | return TRUE; |
| 4542 | 303 | } |
| 304 | ||
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
305 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
306 | out_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
307 | size_t param_count) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
308 | { |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5506
diff
changeset
|
309 | GaimConnection *gc = servconn->session->account->gc; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
310 | MsnSwitchBoard *swboard = servconn->data; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
311 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
312 | if (swboard->chat != NULL) |
| 8499 | 313 | { |
| 314 | serv_got_chat_left(gc, | |
| 315 | gaim_conv_chat_get_id(GAIM_CONV_CHAT(swboard->chat))); | |
| 316 | } | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
317 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
318 | msn_switchboard_destroy(swboard); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
319 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
320 | return FALSE; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
321 | } |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
322 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
323 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
324 | usr_cmd(MsnServConn *servconn, const char *command, const char **params, |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
325 | size_t param_count) |
| 4542 | 326 | { |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
327 | MsnSwitchBoard *swboard = servconn->data; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
328 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
329 | if (!msn_switchboard_send_command(swboard, "CAL", |
| 8499 | 330 | msn_user_get_passport(swboard->user))) |
| 331 | { | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
332 | msn_switchboard_destroy(swboard); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
333 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
334 | return FALSE; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
335 | } |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
336 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
337 | return TRUE; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
338 | } |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
339 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
340 | /************************************************************************** |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
341 | * Message Types |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
342 | **************************************************************************/ |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
343 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
344 | plain_msg(MsnServConn *servconn, MsnMessage *msg) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
345 | { |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5506
diff
changeset
|
346 | GaimConnection *gc = servconn->session->account->gc; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
347 | MsnSwitchBoard *swboard = servconn->data; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
348 | char *body; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
349 | const char *value; |
| 4542 | 350 | |
| 8442 | 351 | body = gaim_escape_html(msn_message_get_body(msg)); |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
352 | |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
353 | if (!strcmp(msg->passport, "messenger@microsoft.com") && |
|
6668
15875d5cecc4
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
354 | strstr(body, "immediate security update")) |
|
15875d5cecc4
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
355 | { |
|
15875d5cecc4
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
356 | g_free(body); |
|
15875d5cecc4
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
357 | |
|
15875d5cecc4
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
358 | return TRUE; |
|
15875d5cecc4
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
359 | } |
|
15875d5cecc4
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
360 | |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
361 | #if 0 |
|
5454
5263b77f0ad9
[gaim-migrate @ 5842]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
362 | gaim_debug(GAIM_DEBUG_INFO, "msn", "Checking User-Agent...\n"); |
|
5263b77f0ad9
[gaim-migrate @ 5842]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
363 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
364 | if ((value = msn_message_get_attr(msg, "User-Agent")) != NULL) { |
|
5454
5263b77f0ad9
[gaim-migrate @ 5842]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
365 | gaim_debug(GAIM_DEBUG_MISC, "msn", "value = '%s'\n", value); |
| 4542 | 366 | } |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
367 | #endif |
| 4542 | 368 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
369 | if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL) { |
|
6358
c3347685b9ef
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
370 | char *pre_format, *post_format; |
|
c3347685b9ef
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
371 | |
|
c3347685b9ef
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
372 | msn_parse_format(value, &pre_format, &post_format); |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
373 | |
|
6358
c3347685b9ef
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
374 | body = g_strdup_printf("%s%s%s", pre_format, body, post_format); |
|
c3347685b9ef
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
375 | |
|
c3347685b9ef
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
376 | g_free(pre_format); |
|
c3347685b9ef
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
377 | g_free(post_format); |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
378 | } |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
379 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
380 | if (swboard->chat != NULL) |
| 8499 | 381 | { |
| 382 | serv_got_chat_in(gc, | |
| 383 | gaim_conv_chat_get_id(GAIM_CONV_CHAT(swboard->chat)), | |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
384 | msg->passport, 0, body, time(NULL)); |
| 8499 | 385 | } |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
386 | else |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
387 | serv_got_im(gc, msg->passport, body, 0, time(NULL)); |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
388 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
389 | g_free(body); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
390 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
391 | return TRUE; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
392 | } |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
393 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
394 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
395 | control_msg(MsnServConn *servconn, MsnMessage *msg) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
396 | { |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5506
diff
changeset
|
397 | GaimConnection *gc = servconn->session->account->gc; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
398 | MsnSwitchBoard *swboard = servconn->data; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
399 | const char *value; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
400 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
401 | if (swboard->chat == NULL && |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
402 | (value = msn_message_get_attr(msg, "TypingUser")) != NULL) { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
403 | |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
404 | serv_got_typing(gc, msg->passport, MSN_TYPING_RECV_TIMEOUT, |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5793
diff
changeset
|
405 | GAIM_TYPING); |
| 4542 | 406 | } |
| 407 | ||
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
408 | return TRUE; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
409 | } |
| 4542 | 410 | |
|
5316
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
411 | static gboolean |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
412 | clientcaps_msg(MsnServConn *servconn, MsnMessage *msg) |
|
5316
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
413 | { |
|
6845
3706464f79f7
[gaim-migrate @ 7390]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
414 | #if 0 |
|
5316
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
415 | MsnSession *session = servconn->session; |
|
5351
cb12105b532b
[gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
5342
diff
changeset
|
416 | MsnSwitchBoard *swboard = servconn->data; |
|
5316
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
417 | MsnUser *user; |
|
5475
a2f856cac665
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
418 | GHashTable *clientcaps; |
|
5351
cb12105b532b
[gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
5342
diff
changeset
|
419 | const char *value; |
|
5316
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
420 | |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
421 | user = msn_user_new(session, msg->passport, NULL); |
|
5316
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
422 | |
|
5475
a2f856cac665
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
423 | clientcaps = msn_message_get_hashtable_from_body(msg); |
|
6845
3706464f79f7
[gaim-migrate @ 7390]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
424 | #endif |
|
5351
cb12105b532b
[gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
5342
diff
changeset
|
425 | |
|
5316
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
426 | return TRUE; |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
427 | } |
|
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
428 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
429 | /************************************************************************** |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
430 | * Connect stuff |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
431 | **************************************************************************/ |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
432 | static gboolean |
|
8583
56f69df8f12f
[gaim-migrate @ 9333]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8499
diff
changeset
|
433 | connect_cb(MsnServConn *servconn) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
434 | { |
|
5566
7ebd31a6f5da
[gaim-migrate @ 5968]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
435 | GaimAccount *account = servconn->session->account; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
436 | MsnSwitchBoard *swboard = servconn->data; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
437 | char outparams[MSN_BUF_LEN]; |
| 4542 | 438 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
439 | swboard->in_use = TRUE; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
440 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
441 | gaim_debug(GAIM_DEBUG_INFO, "msn", "Connecting to switchboard...\n"); |
| 4542 | 442 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
443 | if (msn_switchboard_is_invited(swboard)) { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
444 | g_snprintf(outparams, sizeof(outparams), "%s %s %s", |
|
5566
7ebd31a6f5da
[gaim-migrate @ 5968]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
445 | gaim_account_get_username(account), |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
446 | swboard->auth_key, swboard->session_id); |
| 4542 | 447 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
448 | if (!msn_switchboard_send_command(swboard, "ANS", outparams)) { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
449 | msn_switchboard_destroy(swboard); |
| 4542 | 450 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
451 | return FALSE; |
| 4542 | 452 | } |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
453 | } |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
454 | else { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
455 | g_snprintf(outparams, sizeof(outparams), "%s %s", |
|
5566
7ebd31a6f5da
[gaim-migrate @ 5968]
Christian Hammond <chipx86@chipx86.com>
parents:
5564
diff
changeset
|
456 | gaim_account_get_username(account), swboard->auth_key); |
| 4542 | 457 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
458 | if (!msn_switchboard_send_command(swboard, "USR", outparams)) { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
459 | msn_switchboard_destroy(swboard); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
460 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
461 | return FALSE; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
462 | } |
| 4542 | 463 | } |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
464 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
465 | return TRUE; |
| 4542 | 466 | } |
| 467 | ||
| 468 | static void | |
|
8583
56f69df8f12f
[gaim-migrate @ 9333]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8499
diff
changeset
|
469 | disconnect_cb(MsnServConn *servconn) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
470 | { |
|
8583
56f69df8f12f
[gaim-migrate @ 9333]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8499
diff
changeset
|
471 | MsnSwitchBoard *swboard; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
472 | |
|
8583
56f69df8f12f
[gaim-migrate @ 9333]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8499
diff
changeset
|
473 | swboard = servconn->data; |
|
56f69df8f12f
[gaim-migrate @ 9333]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8499
diff
changeset
|
474 | if (!swboard->destroying) |
|
56f69df8f12f
[gaim-migrate @ 9333]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8499
diff
changeset
|
475 | msn_switchboard_destroy(swboard); |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
476 | } |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
477 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
478 | MsnSwitchBoard * |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
479 | msn_switchboard_new(MsnSession *session) |
| 4542 | 480 | { |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
481 | MsnSwitchBoard *swboard; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
482 | MsnServConn *servconn; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
483 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
484 | g_return_val_if_fail(session != NULL, NULL); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
485 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
486 | swboard = g_new0(MsnSwitchBoard, 1); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
487 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
488 | swboard->servconn = servconn = msn_servconn_new(session); |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
489 | msn_servconn_set_connect_cb(servconn, connect_cb); |
|
8583
56f69df8f12f
[gaim-migrate @ 9333]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8499
diff
changeset
|
490 | msn_servconn_set_disconnect_cb(servconn, disconnect_cb); |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
491 | |
|
7288
486e8b44a14b
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
7118
diff
changeset
|
492 | if (session->http_method) |
|
486e8b44a14b
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
7118
diff
changeset
|
493 | swboard->servconn->http_data->server_type = "SB"; |
|
486e8b44a14b
[gaim-migrate @ 7869]
Christian Hammond <chipx86@chipx86.com>
parents:
7118
diff
changeset
|
494 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
495 | servconn->data = swboard; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
496 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
497 | session->switches = g_list_append(session->switches, swboard); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
498 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
499 | if (switchboard_commands == NULL) { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
500 | /* Register the command callbacks. */ |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
501 | msn_servconn_register_command(servconn, "ACK", blank_cmd); |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
502 | msn_servconn_register_command(servconn, "ANS", ans_cmd); |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
503 | msn_servconn_register_command(servconn, "BYE", bye_cmd); |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
504 | msn_servconn_register_command(servconn, "CAL", blank_cmd); |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
505 | msn_servconn_register_command(servconn, "IRO", iro_cmd); |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
506 | msn_servconn_register_command(servconn, "JOI", joi_cmd); |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
507 | msn_servconn_register_command(servconn, "MSG", msg_cmd); |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
508 | msn_servconn_register_command(servconn, "NAK", nak_cmd); |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
509 | msn_servconn_register_command(servconn, "NLN", blank_cmd); |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
510 | msn_servconn_register_command(servconn, "OUT", out_cmd); |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
511 | msn_servconn_register_command(servconn, "USR", usr_cmd); |
|
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
512 | msn_servconn_register_command(servconn, "_unknown_",unknown_cmd); |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
513 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
514 | /* Register the message type callbacks. */ |
|
5793
28d84d5e5663
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
515 | msn_servconn_register_msg_type(servconn, "text/plain",plain_msg); |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
516 | msn_servconn_register_msg_type(servconn, "text/x-msmsgscontrol", |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
517 | control_msg); |
|
5475
a2f856cac665
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
518 | msn_servconn_register_msg_type(servconn, "text/x-clientcaps", |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
519 | clientcaps_msg); |
|
5316
ec9cbe50e70c
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
520 | msn_servconn_register_msg_type(servconn, "text/x-clientinfo", |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
521 | clientcaps_msg); |
|
7639
a973497d5967
[gaim-migrate @ 8281]
Christian Hammond <chipx86@chipx86.com>
parents:
7594
diff
changeset
|
522 | #if 0 |
|
6786
096ebddea1f3
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
523 | msn_servconn_register_msg_type(servconn, "application/x-msnmsgrp2p", |
|
096ebddea1f3
[gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
524 | msn_p2p_msg); |
|
7639
a973497d5967
[gaim-migrate @ 8281]
Christian Hammond <chipx86@chipx86.com>
parents:
7594
diff
changeset
|
525 | #endif |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
526 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
527 | /* Save these for future use. */ |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
528 | switchboard_commands = servconn->commands; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
529 | switchboard_msg_types = servconn->msg_types; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
530 | } |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
531 | else { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
532 | g_hash_table_destroy(servconn->commands); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
533 | g_hash_table_destroy(servconn->msg_types); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
534 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
535 | servconn->commands = switchboard_commands; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
536 | servconn->msg_types = switchboard_msg_types; |
| 4542 | 537 | } |
| 538 | ||
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
539 | return swboard; |
| 4542 | 540 | } |
| 541 | ||
| 542 | void | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
543 | msn_switchboard_destroy(MsnSwitchBoard *swboard) |
| 4542 | 544 | { |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
545 | MsnSession *session; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
546 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
547 | g_return_if_fail(swboard != NULL); |
|
8583
56f69df8f12f
[gaim-migrate @ 9333]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8499
diff
changeset
|
548 | g_return_if_fail(!swboard->destroying); |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
549 | |
|
8583
56f69df8f12f
[gaim-migrate @ 9333]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8499
diff
changeset
|
550 | swboard->destroying = TRUE; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
551 | session = swboard->servconn->session; |
| 4542 | 552 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
553 | if (swboard->servconn->connected) |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
554 | msn_switchboard_disconnect(swboard); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
555 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
556 | if (swboard->user != NULL) |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
557 | msn_user_unref(swboard->user); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
558 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
559 | if (swboard->auth_key != NULL) |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
560 | g_free(swboard->auth_key); |
| 4542 | 561 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
562 | if (swboard->session_id != NULL) |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
563 | g_free(swboard->session_id); |
| 4542 | 564 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
565 | session->switches = g_list_remove(session->switches, swboard); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
566 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
567 | msn_servconn_destroy(swboard->servconn); |
| 4542 | 568 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
569 | g_free(swboard); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
570 | } |
| 4542 | 571 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
572 | void |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
573 | msn_switchboard_set_user(MsnSwitchBoard *swboard, MsnUser *user) |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
574 | { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
575 | g_return_if_fail(swboard != NULL); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
576 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
577 | swboard->user = user; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
578 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
579 | msn_user_ref(user); |
| 4542 | 580 | } |
| 581 | ||
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
582 | MsnUser * |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
583 | msn_switchboard_get_user(const MsnSwitchBoard *swboard) |
| 4542 | 584 | { |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
585 | g_return_val_if_fail(swboard != NULL, NULL); |
| 4542 | 586 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
587 | return swboard->user; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
588 | } |
| 4542 | 589 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
590 | void |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
591 | msn_switchboard_set_auth_key(MsnSwitchBoard *swboard, const char *key) |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
592 | { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
593 | g_return_if_fail(swboard != NULL); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
594 | g_return_if_fail(key != NULL); |
| 4542 | 595 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
596 | swboard->auth_key = g_strdup(key); |
| 4542 | 597 | } |
| 598 | ||
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
599 | const char * |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
600 | msn_switchboard_get_auth_key(const MsnSwitchBoard *swboard) |
| 4542 | 601 | { |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
602 | g_return_val_if_fail(swboard != NULL, NULL); |
| 4542 | 603 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
604 | return swboard->auth_key; |
| 4542 | 605 | } |
| 606 | ||
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
607 | void |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
608 | msn_switchboard_set_session_id(MsnSwitchBoard *swboard, const char *id) |
| 4542 | 609 | { |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
610 | g_return_if_fail(swboard != NULL); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
611 | g_return_if_fail(id != NULL); |
| 4542 | 612 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
613 | if (swboard->session_id != NULL) |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
614 | g_free(swboard->session_id); |
| 4542 | 615 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
616 | swboard->session_id = g_strdup(id); |
| 4542 | 617 | } |
| 618 | ||
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
619 | const char * |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
620 | msn_switchboard_get_session_id(const MsnSwitchBoard *swboard) |
| 4542 | 621 | { |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
622 | g_return_val_if_fail(swboard != NULL, NULL); |
| 4542 | 623 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
624 | return swboard->session_id; |
| 4542 | 625 | } |
| 626 | ||
| 627 | void | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
628 | msn_switchboard_set_invited(MsnSwitchBoard *swboard, gboolean invited) |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
629 | { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
630 | g_return_if_fail(swboard != NULL); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
631 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
632 | swboard->invited = invited; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
633 | } |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
634 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
635 | gboolean |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
636 | msn_switchboard_is_invited(const MsnSwitchBoard *swboard) |
| 4542 | 637 | { |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
638 | g_return_val_if_fail(swboard != NULL, FALSE); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
639 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
640 | return swboard->invited; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
641 | } |
| 4542 | 642 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
643 | gboolean |
|
8583
56f69df8f12f
[gaim-migrate @ 9333]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8499
diff
changeset
|
644 | msn_switchboard_connect(MsnSwitchBoard *swboard, const char *host, int port) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
645 | { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
646 | g_return_val_if_fail(swboard != NULL, FALSE); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
647 | |
|
8583
56f69df8f12f
[gaim-migrate @ 9333]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8499
diff
changeset
|
648 | if (msn_servconn_connect(swboard->servconn, host, port)) |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
649 | swboard->in_use = TRUE; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
650 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
651 | return swboard->in_use; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
652 | } |
| 4542 | 653 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
654 | void |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
655 | msn_switchboard_disconnect(MsnSwitchBoard *swboard) |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
656 | { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
657 | g_return_if_fail(swboard != NULL); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
658 | g_return_if_fail(swboard->servconn->connected); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
659 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
660 | msn_servconn_disconnect(swboard->servconn); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
661 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
662 | swboard->in_use = FALSE; |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
663 | } |
| 4542 | 664 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
665 | gboolean |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
666 | msn_switchboard_send_msg(MsnSwitchBoard *swboard, MsnMessage *msg) |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
667 | { |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
668 | char *buf; |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
669 | char *payload; |
|
6826
986589449e69
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6802
diff
changeset
|
670 | size_t len; |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
671 | size_t payload_len; |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
672 | int ret; |
|
8386
5b9e02f4c03d
[gaim-migrate @ 9114]
Mark Doliner <markdoliner@pidgin.im>
parents:
8372
diff
changeset
|
673 | #if 0 |
|
6827
df4411142ece
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
674 | FILE *fp; |
|
8386
5b9e02f4c03d
[gaim-migrate @ 9114]
Mark Doliner <markdoliner@pidgin.im>
parents:
8372
diff
changeset
|
675 | #endif |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
676 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
677 | g_return_val_if_fail(swboard != NULL, FALSE); |
|
6800
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
678 | g_return_val_if_fail(msg != NULL, FALSE); |
| 4542 | 679 | |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
680 | buf = g_strdup_printf("MSG %d %c %d\r\n", ++swboard->trId, |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
681 | msn_message_get_flag(msg), (int)msg->size); |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
682 | |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
683 | len = strlen(buf); |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
684 | |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
685 | payload = msn_message_gen_payload(msg, &payload_len); |
| 4542 | 686 | |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
687 | if (payload != NULL) |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
688 | { |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
689 | buf = g_realloc(buf, len + payload_len + 1); |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
690 | memcpy(buf + len, payload, payload_len); |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
691 | len += payload_len; |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
692 | buf[len] = 0; |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
693 | } |
|
6800
8f99c220b503
[gaim-migrate @ 7340]
Christian Hammond <chipx86@chipx86.com>
parents:
6786
diff
changeset
|
694 | |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
695 | if (swboard->servconn->txqueue != NULL || !swboard->in_use) |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8583
diff
changeset
|
696 | { |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
697 | gaim_debug(GAIM_DEBUG_INFO, "msn", "Appending message to queue.\n"); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
698 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
699 | swboard->servconn->txqueue = |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
700 | g_slist_append(swboard->servconn->txqueue, buf); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
701 | |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
702 | return TRUE; |
| 4542 | 703 | } |
| 704 | ||
|
6826
986589449e69
[gaim-migrate @ 7371]
Christian Hammond <chipx86@chipx86.com>
parents:
6802
diff
changeset
|
705 | ret = msn_servconn_write(swboard->servconn, buf, len); |
|
6917
ac9da59eb116
[gaim-migrate @ 7464]
Christian Hammond <chipx86@chipx86.com>
parents:
6893
diff
changeset
|
706 | |
|
ac9da59eb116
[gaim-migrate @ 7464]
Christian Hammond <chipx86@chipx86.com>
parents:
6893
diff
changeset
|
707 | #if 0 |
|
8372
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
708 | /* Windows doesn't like Unix paths */ |
|
c861368e51d0
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
709 | fp = fopen("/tmp/msn-msg", "ab"); |
|
6827
df4411142ece
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
710 | fwrite(buf, 1, len, fp); |
|
df4411142ece
[gaim-migrate @ 7372]
Christian Hammond <chipx86@chipx86.com>
parents:
6826
diff
changeset
|
711 | fclose(fp); |
|
6893
35cce86fa37e
[gaim-migrate @ 7440]
Herman Bloggs <herman@bluedigits.com>
parents:
6891
diff
changeset
|
712 | #endif |
|
6917
ac9da59eb116
[gaim-migrate @ 7464]
Christian Hammond <chipx86@chipx86.com>
parents:
6893
diff
changeset
|
713 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
714 | g_free(buf); |
| 4542 | 715 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
716 | return (ret > 0); |
| 4542 | 717 | } |
| 718 | ||
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
719 | gboolean |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
720 | msn_switchboard_send_command(MsnSwitchBoard *swboard, const char *command, |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
721 | const char *params) |
| 4542 | 722 | { |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
723 | char buf[MSN_BUF_LEN]; |
| 4542 | 724 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
725 | g_return_val_if_fail(swboard != NULL, FALSE); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
726 | g_return_val_if_fail(command != NULL, FALSE); |
| 4542 | 727 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
728 | if (params == NULL) |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
729 | g_snprintf(buf, sizeof(buf), "%s %u\r\n", command, |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
730 | ++swboard->trId); |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
731 | else |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
732 | g_snprintf(buf, sizeof(buf), "%s %u %s\r\n", |
|
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
733 | command, ++swboard->trId, params); |
| 4542 | 734 | |
|
5309
3178acad1449
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
735 | return (msn_servconn_write(swboard->servconn, buf, strlen(buf)) > 0); |
| 4542 | 736 | } |