annotate src/protocols/msn/msn.c @ 4249:9c7fcb211886

[gaim-migrate @ 4499] If anyone is curious, the commit before this fixed a bug which didn't allow you to delete AIM or ICQ people from a deny list. They'll show up when you sign back online, and will be deleteable now. This is a patch from the good Mr. McQueen. "Twofold attack: 1) Make sure all the callback functions don't throw a mental if the gc the dialog was asking about has disappeared. Make sure the functions still free up the data structs as necessary in this case. 2) When setting up a ask dialog, plugins (including prpls) pass in their handle. The ask dialog struct gets kept in a slist. When unloading a plugin or prpl, Gaim checks the handle against the list, and sends a cancel-type message for any outstanding dialogs. Should avoid crashes from non-modal ask dialogs lying around." Yeah, so that's a nice lil' improvement. I also fixed a think where SSI "authorization denied" messages would be gibberish. That was a bug from just a few hours ago. Whoops. Also, since this is like a grown up version of show and tell, I thought this was funny: * Robot101 fixes idiocy <KingAnt> Does that mean I'm going to be nuetered? committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 08 Jan 2003 08:18:49 +0000
parents cd84b0fd63fc
children cc79431a11a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 #include "config.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
3 #ifndef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
4 #include <unistd.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
5 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
6 #include <winsock.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
7 #include <io.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
8 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
9
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
10
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
11 #include <sys/stat.h>
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 #include <stdlib.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 #include <string.h>
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
14 #include <errno.h>
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 #include <stdio.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 #include <ctype.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 #include "gaim.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 #include "prpl.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 #include "proxy.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 #include "md5.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
22 #ifdef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
23 #include "win32dep.h"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
24 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
25
3592
15a0e82a0936 [gaim-migrate @ 3694]
Sean Egan <seanegan@gmail.com>
parents: 3572
diff changeset
26 #include "pixmaps/protocols/msn/msn_online.xpm"
15a0e82a0936 [gaim-migrate @ 3694]
Sean Egan <seanegan@gmail.com>
parents: 3572
diff changeset
27 #include "pixmaps/protocols/msn/msn_away.xpm"
15a0e82a0936 [gaim-migrate @ 3694]
Sean Egan <seanegan@gmail.com>
parents: 3572
diff changeset
28 #include "pixmaps/protocols/msn/msn_occ.xpm"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
30 static struct prpl *my_protocol = NULL;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
31
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
32 /* for win32 compatability */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
33 G_MODULE_IMPORT GSList *connections;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
34
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #define MSN_BUF_LEN 8192
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #define MIME_HEADER "MIME-Version: 1.0\r\n" \
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 "Content-Type: text/plain; charset=UTF-8\r\n" \
2273
0b5c3338fa3d [gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2265
diff changeset
38 "User-Agent: Gaim/" VERSION "\r\n" \
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
39 "X-MMS-IM-Format: FN=Arial; EF=; CO=0; PF=0\r\n\r\n"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
41 #define HOTMAIL_URL "http://www.hotmail.com/cgi-bin/folders"
2932
3827e4cd665c [gaim-migrate @ 2945]
Rob Flynn <gaim@robflynn.com>
parents: 2889
diff changeset
42 #define PASSPORT_URL "http://lc1.law13.hotmail.passport.com/cgi-bin/dologin?login="
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
43
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 #define MSN_ONLINE 1
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 #define MSN_BUSY 2
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 #define MSN_IDLE 3
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #define MSN_BRB 4
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 #define MSN_AWAY 5
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 #define MSN_PHONE 6
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 #define MSN_LUNCH 7
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 #define MSN_OFFLINE 8
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 #define MSN_HIDDEN 9
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 #define USEROPT_HOTMAIL 0
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55
3322
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3321
diff changeset
56 #define USEROPT_MSNSERVER 3
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3321
diff changeset
57 #define MSN_SERVER "messenger.hotmail.com"
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3321
diff changeset
58 #define USEROPT_MSNPORT 4
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3321
diff changeset
59 #define MSN_PORT 1863
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3321
diff changeset
60
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
61 #define MSN_TYPING_RECV_TIMEOUT 6
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
62 #define MSN_TYPING_SEND_TIMEOUT 4
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
63
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
64 struct msn_file_transfer {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
65 enum { MFT_SENDFILE_IN, MFT_SENDFILE_OUT } type;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
66 struct file_transfer *xfer;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
67 struct gaim_connection *gc;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
68
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
69 int fd;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
70 int inpa;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
71
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
72 char *filename;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
73
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
74 char *sn;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
75 char ip[16];
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
76 int port;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
77
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
78 unsigned long cookie;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
79 unsigned long authcookie;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
80
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
81 int len;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
82
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
83 char *rxqueue;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
84 int rxlen;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
85 gboolean msg;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
86 char *msguser;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
87 int msglen;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
88 };
3035
0f1766887ddd [gaim-migrate @ 3048]
Rob Flynn <gaim@robflynn.com>
parents: 3033
diff changeset
89
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 struct msn_data {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 int fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 int trId;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 int inpa;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
94
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
95 char *rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
96 int rxlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
97 gboolean msg;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
98 char *msguser;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
99 int msglen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
100
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 GSList *switches;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 GSList *fl;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
103 GSList *permit;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
104 GSList *deny;
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
105 GSList *file_transfers;
3171
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
106
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
107 char *kv;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
108 char *sid;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
109 char *mspauth;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
110 unsigned long sl;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
111 char *passport;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
112
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 struct msn_switchboard {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 struct gaim_connection *gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 struct conversation *chat;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 int fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 int inpa;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
120
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
121 char *rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
122 int rxlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
123 gboolean msg;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
124 char *msguser;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
125 int msglen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
126
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 char *sessid;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 char *auth;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 int trId;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 int total;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 char *user;
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
132 GSList *txqueue;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 struct msn_buddy {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 char *user;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 char *friend;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
140 static void msn_login_callback(gpointer, gint, GaimInputCondition);
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
141 static void msn_login_xfr_connect(gpointer, gint, GaimInputCondition);
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
142 static struct msn_file_transfer *find_mft_by_cookie(struct gaim_connection *gc,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
143 unsigned long cookie);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
144 static struct msn_file_transfer *find_mft_by_xfer(struct gaim_connection *gc,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
145 struct file_transfer *xfer);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146
4039
630826d97d54 [gaim-migrate @ 4247]
Luke Schierer <lschiere@pidgin.im>
parents: 3768
diff changeset
147 #define GET_NEXT(tmp) while (*(tmp) && *(tmp) != ' ') \
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 (tmp)++; \
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 *(tmp)++ = 0; \
4039
630826d97d54 [gaim-migrate @ 4247]
Luke Schierer <lschiere@pidgin.im>
parents: 3768
diff changeset
150 while (*(tmp) && *(tmp) == ' ') \
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 (tmp)++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152
4186
9615c6996348 [gaim-migrate @ 4417]
Luke Schierer <lschiere@pidgin.im>
parents: 4150
diff changeset
153 #define GET_NEXT_LINE(tmp,s) strsep (&tmp, " "); s = strsep (&tmp, "\r");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 static char *msn_normalize(const char *s)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 static char buf[BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 g_return_val_if_fail(s != NULL, NULL);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160
3504
d7cefb94a978 [gaim-migrate @ 3568]
Sean Egan <seanegan@gmail.com>
parents: 3493
diff changeset
161 g_snprintf(buf, sizeof(buf), "%s%s", s, strchr(s, '@') ? "" : "@hotmail.com");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 return buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 static int msn_write(int fd, void *data, int len)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 {
4201
511c2b63caa4 [gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents: 4186
diff changeset
168 debug_printf("MSN C: %s", (char *)data);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 return write(fd, data, len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 static char *url_decode(const char *msg)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 static char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 int i, j = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 bzero(buf, sizeof(buf));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 for (i = 0; i < strlen(msg); i++) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 char hex[3];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 if (msg[i] != '%') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 buf[j++] = msg[i];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 continue;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 }
2093
83d8a9b7e89b [gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2090
diff changeset
184 strncpy(hex, msg + ++i, 2); hex[2] = 0;
83d8a9b7e89b [gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2090
diff changeset
185 /* i is pointing to the start of the number */
83d8a9b7e89b [gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2090
diff changeset
186 i++; /* now it's at the end and at the start of the for loop
83d8a9b7e89b [gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2090
diff changeset
187 will be at the next character */
83d8a9b7e89b [gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2090
diff changeset
188 buf[j++] = strtol(hex, NULL, 16);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 buf[j] = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 return buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194
2219
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
195 static char *url_encode(const char *msg)
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
196 {
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
197 static char buf[MSN_BUF_LEN];
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
198 int i, j = 0;
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
199
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
200 bzero(buf, sizeof(buf));
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
201 for (i = 0; i < strlen(msg); i++) {
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
202 if (isalnum(msg[i]))
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
203 buf[j++] = msg[i];
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
204 else {
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
205 sprintf(buf + j, "%%%02x", (unsigned char)msg[i]);
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
206 j += 3;
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
207 }
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
208 }
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
209 buf[j] = 0;
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
210
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
211 return buf;
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
212 }
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
213
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 static char *handle_errcode(char *buf, gboolean show)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 int errcode;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 static char msg[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 buf[4] = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 errcode = atoi(buf);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 switch (errcode) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 case 200:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
224 g_snprintf(msg, sizeof(msg), _("Syntax Error (probably a Gaim bug)"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 case 201:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
227 g_snprintf(msg, sizeof(msg), _("Invalid Parameter (probably a Gaim bug)"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229 case 205:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
230 g_snprintf(msg, sizeof(msg), _("Invalid User"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
231 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 case 206:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
233 g_snprintf(msg, sizeof(msg), _("Fully Qualified Domain Name missing"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235 case 207:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
236 g_snprintf(msg, sizeof(msg), _("Already Login"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238 case 208:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
239 g_snprintf(msg, sizeof(msg), _("Invalid Username"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241 case 209:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
242 g_snprintf(msg, sizeof(msg), _("Invalid Friendly Name"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 case 210:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
245 g_snprintf(msg, sizeof(msg), _("List Full"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 case 215:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
248 g_snprintf(msg, sizeof(msg), _("Already there"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 case 216:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
251 g_snprintf(msg, sizeof(msg), _("Not on list"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 break;
2842
cf0f0153e2da [gaim-migrate @ 2855]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
253 case 217:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
254 g_snprintf(msg, sizeof(msg), _("User is offline"));
2842
cf0f0153e2da [gaim-migrate @ 2855]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2820
diff changeset
255 break;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 case 218:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
257 g_snprintf(msg, sizeof(msg), _("Already in the mode"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 case 219:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
260 g_snprintf(msg, sizeof(msg), _("Already in opposite list"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 case 280:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
263 g_snprintf(msg, sizeof(msg), _("Switchboard failed"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 case 281:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
266 g_snprintf(msg, sizeof(msg), _("Notify Transfer failed"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 case 300:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
270 g_snprintf(msg, sizeof(msg), _("Required fields missing"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 case 302:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
273 g_snprintf(msg, sizeof(msg), _("Not logged in"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 case 500:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
277 g_snprintf(msg, sizeof(msg), _("Internal server error"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 case 501:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
280 g_snprintf(msg, sizeof(msg), _("Database server error"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 case 510:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
283 g_snprintf(msg, sizeof(msg), _("File operation error"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 case 520:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
286 g_snprintf(msg, sizeof(msg), _("Memory allocation error"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289 case 600:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
290 g_snprintf(msg, sizeof(msg), _("Server busy"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 case 601:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
293 g_snprintf(msg, sizeof(msg), _("Server unavailable"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295 case 602:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
296 g_snprintf(msg, sizeof(msg), _("Peer Notification server down"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 case 603:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
299 g_snprintf(msg, sizeof(msg), _("Database connect error"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 case 604:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
302 g_snprintf(msg, sizeof(msg), _("Server is going down (abandon ship)"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305 case 707:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
306 g_snprintf(msg, sizeof(msg), _("Error creating connection"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 case 711:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
309 g_snprintf(msg, sizeof(msg), _("Unable to write"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 case 712:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
312 g_snprintf(msg, sizeof(msg), _("Session overload"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 case 713:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
315 g_snprintf(msg, sizeof(msg), _("User is too active"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317 case 714:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
318 g_snprintf(msg, sizeof(msg), _("Too many sessions"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 case 715:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
321 g_snprintf(msg, sizeof(msg), _("Not expected"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 case 717:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
324 g_snprintf(msg, sizeof(msg), _("Bad friend file"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 case 911:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
328 g_snprintf(msg, sizeof(msg), _("Authentication failed"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330 case 913:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
331 g_snprintf(msg, sizeof(msg), _("Not allowed when offline"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332 break;
3073
22c82a341c32 [gaim-migrate @ 3087]
Sean Egan <seanegan@gmail.com>
parents: 3065
diff changeset
333 case 920:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
334 g_snprintf(msg, sizeof(msg), _("Not accepting new users"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335 break;
3073
22c82a341c32 [gaim-migrate @ 3087]
Sean Egan <seanegan@gmail.com>
parents: 3065
diff changeset
336 case 924:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
337 g_snprintf(msg, sizeof(msg), _("User unverified"));
3073
22c82a341c32 [gaim-migrate @ 3087]
Sean Egan <seanegan@gmail.com>
parents: 3065
diff changeset
338 break;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 default:
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
340 g_snprintf(msg, sizeof(msg), _("Unknown Error Code"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 if (show)
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
345 do_error_dialog(msg, NULL, GAIM_ERROR);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 return msg;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 static void handle_hotmail(struct gaim_connection *gc, char *data)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351 {
2932
3827e4cd665c [gaim-migrate @ 2945]
Rob Flynn <gaim@robflynn.com>
parents: 2889
diff changeset
352 char login_url[2048];
3171
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
353 char buf[MSN_BUF_LEN];
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
354 struct msn_data *md = gc->proto_data;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
355
3293
3e37cfdcca73 [gaim-migrate @ 3311]
Sean Egan <seanegan@gmail.com>
parents: 3279
diff changeset
356 if (strchr(gc->username, '@') != strstr(gc->username, "@hotmail.com"))
3e37cfdcca73 [gaim-migrate @ 3311]
Sean Egan <seanegan@gmail.com>
parents: 3279
diff changeset
357 /* We can only get Hotmail notification from hotmail users */
3e37cfdcca73 [gaim-migrate @ 3311]
Sean Egan <seanegan@gmail.com>
parents: 3279
diff changeset
358 return;
3e37cfdcca73 [gaim-migrate @ 3311]
Sean Egan <seanegan@gmail.com>
parents: 3279
diff changeset
359
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
360 if (!md->passport) {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
361 g_snprintf(buf, sizeof(buf), "URL %d INBOX\r\n", ++md->trId);
2932
3827e4cd665c [gaim-migrate @ 2945]
Rob Flynn <gaim@robflynn.com>
parents: 2889
diff changeset
362
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
363 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
364 return;
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
365 }
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
366 } else {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
367 g_snprintf(login_url, sizeof(login_url), "%s", md->passport);
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
368
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
369 if (strstr(data, "Content-Type: text/x-msmsgsinitialemailnotification;")) {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
370 char *x = strstr(data, "Inbox-Unread:");
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
371 if (!x) return;
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
372 x += strlen("Inbox-Unread: ");
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
373 connection_has_mail(gc, atoi(x), NULL, NULL, login_url);
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
374 } else if (strstr(data, "Content-Type: text/x-msmsgsemailnotification;")) {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
375 char *from = strstr(data, "From:");
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
376 char *subject = strstr(data, "Subject:");
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
377 char *x;
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
378 if (!from || !subject) {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
379 connection_has_mail(gc, 1, NULL, NULL, login_url);
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
380 return;
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
381 }
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
382 from += strlen("From: ");
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
383 x = strstr(from, "\r\n"); *x = 0;
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
384 subject += strlen("Subject: ");
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
385 x = strstr(subject, "\r\n"); *x = 0;
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
386 connection_has_mail(gc, -1, from, subject, login_url);
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
387 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 static struct msn_switchboard *msn_find_switch(struct gaim_connection *gc, char *id)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 GSList *m = md->switches;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396 while (m) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 struct msn_switchboard *ms = m->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 m = m->next;
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
399 if ((ms->total <= 1) && !g_strcasecmp(ms->user, id))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 return ms;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406 static struct msn_switchboard *msn_find_switch_by_id(struct gaim_connection *gc, int id)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 GSList *m = md->switches;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411 while (m) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412 struct msn_switchboard *ms = m->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413 m = m->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414 if (ms->chat && (ms->chat->id == id))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415 return ms;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
416 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
417
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
419 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
420
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
421 static struct msn_switchboard *msn_find_writable_switch(struct gaim_connection *gc)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
422 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
423 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 GSList *m = md->switches;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 while (m) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427 struct msn_switchboard *ms = m->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428 m = m->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429 if (ms->txqueue)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430 return ms;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 static void msn_kill_switch(struct msn_switchboard *ms)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 struct gaim_connection *gc = ms->gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441 if (ms->inpa)
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
442 gaim_input_remove(ms->inpa);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 close(ms->fd);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
444 g_free(ms->rxqueue);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
445 if (ms->msg)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
446 g_free(ms->msguser);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 if (ms->sessid)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448 g_free(ms->sessid);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 g_free(ms->auth);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
450 if (ms->user)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451 g_free(ms->user);
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
452 while (ms->txqueue) {
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
453 g_free(ms->txqueue->data);
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
454 ms->txqueue = g_slist_remove(ms->txqueue, ms->txqueue->data);
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
455 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456 if (ms->chat)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457 serv_got_chat_left(gc, ms->chat->id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459 md->switches = g_slist_remove(md->switches, ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
461 g_free(ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
462 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
463
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
464 static int msn_process_switch(struct msn_switchboard *ms, char *buf)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 struct gaim_connection *gc = ms->gc;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
467 char sendbuf[MSN_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468 static int id = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
469
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470 if (!g_strncasecmp(buf, "ACK", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471 } else if (!g_strncasecmp(buf, "ANS", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
472 if (ms->chat)
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3642
diff changeset
473 add_chat_buddy(ms->chat, gc->username, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 } else if (!g_strncasecmp(buf, "BYE", 3)) {
4068
29401c9ccc2a [gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents: 4056
diff changeset
475 char *user, *tmp = buf;
29401c9ccc2a [gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents: 4056
diff changeset
476 GET_NEXT(tmp);
29401c9ccc2a [gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents: 4056
diff changeset
477 user = tmp;
29401c9ccc2a [gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents: 4056
diff changeset
478
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479 if (ms->chat) {
2820
b917845dad3c [gaim-migrate @ 2833]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
480 remove_chat_buddy(ms->chat, user, NULL);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
481 } else {
4068
29401c9ccc2a [gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents: 4056
diff changeset
482 char msgbuf[256];
4112
12552607e88c [gaim-migrate @ 4327]
Christian Hammond <chipx86@chipx86.com>
parents: 4111
diff changeset
483 const char *username;
4068
29401c9ccc2a [gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents: 4056
diff changeset
484 struct conversation *cnv;
4112
12552607e88c [gaim-migrate @ 4327]
Christian Hammond <chipx86@chipx86.com>
parents: 4111
diff changeset
485 struct buddy *b;
12552607e88c [gaim-migrate @ 4327]
Christian Hammond <chipx86@chipx86.com>
parents: 4111
diff changeset
486
12552607e88c [gaim-migrate @ 4327]
Christian Hammond <chipx86@chipx86.com>
parents: 4111
diff changeset
487 if ((b = find_buddy(gc, user)) != NULL)
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
488 username = get_buddy_alias(b);
4112
12552607e88c [gaim-migrate @ 4327]
Christian Hammond <chipx86@chipx86.com>
parents: 4111
diff changeset
489 else
12552607e88c [gaim-migrate @ 4327]
Christian Hammond <chipx86@chipx86.com>
parents: 4111
diff changeset
490 username = user;
4068
29401c9ccc2a [gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents: 4056
diff changeset
491
29401c9ccc2a [gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents: 4056
diff changeset
492 g_snprintf(msgbuf, sizeof(msgbuf),
4112
12552607e88c [gaim-migrate @ 4327]
Christian Hammond <chipx86@chipx86.com>
parents: 4111
diff changeset
493 _("%s has closed the conversation window"), username);
4068
29401c9ccc2a [gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents: 4056
diff changeset
494
29401c9ccc2a [gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents: 4056
diff changeset
495 if ((cnv = find_conversation(user)))
29401c9ccc2a [gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents: 4056
diff changeset
496 write_to_conv(cnv, msgbuf, WFLAG_SYSTEM, NULL, time(NULL), -1);
29401c9ccc2a [gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents: 4056
diff changeset
497
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498 msn_kill_switch(ms);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
499 return 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
500 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501 } else if (!g_strncasecmp(buf, "CAL", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
502 } else if (!g_strncasecmp(buf, "IRO", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
503 char *tot, *user, *tmp = buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
505 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
506 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
507 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
508 tot = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
509 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
510 ms->total = atoi(tot);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
511 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
512 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
513
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
514 if (ms->total > 1) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
515 if (!ms->chat)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516 ms->chat = serv_got_joined_chat(gc, ++id, "MSN Chat");
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3642
diff changeset
517 add_chat_buddy(ms->chat, user, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
519 } else if (!g_strncasecmp(buf, "JOI", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520 char *user, *tmp = buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
521 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
522 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
523 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
524
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
525 if (ms->total == 1) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
526 ms->chat = serv_got_joined_chat(gc, ++id, "MSN Chat");
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3642
diff changeset
527 add_chat_buddy(ms->chat, ms->user, NULL);
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3642
diff changeset
528 add_chat_buddy(ms->chat, gc->username, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
529 g_free(ms->user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
530 ms->user = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
531 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
532 if (ms->chat)
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3642
diff changeset
533 add_chat_buddy(ms->chat, user, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
534 ms->total++;
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
535 while (ms->txqueue) {
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
536 char *send = add_cr(ms->txqueue->data);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
537 g_snprintf(sendbuf, sizeof(sendbuf), "MSG %d N %d\r\n%s%s", ++ms->trId,
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
538 strlen(MIME_HEADER) + strlen(send),
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
539 MIME_HEADER, send);
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
540 g_free(ms->txqueue->data);
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
541 ms->txqueue = g_slist_remove(ms->txqueue, ms->txqueue->data);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
542 if (msn_write(ms->fd, sendbuf, strlen(sendbuf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
543 msn_kill_switch(ms);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
544 return 0;
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
545 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
546 debug_printf("\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
547 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
548 } else if (!g_strncasecmp(buf, "MSG", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
549 char *user, *tmp = buf;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
550 int length;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
551
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
552 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
553 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
554
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
555 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
556
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
557 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
558 length = atoi(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
559
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
560 ms->msg = TRUE;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
561 ms->msguser = g_strdup(user);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
562 ms->msglen = length;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
563 } else if (!g_strncasecmp(buf, "NAK", 3)) {
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
564 do_error_dialog(_("An MSN message may not have been received."), NULL, GAIM_ERROR);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
565 } else if (!g_strncasecmp(buf, "NLN", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
566 } else if (!g_strncasecmp(buf, "OUT", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
567 if (ms->chat)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
568 serv_got_chat_left(gc, ms->chat->id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
569 msn_kill_switch(ms);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
570 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
571 } else if (!g_strncasecmp(buf, "USR", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
572 /* good, we got USR, now we need to find out who we want to talk to */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
573 struct msn_switchboard *ms = msn_find_writable_switch(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
574
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
575 if (!ms)
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
576 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
577
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
578 g_snprintf(sendbuf, sizeof(sendbuf), "CAL %d %s\r\n", ++ms->trId, ms->user);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
579 if (msn_write(ms->fd, sendbuf, strlen(sendbuf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
580 msn_kill_switch(ms);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
581 return 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
582 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
583 } else if (isdigit(*buf)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
584 handle_errcode(buf, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
585 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
586 debug_printf("Unhandled message!\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
587 }
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
588
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
589 return 1;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
590 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
591
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
592 static char *msn_parse_format(char *mime)
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
593 {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
594 char *cur;
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
595 GString *ret = g_string_new(NULL);
3375
fb1a0caadb9f [gaim-migrate @ 3394]
Sean Egan <seanegan@gmail.com>
parents: 3324
diff changeset
596 guint colorbuf;
fb1a0caadb9f [gaim-migrate @ 3394]
Sean Egan <seanegan@gmail.com>
parents: 3324
diff changeset
597 char *colors = (char *)(&colorbuf);
fb1a0caadb9f [gaim-migrate @ 3394]
Sean Egan <seanegan@gmail.com>
parents: 3324
diff changeset
598
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
599
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
600 cur = strstr(mime, "FN=");
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
601 if (cur && (*(cur = cur + 3) != ';')) {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
602 ret = g_string_append(ret, "<FONT FACE=\"");
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
603 while (*cur && *cur != ';') {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
604 ret = g_string_append_c(ret, *cur);
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
605 cur++;
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
606 }
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
607 ret = g_string_append(ret, "\">");
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
608 }
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
609
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
610 cur = strstr(mime, "EF=");
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
611 if (cur && (*(cur = cur + 3) != ';')) {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
612 while (*cur && *cur != ';') {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
613 ret = g_string_append_c(ret, '<');
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
614 ret = g_string_append_c(ret, *cur);
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
615 ret = g_string_append_c(ret, '>');
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
616 cur++;
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
617 }
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
618 }
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
619
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
620 cur = strstr(mime, "CO=");
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
621 if (cur && (*(cur = cur + 3) != ';')) {
3375
fb1a0caadb9f [gaim-migrate @ 3394]
Sean Egan <seanegan@gmail.com>
parents: 3324
diff changeset
622 if (sscanf (cur, "%x;", &colorbuf) == 1) {
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
623 char tag[MSN_BUF_LEN];
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
624 g_snprintf(tag, sizeof(tag), "<FONT COLOR=\"#%02hhx%02hhx%02hhx\">", colors[0], colors[1], colors[2]);
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
625 ret = g_string_append(ret, tag);
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
626 }
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
627 }
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
628
3323
3e6e54051e67 [gaim-migrate @ 3341]
Sean Egan <seanegan@gmail.com>
parents: 3322
diff changeset
629 cur = url_decode(ret->str);
3324
edc8511fddff [gaim-migrate @ 3342]
Sean Egan <seanegan@gmail.com>
parents: 3323
diff changeset
630 g_string_free(ret, TRUE);
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
631 return cur;
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
632 }
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
633
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
634 static int msn_process_msnftp(struct msn_file_transfer *mft, char *buf)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
635 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
636 struct gaim_connection *gc = mft->gc;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
637 char sendbuf[MSN_BUF_LEN];
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
638
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
639 if (!g_strncasecmp(buf, "VER MSNFTP", 10)) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
640
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
641 /* Send the USR string. */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
642 g_snprintf(sendbuf, sizeof(sendbuf), "USR %s %ld\r\n",
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
643 gc->username, mft->authcookie);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
644
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
645 if (msn_write(mft->fd, sendbuf, strlen(sendbuf)) < 0) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
646 /* TODO: Clean up */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
647 return 0;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
648 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
649 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
650 else if (!g_strncasecmp(buf, "FIL", 3)) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
651
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
652 char *tmp = buf;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
653
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
654 GET_NEXT(tmp);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
655
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
656 mft->len = atoi(tmp);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
657
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
658 /* Send the TFR string, to request a start of transfer. */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
659 g_snprintf(sendbuf, sizeof(sendbuf), "TFR\r\n");
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
660
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
661 gaim_input_remove(mft->inpa);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
662 mft->inpa = 0;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
663
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
664 if (msn_write(mft->fd, sendbuf, strlen(sendbuf)) < 0) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
665 /* TODO: Clean up */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
666 return 0;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
667 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
668
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
669 if (transfer_in_do(mft->xfer, mft->fd, mft->filename, mft->len)) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
670 debug_printf("MSN: transfer_in_do failed\n");
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
671 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
672 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
673
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
674 return 1;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
675 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
676
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
677 static void msn_msnftp_callback(gpointer data, gint source,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
678 GaimInputCondition cond)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
679 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
680 struct msn_file_transfer *mft = (struct msn_file_transfer *)data;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
681 char buf[MSN_BUF_LEN];
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
682 int cont = 1;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
683 int len;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
684
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
685 if (mft->fd != source)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
686 mft->fd = source;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
687
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
688 len = read(mft->fd, buf, sizeof(buf));
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
689
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
690 if (len <= 0) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
691 /* TODO: Kill mft. */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
692 return;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
693 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
694
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
695 mft->rxqueue = g_realloc(mft->rxqueue, len + mft->rxlen);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
696 memcpy(mft->rxqueue + mft->rxlen, buf, len);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
697 mft->rxlen += len;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
698
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
699 while (cont) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
700 char *end = mft->rxqueue;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
701 int cmdlen;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
702 char *cmd;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
703 int i = 0;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
704
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
705 if (!mft->rxlen)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
706 return;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
707
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
708 while (i + 1 < mft->rxlen) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
709 if (*end == '\r' && end[1] == '\n')
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
710 break;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
711 end++; i++;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
712 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
713 if (i + 1 == mft->rxlen)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
714 return;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
715
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
716 cmdlen = end - mft->rxqueue + 2;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
717 cmd = mft->rxqueue;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
718 mft->rxlen -= cmdlen;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
719 if (mft->rxlen) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
720 mft->rxqueue = g_memdup(cmd + cmdlen, mft->rxlen);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
721 } else {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
722 mft->rxqueue = NULL;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
723 cmd = g_realloc(cmd, cmdlen + 1);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
724 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
725 cmd[cmdlen] = 0;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
726
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
727 g_strchomp(cmd);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
728 cont = msn_process_msnftp(mft, cmd);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
729
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
730 g_free(cmd);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
731 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
732 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
733
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
734 static void msn_msnftp_connect(gpointer data, gint source,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
735 GaimInputCondition cond)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
736 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
737 struct msn_file_transfer *mft = (struct msn_file_transfer *)data;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
738 struct gaim_connection *gc = mft->gc;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
739 char buf[MSN_BUF_LEN];
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
740
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
741 if (source == -1 || !g_slist_find(connections, gc)) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
742 debug_printf("Error establishing MSNFTP connection\n");
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
743 close(source);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
744 /* TODO: Clean up */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
745 return;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
746 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
747
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
748 if (mft->fd != source)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
749 mft->fd = source;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
750
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
751 g_snprintf(buf, sizeof(buf), "VER MSNFTP\r\n");
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
752
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
753 if (msn_write(mft->fd, buf, strlen(buf)) < 0) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
754 /* TODO: Clean up */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
755 return;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
756 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
757
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
758 mft->inpa = gaim_input_add(mft->fd, GAIM_INPUT_READ,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
759 msn_msnftp_callback, mft);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
760 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
761
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
762 static void msn_process_ft_msg(struct msn_switchboard *ms, char *msg)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
763 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
764 struct msn_file_transfer *mft;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
765 struct msn_data *md = ms->gc->proto_data;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
766 char *tmp = msg;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
767
4186
9615c6996348 [gaim-migrate @ 4417]
Luke Schierer <lschiere@pidgin.im>
parents: 4150
diff changeset
768 if (strstr(msg, "Application-GUID: {5D3E02AB-6190-11d3-BBBB-00C04F795683}") &&
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
769 strstr(msg, "Invitation-Command: INVITE")) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
770
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
771 /*
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
772 * First invitation message, requesting an ACCEPT or CANCEL from
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
773 * the recipient. Used in incoming file transfers.
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
774 */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
775
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
776 char *filename;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
777 char *cookie_s, *filesize_s;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
778 size_t filesize;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
779
4186
9615c6996348 [gaim-migrate @ 4417]
Luke Schierer <lschiere@pidgin.im>
parents: 4150
diff changeset
780 tmp = strstr(msg, "Invitation-Cookie:");
9615c6996348 [gaim-migrate @ 4417]
Luke Schierer <lschiere@pidgin.im>
parents: 4150
diff changeset
781 GET_NEXT_LINE(tmp, cookie_s);
9615c6996348 [gaim-migrate @ 4417]
Luke Schierer <lschiere@pidgin.im>
parents: 4150
diff changeset
782 GET_NEXT_LINE(tmp, filename);
9615c6996348 [gaim-migrate @ 4417]
Luke Schierer <lschiere@pidgin.im>
parents: 4150
diff changeset
783 GET_NEXT_LINE(tmp, filesize_s);
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
784
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
785 mft = g_new0(struct msn_file_transfer, 1);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
786 mft->gc = ms->gc;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
787 mft->type = MFT_SENDFILE_IN;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
788 mft->sn = g_strdup(ms->msguser);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
789 mft->cookie = atoi(cookie_s);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
790 mft->filename = g_strdup(filename);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
791
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
792 filesize = atoi(filesize_s);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
793
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
794 md->file_transfers = g_slist_append(md->file_transfers, mft);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
795
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
796 mft->xfer = transfer_in_add(ms->gc, ms->msguser,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
797 mft->filename, filesize, 1, NULL);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
798 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
799 else if (strstr(msg, "Invitation-Command: ACCEPT")) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
800
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
801 /*
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
802 * XXX I hope these checks don't return false positives, but they
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
803 * seem like they should work. The only issue is alternative
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
804 * protocols, *maybe*.
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
805 */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
806
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
807 if (strstr(msg, "AuthCookie:")) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
808
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
809 /*
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
810 * Second invitation request, sent after the recipient accepts
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
811 * the request. Used in incoming file transfers.
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
812 */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
813
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
814 char *cookie_s, *ip, *port_s, *authcookie_s;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
815
4186
9615c6996348 [gaim-migrate @ 4417]
Luke Schierer <lschiere@pidgin.im>
parents: 4150
diff changeset
816 tmp = strstr(msg, "Invitation-Cookie:");
9615c6996348 [gaim-migrate @ 4417]
Luke Schierer <lschiere@pidgin.im>
parents: 4150
diff changeset
817 GET_NEXT_LINE(tmp, cookie_s);
9615c6996348 [gaim-migrate @ 4417]
Luke Schierer <lschiere@pidgin.im>
parents: 4150
diff changeset
818 GET_NEXT_LINE(tmp, ip);
9615c6996348 [gaim-migrate @ 4417]
Luke Schierer <lschiere@pidgin.im>
parents: 4150
diff changeset
819 GET_NEXT_LINE(tmp, port_s);
9615c6996348 [gaim-migrate @ 4417]
Luke Schierer <lschiere@pidgin.im>
parents: 4150
diff changeset
820 GET_NEXT_LINE(tmp, authcookie_s);
9615c6996348 [gaim-migrate @ 4417]
Luke Schierer <lschiere@pidgin.im>
parents: 4150
diff changeset
821 GET_NEXT_LINE(tmp, authcookie_s);
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
822
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
823 mft = find_mft_by_cookie(ms->gc, atoi(cookie_s));
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
824
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
825 if (!mft)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
826 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
827 debug_printf("MSN: Cookie not found. File transfer aborted.\n");
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
828 return;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
829 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
830
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
831 strncpy(mft->ip, ip, 16);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
832 mft->port = atoi(port_s);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
833 mft->authcookie = atoi(authcookie_s);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
834
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
835 mft->fd = proxy_connect(mft->ip, mft->port, msn_msnftp_connect, mft);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
836
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
837 if (ms->fd < 0) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
838 md->file_transfers = g_slist_remove(md->file_transfers, mft);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
839 return;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
840 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
841 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
842 else
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
843 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
844 /*
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
845 * An accept message from the recipient. Used in outgoing
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
846 * file transfers.
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
847 */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
848 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
849 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
850 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
851
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
852 static void msn_process_switch_msg(struct msn_switchboard *ms, char *msg)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
853 {
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
854 char *content, *agent, *format;
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
855 char *message = NULL;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
856 int flags = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
857
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
858 agent = strstr(msg, "User-Agent: ");
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
859 if (agent) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
860 if (!g_strncasecmp(agent, "User-Agent: Gaim", strlen("User-Agent: Gaim")))
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
861 flags |= IM_FLAG_GAIMUSER;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
862 }
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
863
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
864 format = strstr(msg, "X-MMS-IM-Format: ");
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
865 if (format) {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
866 format = msn_parse_format(format);
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
867 } else {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
868 format = NULL;
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
869 }
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
870
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
871 content = strstr(msg, "Content-Type: ");
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
872 if (!content)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
873 return;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
874 if (!g_strncasecmp(content, "Content-Type: text/x-msmsgscontrol\r\n",
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
875 strlen( "Content-Type: text/x-msmsgscontrol\r\n"))) {
3323
3e6e54051e67 [gaim-migrate @ 3341]
Sean Egan <seanegan@gmail.com>
parents: 3322
diff changeset
876 if (strstr(content,"TypingUser: ") && !ms->chat) {
3768
f53370197bb9 [gaim-migrate @ 3907]
Sean Egan <seanegan@gmail.com>
parents: 3730
diff changeset
877 serv_got_typing(ms->gc, ms->msguser, MSN_TYPING_RECV_TIMEOUT, TYPING);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
878 return;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
879 }
3171
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
880
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
881 } else if (!g_strncasecmp(content, "Content-Type: text/x-msmsgsinvite;",
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
882 strlen("Content-Type: text/x-msmsgsinvite;"))) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
883
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
884 /*
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
885 * NOTE: Other things, such as voice communication, would go in
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
886 * here too (since they send the same Content-Type). However,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
887 * this is the best check for file transfer messages, so I'm
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
888 * calling msn_process_ft_invite_msg(). If anybody adds support
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
889 * for anything else that sends a text/x-msmsgsinvite, perhaps
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
890 * this should be changed. For now, it stays.
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
891 */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
892 msn_process_ft_msg(ms, content);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
893
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
894 } else if (!g_strncasecmp(content, "Content-Type: text/plain",
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
895 strlen("Content-Type: text/plain"))) {
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
896
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
897
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
898
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
899 char *skiphead;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
900 skiphead = strstr(msg, "\r\n\r\n");
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
901 if (!skiphead || !skiphead[4]) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
902 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
903 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
904 skiphead += 4;
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
905 strip_linefeed(skiphead);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
906
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
907 if (format) {
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
908 message = g_strdup_printf("%s%s", format, skiphead);
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
909 } else {
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
910 message = g_strdup(skiphead);
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
911 }
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
912
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
913 if (ms->chat)
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
914 serv_got_chat_in(ms->gc, ms->chat->id, ms->msguser, flags, message, time(NULL));
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
915 else
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
916 serv_got_im(ms->gc, ms->msguser, message, flags, time(NULL), -1);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
917
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
918 g_free(message);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
919 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
920 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
921
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
922 static void msn_switchboard_callback(gpointer data, gint source, GaimInputCondition cond)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
923 {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
924 struct msn_switchboard *ms = data;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
925 char buf[MSN_BUF_LEN];
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
926 int cont = 1;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
927 int len;
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
928
2970
f7f7c9223312 [gaim-migrate @ 2983]
Rob Flynn <gaim@robflynn.com>
parents: 2953
diff changeset
929 /* This is really stupid and I hate to put this here. */
f7f7c9223312 [gaim-migrate @ 2983]
Rob Flynn <gaim@robflynn.com>
parents: 2953
diff changeset
930 if (ms->fd != source)
f7f7c9223312 [gaim-migrate @ 2983]
Rob Flynn <gaim@robflynn.com>
parents: 2953
diff changeset
931 ms->fd = source;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
932 len = read(ms->fd, buf, sizeof(buf));
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
933 if (len <= 0) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
934 msn_kill_switch(ms);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
935 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
936 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
937
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
938 ms->rxqueue = g_realloc(ms->rxqueue, len + ms->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
939 memcpy(ms->rxqueue + ms->rxlen, buf, len);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
940 ms->rxlen += len;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
941
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
942 while (cont) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
943 if (!ms->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
944 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
945
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
946 if (ms->msg) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
947 char *msg;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
948 if (ms->msglen > ms->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
949 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
950 msg = ms->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
951 ms->rxlen -= ms->msglen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
952 if (ms->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
953 ms->rxqueue = g_memdup(msg + ms->msglen, ms->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
954 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
955 ms->rxqueue = NULL;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
956 msg = g_realloc(msg, ms->msglen + 1);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
957 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
958 msg[ms->msglen] = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
959 ms->msglen = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
960 ms->msg = FALSE;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
961
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
962 msn_process_switch_msg(ms, msg);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
963
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
964 g_free(ms->msguser);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
965 g_free(msg);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
966 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
967 char *end = ms->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
968 int cmdlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
969 char *cmd;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
970 int i = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
971
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
972 while (i + 1 < ms->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
973 if (*end == '\r' && end[1] == '\n')
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
974 break;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
975 end++; i++;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
976 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
977 if (i + 1 == ms->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
978 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
979
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
980 cmdlen = end - ms->rxqueue + 2;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
981 cmd = ms->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
982 ms->rxlen -= cmdlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
983 if (ms->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
984 ms->rxqueue = g_memdup(cmd + cmdlen, ms->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
985 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
986 ms->rxqueue = NULL;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
987 cmd = g_realloc(cmd, cmdlen + 1);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
988 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
989 cmd[cmdlen] = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
990
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
991 debug_printf("MSN S: %s", cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
992 g_strchomp(cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
993 cont = msn_process_switch(ms, cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
994
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
995 g_free(cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
996 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
997 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
998 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
999
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1000 static void msn_rng_connect(gpointer data, gint source, GaimInputCondition cond)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1001 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1002 struct msn_switchboard *ms = data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1003 struct gaim_connection *gc = ms->gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1004 struct msn_data *md;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1005 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1006
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1007 if (source == -1 || !g_slist_find(connections, gc)) {
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1008 close(source);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1009 g_free(ms->sessid);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1010 g_free(ms->auth);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1011 g_free(ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1012 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1013 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1014
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1015 md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1016
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1017 if (ms->fd != source)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1018 ms->fd = source;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1019
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1020 g_snprintf(buf, sizeof(buf), "ANS %d %s %s %s\r\n", ++ms->trId, gc->username, ms->auth, ms->sessid);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1021 if (msn_write(ms->fd, buf, strlen(buf)) < 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1022 close(ms->fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1023 g_free(ms->sessid);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1024 g_free(ms->auth);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1025 g_free(ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1026 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1027 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1028
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1029 md->switches = g_slist_append(md->switches, ms);
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1030 ms->inpa = gaim_input_add(ms->fd, GAIM_INPUT_READ, msn_switchboard_callback, ms);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1031 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1032
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1033 static void msn_ss_xfr_connect(gpointer data, gint source, GaimInputCondition cond)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1034 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1035 struct msn_switchboard *ms = data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1036 struct gaim_connection *gc = ms->gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1037 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1038
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1039 if (source == -1 || !g_slist_find(connections, gc)) {
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1040 close(source);
2265
2f03cfd21fc2 [gaim-migrate @ 2275]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
1041 if (g_slist_find(connections, gc)) {
2f03cfd21fc2 [gaim-migrate @ 2275]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
1042 msn_kill_switch(ms);
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
1043 do_error_dialog(_("Gaim was unable to send an MSN message"),
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
1044 _("Gaim encountered an error communicating with the "
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
1045 "MSN switchboard server. Please try again later."), GAIM_ERROR);
2265
2f03cfd21fc2 [gaim-migrate @ 2275]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
1046 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1047 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1048 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1049
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1050 if (ms->fd != source)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1051 ms->fd = source;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1052
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1053 g_snprintf(buf, sizeof(buf), "USR %d %s %s\r\n", ++ms->trId, gc->username, ms->auth);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1054 if (msn_write(ms->fd, buf, strlen(buf)) < 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1055 g_free(ms->auth);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1056 g_free(ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1057 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1058 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1059
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1060 ms->inpa = gaim_input_add(ms->fd, GAIM_INPUT_READ, msn_switchboard_callback, ms);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1061 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1062
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1063 struct msn_add_permit {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1064 struct gaim_connection *gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1065 char *user;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1066 char *friend;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1067 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1068
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3720
diff changeset
1069 static void msn_accept_add(struct msn_add_permit *map)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1070 {
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1071 if(g_slist_find(connections, map->gc)) {
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1072 struct msn_data *md = map->gc->proto_data;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1073 char buf[MSN_BUF_LEN];
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1074
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1075 g_snprintf(buf, sizeof(buf), "ADD %d AL %s %s\r\n", ++md->trId, map->user, url_encode(map->friend));
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1076
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1077 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1078 hide_login_progress(map->gc, _("Write error"));
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1079 signoff(map->gc);
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1080 return;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1081 }
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1082 map->gc->permit = g_slist_append(map->gc->permit, map->user);
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1083 build_allow_list(); /* er. right. we'll need to have a thing for this in CUI too */
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1084 show_got_added(map->gc, NULL, map->user, map->friend, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1085 }
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1086
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3720
diff changeset
1087 g_free(map->user);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3720
diff changeset
1088 g_free(map->friend);
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3720
diff changeset
1089 g_free(map);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1090 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1091
3730
a20bf3d247ff [gaim-migrate @ 3868]
Sean Egan <seanegan@gmail.com>
parents: 3720
diff changeset
1092 static void msn_cancel_add(struct msn_add_permit *map)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1093 {
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1094 if(g_slist_find(connections, map->gc)) {
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1095 struct msn_data *md = map->gc->proto_data;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1096 char buf[MSN_BUF_LEN];
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1097
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1098 g_snprintf(buf, sizeof(buf), "ADD %d BL %s %s\r\n", ++md->trId, map->user, url_encode(map->friend));
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1099 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1100 hide_login_progress(map->gc, _("Write error"));
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1101 signoff(map->gc);
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1102 return;
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1103 }
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1104 map->gc->deny = g_slist_append(map->gc->deny, map->user);
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1105 build_block_list();
3118
712bc3205d9a [gaim-migrate @ 3133]
Sean Egan <seanegan@gmail.com>
parents: 3117
diff changeset
1106 }
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1107
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1108 g_free(map->user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1109 g_free(map->friend);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1110 g_free(map);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1111 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1112
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1113 static int msn_process_main(struct gaim_connection *gc, char *buf)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1114 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1115 struct msn_data *md = gc->proto_data;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1116 char sendbuf[MSN_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1117
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1118 if (!g_strncasecmp(buf, "ADD", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1119 char *list, *user, *friend, *tmp = buf;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1120 struct msn_add_permit *ap;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1121 GSList *perm = gc->permit;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1122 char msg[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1123
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1124 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1125 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1126 list = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1127
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1128 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1129 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1130 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1131
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1132 GET_NEXT(tmp);
3323
3e6e54051e67 [gaim-migrate @ 3341]
Sean Egan <seanegan@gmail.com>
parents: 3322
diff changeset
1133 friend = url_decode(tmp);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1134
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1135 if (g_strcasecmp(list, "RL"))
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1136 return 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1137
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1138 while (perm) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1139 if (!g_strcasecmp(perm->data, user))
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1140 return 1;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1141 perm = perm->next;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1142 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1143
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1144 ap = g_new0(struct msn_add_permit, 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1145 ap->user = g_strdup(user);
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
1146 ap->friend = g_strdup(friend);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1147 ap->gc = gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1148
3299
a184a80b1e15 [gaim-migrate @ 3317]
Sean Egan <seanegan@gmail.com>
parents: 3296
diff changeset
1149 g_snprintf(msg, sizeof(msg), _("The user %s (%s) wants to add %s to his or her buddy list."),
3323
3e6e54051e67 [gaim-migrate @ 3341]
Sean Egan <seanegan@gmail.com>
parents: 3322
diff changeset
1150 ap->user, ap->friend, ap->gc->username);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1151
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1152 do_ask_dialog(msg, NULL, ap, _("Authorize"), msn_accept_add, _("Deny"), msn_cancel_add, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1153 } else if (!g_strncasecmp(buf, "BLP", 3)) {
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1154 char *type, *tmp = buf;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1155
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1156 GET_NEXT(tmp);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1157 GET_NEXT(tmp);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1158 GET_NEXT(tmp);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1159 type = tmp;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1160
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1161 if (!g_strcasecmp(type, "AL")) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1162 /* If the current setting is AL, messages
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1163 * from users who are not in BL will be delivered
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1164 *
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1165 * In other words, deny some */
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1166 gc->permdeny = DENY_SOME;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1167 } else {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1168 /* If the current
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1169 * setting is BL, only messages from people who are in the AL will be
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1170 * delivered.
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1171 *
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1172 * In other words, permit some */
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1173 gc->permdeny = PERMIT_SOME;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1174 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1175 } else if (!g_strncasecmp(buf, "BPR", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1176 } else if (!g_strncasecmp(buf, "CHG", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1177 } else if (!g_strncasecmp(buf, "CHL", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1178 char *hash = buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1179 char buf2[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1180 md5_state_t st;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1181 md5_byte_t di[16];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1182 int i;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1183
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1184 GET_NEXT(hash);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1185 GET_NEXT(hash);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1186
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1187 md5_init(&st);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1188 md5_append(&st, (const md5_byte_t *)hash, strlen(hash));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1189 md5_append(&st, (const md5_byte_t *)"Q1P7W2E4J9R8U3S5", strlen("Q1P7W2E4J9R8U3S5"));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1190 md5_finish(&st, di);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1191
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1192 g_snprintf(sendbuf, sizeof(sendbuf), "QRY %d msmsgs@msnmsgr.com 32\r\n", ++md->trId);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1193 for (i = 0; i < 16; i++) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1194 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1195 strcat(sendbuf, buf2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1196 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1197
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1198 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1199 hide_login_progress(gc, _("Unable to write to server"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1200 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1201 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1202
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1203 debug_printf("\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1204 } else if (!g_strncasecmp(buf, "FLN", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1205 char *usr = buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1206
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1207 GET_NEXT(usr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1208 serv_got_update(gc, usr, 0, 0, 0, 0, 0, 0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1209 } else if (!g_strncasecmp(buf, "GTC", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1210 } else if (!g_strncasecmp(buf, "INF", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1211 } else if (!g_strncasecmp(buf, "ILN", 3)) {
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1212 char *state, *user, *friend, *tmp = buf;
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1213 int status = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1214
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1215 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1216
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1217 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1218 state = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1219
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1220 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1221 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1222
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1223 GET_NEXT(tmp);
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1224 friend = url_decode(tmp);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1225
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
1226 serv_got_alias(gc, user, friend);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1227
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1228 if (!g_strcasecmp(state, "BSY")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1229 status |= UC_UNAVAILABLE | (MSN_BUSY << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1230 } else if (!g_strcasecmp(state, "IDL")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1231 status |= UC_UNAVAILABLE | (MSN_IDLE << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1232 } else if (!g_strcasecmp(state, "BRB")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1233 status |= UC_UNAVAILABLE | (MSN_BRB << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1234 } else if (!g_strcasecmp(state, "AWY")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1235 status |= UC_UNAVAILABLE | (MSN_AWAY << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1236 } else if (!g_strcasecmp(state, "PHN")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1237 status |= UC_UNAVAILABLE | (MSN_PHONE << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1238 } else if (!g_strcasecmp(state, "LUN")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1239 status |= UC_UNAVAILABLE | (MSN_LUNCH << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1240 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1241
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1242 serv_got_update(gc, user, 1, 0, 0, 0, status, 0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1243 } else if (!g_strncasecmp(buf, "LST", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1244 char *which, *who, *friend, *tmp = buf;
3012
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1245 struct msn_add_permit *ap; /* for any as yet undealt with buddies who've added you to their buddy list when you were off-line. How dare they! */
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1246 GSList *perm = gc->permit; /* current permit list */
3018
63628fddf121 [gaim-migrate @ 3031]
Sean Egan <seanegan@gmail.com>
parents: 3013
diff changeset
1247 GSList *denyl = gc->deny;
3012
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1248 char msg[MSN_BUF_LEN];
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1249 int new = 1;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1250 int pos, tot;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1251
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1252 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1253 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1254 which = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1255
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1256 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1257 GET_NEXT(tmp);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1258 pos = strtol(tmp, NULL, 10);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1259 GET_NEXT(tmp);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1260 tot = strtol(tmp, NULL, 10);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1261 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1262 who = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1263
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1264 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1265 friend = url_decode(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1266
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1267 if (!g_strcasecmp(which, "FL") && pos) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1268 struct msn_buddy *b = g_new0(struct msn_buddy, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1269 b->user = g_strdup(who);
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
1270 b->friend = g_strdup(friend);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1271 md->fl = g_slist_append(md->fl, b);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1272 } else if (!g_strcasecmp(which, "AL") && pos) {
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
1273 char *dupl;
3296
56df4d1dcad5 [gaim-migrate @ 3314]
Sean Egan <seanegan@gmail.com>
parents: 3295
diff changeset
1274 if ((dupl = (char *)g_slist_find_custom(gc->deny, who,
56df4d1dcad5 [gaim-migrate @ 3314]
Sean Egan <seanegan@gmail.com>
parents: 3295
diff changeset
1275 (GCompareFunc)strcmp))) {
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
1276 debug_printf("moving from deny to permit: %s", who);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
1277 gc->deny = g_slist_remove(gc->deny, dupl);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
1278 }
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1279 gc->permit = g_slist_append(gc->permit, g_strdup(who));
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1280 } else if (!g_strcasecmp(which, "BL") && pos) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1281 gc->deny = g_slist_append(gc->deny, g_strdup(who));
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1282 } else if (!g_strcasecmp(which, "RL")) {
3121
025a8042dd73 [gaim-migrate @ 3136]
Sean Egan <seanegan@gmail.com>
parents: 3119
diff changeset
1283 if (pos) {
3012
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1284 while(perm) {
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1285 if(!g_strcasecmp(perm->data, who))
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1286 new = 0;
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1287 perm = perm->next;
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1288 }
3018
63628fddf121 [gaim-migrate @ 3031]
Sean Egan <seanegan@gmail.com>
parents: 3013
diff changeset
1289 while(denyl) {
63628fddf121 [gaim-migrate @ 3031]
Sean Egan <seanegan@gmail.com>
parents: 3013
diff changeset
1290 if(!g_strcasecmp(denyl->data, who))
63628fddf121 [gaim-migrate @ 3031]
Sean Egan <seanegan@gmail.com>
parents: 3013
diff changeset
1291 new = 0;
63628fddf121 [gaim-migrate @ 3031]
Sean Egan <seanegan@gmail.com>
parents: 3013
diff changeset
1292 denyl = denyl->next;
63628fddf121 [gaim-migrate @ 3031]
Sean Egan <seanegan@gmail.com>
parents: 3013
diff changeset
1293 }
3012
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1294 if(new) {
3013
47d0f8979fb1 [gaim-migrate @ 3026]
Sean Egan <seanegan@gmail.com>
parents: 3012
diff changeset
1295 debug_printf("Unresolved MSN RL entry\n");
3012
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1296 ap = g_new0(struct msn_add_permit, 1);
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1297 ap->user = g_strdup(who);
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
1298 ap->friend = g_strdup(friend);
3012
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1299 ap->gc = gc;
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1300
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1301 g_snprintf(msg, sizeof(msg), _("The user %s (%s) wants to add you to their buddy list"),ap->user, ap->friend);
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
1302 do_ask_dialog(msg, NULL, ap, _("Authorize"), msn_accept_add, _("Deny"), msn_cancel_add, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE);
3012
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1303 }
3121
025a8042dd73 [gaim-migrate @ 3136]
Sean Egan <seanegan@gmail.com>
parents: 3119
diff changeset
1304 }
3012
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1305
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1306 if (pos != tot)
08327a2f25aa [gaim-migrate @ 3025]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1307 return 1; /* this isn't the last one in the RL, so return. */
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1308
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1309 g_snprintf(sendbuf, sizeof(sendbuf), "CHG %d NLN\r\n", ++md->trId);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1310 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1311 hide_login_progress(gc, _("Unable to write"));
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1312 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1313 return 0;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1314 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1315
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1316 account_online(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1317 serv_finish_login(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1318
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1319 md->permit = g_slist_copy(gc->permit);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1320 md->deny = g_slist_copy(gc->deny);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1321
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1322 if (bud_list_cache_exists(gc))
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2311
diff changeset
1323 do_import(gc, NULL);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1324 else {
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1325 g_snprintf(sendbuf, sizeof(sendbuf), "BLP %d AL\r\n", ++md->trId);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1326 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1327 hide_login_progress(gc, _("Unable to write"));
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1328 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1329 return 0;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1330 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1331 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1332 while (md->fl) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1333 struct msn_buddy *mb = md->fl->data;
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
1334 struct buddy *b = find_buddy(gc, mb->user);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1335 md->fl = g_slist_remove(md->fl, mb);
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
1336 if(!b)
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
1337 b = add_buddy(gc, _("Buddies"), mb->user, NULL);
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
1338 serv_got_alias(gc, mb->user, mb->friend);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1339 g_free(mb->user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1340 g_free(mb->friend);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1341 g_free(mb);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1342 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1343 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1344 } else if (!g_strncasecmp(buf, "MSG", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1345 char *user, *tmp = buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1346 int length;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1347
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1348 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1349 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1350
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1351 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1352
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1353 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1354 length = atoi(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1355
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1356 md->msg = TRUE;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1357 md->msguser = g_strdup(user);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1358 md->msglen = length;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1359 } else if (!g_strncasecmp(buf, "NLN", 3)) {
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1360 char *state, *user, *friend, *tmp = buf;
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1361 int status = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1362
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1363 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1364 state = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1365
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1366 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1367 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1368
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1369 GET_NEXT(tmp);
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1370 friend = url_decode(tmp);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1371
4227
a614423c648f [gaim-migrate @ 4471]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
1372 serv_got_alias(gc, user, friend);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1373
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1374 if (!g_strcasecmp(state, "BSY")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1375 status |= UC_UNAVAILABLE | (MSN_BUSY << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1376 } else if (!g_strcasecmp(state, "IDL")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1377 status |= UC_UNAVAILABLE | (MSN_IDLE << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1378 } else if (!g_strcasecmp(state, "BRB")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1379 status |= UC_UNAVAILABLE | (MSN_BRB << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1380 } else if (!g_strcasecmp(state, "AWY")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1381 status |= UC_UNAVAILABLE | (MSN_AWAY << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1382 } else if (!g_strcasecmp(state, "PHN")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1383 status |= UC_UNAVAILABLE | (MSN_PHONE << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1384 } else if (!g_strcasecmp(state, "LUN")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1385 status |= UC_UNAVAILABLE | (MSN_LUNCH << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1386 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1387
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1388 serv_got_update(gc, user, 1, 0, 0, 0, status, 0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1389 } else if (!g_strncasecmp(buf, "OUT", 3)) {
2887
704e1685f89b [gaim-migrate @ 2900]
Rob Flynn <gaim@robflynn.com>
parents: 2870
diff changeset
1390 char *tmp = buf;
704e1685f89b [gaim-migrate @ 2900]
Rob Flynn <gaim@robflynn.com>
parents: 2870
diff changeset
1391
704e1685f89b [gaim-migrate @ 2900]
Rob Flynn <gaim@robflynn.com>
parents: 2870
diff changeset
1392 GET_NEXT(tmp);
704e1685f89b [gaim-migrate @ 2900]
Rob Flynn <gaim@robflynn.com>
parents: 2870
diff changeset
1393 if (!g_strncasecmp(tmp, "OTH", 3)) {
2889
fccda160c078 [gaim-migrate @ 2902]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2888
diff changeset
1394 hide_login_progress(gc, _("You have been disconnected. You have "
fccda160c078 [gaim-migrate @ 2902]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2888
diff changeset
1395 "signed on from another location."));
fccda160c078 [gaim-migrate @ 2902]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2888
diff changeset
1396 signoff(gc);
fccda160c078 [gaim-migrate @ 2902]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2888
diff changeset
1397 return 0;
2887
704e1685f89b [gaim-migrate @ 2900]
Rob Flynn <gaim@robflynn.com>
parents: 2870
diff changeset
1398 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1399 } else if (!g_strncasecmp(buf, "PRP", 3)) {
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
1400 } else if (!g_strncasecmp(buf, "QNG", 3)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1401 } else if (!g_strncasecmp(buf, "QRY", 3)) {
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1402 } else if (!g_strncasecmp(buf, "REA", 3)) {
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1403 char *friend, *tmp = buf;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1404
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1405 GET_NEXT(tmp);
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1406 GET_NEXT(tmp);
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1407 GET_NEXT(tmp);
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1408 GET_NEXT(tmp);
3456
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3448
diff changeset
1409
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3448
diff changeset
1410 friend = url_decode(tmp);
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1411
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1412 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", friend);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1413 } else if (!g_strncasecmp(buf, "REM", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1414 } else if (!g_strncasecmp(buf, "RNG", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1415 struct msn_switchboard *ms;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1416 char *sessid, *ssaddr, *auth, *user;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1417 int port, i = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1418 char *tmp = buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1419
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1420 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1421 sessid = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1422
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1423 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1424 ssaddr = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1425
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1426 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1427
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1428 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1429 auth = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1430
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1431 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1432 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1433 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1434
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1435 while (ssaddr[i] && ssaddr[i] != ':') i++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1436 if (ssaddr[i] == ':') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1437 char *x = &ssaddr[i + 1];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1438 ssaddr[i] = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1439 port = atoi(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1440 } else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1441 port = 1863;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1442
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1443 ms = g_new0(struct msn_switchboard, 1);
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1444 ms->fd = proxy_connect(ssaddr, port, msn_rng_connect, ms);
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1445 if (ms->fd < 0) {
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1446 g_free(ms);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1447 return 1;
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1448 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1449 ms->user = g_strdup(user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1450 ms->sessid = g_strdup(sessid);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1451 ms->auth = g_strdup(auth);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1452 ms->gc = gc;
3171
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1453 } else if (!g_strncasecmp(buf, "URL", 3)) {
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1454 char *tmp = buf;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1455 FILE *fd;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1456 md5_state_t st;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1457 md5_byte_t di[16];
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1458 int i;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1459 char buf2[64];
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1460 char sendbuf[64];
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1461 char hippy[2048];
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1462 char *rru;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1463 char *passport;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1464
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1465 GET_NEXT(tmp);
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1466 GET_NEXT(tmp);
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1467 rru = tmp;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1468 GET_NEXT(tmp);
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1469 passport = tmp;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1470
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1471 g_snprintf(hippy, sizeof(hippy), "%s%lu%s", md->mspauth, time(NULL) - md->sl, gc->password);
3171
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1472
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1473 md5_init(&st);
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1474 md5_append(&st, (const md5_byte_t *)hippy, strlen(hippy));
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1475 md5_finish(&st, di);
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1476
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1477 bzero(sendbuf, sizeof(sendbuf));
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1478 for (i = 0; i < 16; i++) {
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1479 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]);
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1480 strcat(sendbuf, buf2);
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1481 }
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1482
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
1483 if (md->passport) {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
1484 unlink(md->passport);
3231
b913fc07e18a [gaim-migrate @ 3248]
Jim Seymour <jseymour>
parents: 3200
diff changeset
1485 g_free(md->passport);
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
1486 }
3171
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1487
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1488 if( (fd = gaim_mkstemp(&(md->passport))) == NULL ) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1489 debug_printf("Error opening temp file\n");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1490 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1491 else {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1492 fprintf(fd, "<html>\n");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1493 fprintf(fd, "<head>\n");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1494 fprintf(fd, "<noscript>\n");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1495 fprintf(fd, "<meta http-equiv=Refresh content=\"0; url=http://www.hotmail.com\">\n");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1496 fprintf(fd, "</noscript>\n");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1497 fprintf(fd, "</head>\n\n");
3171
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1498
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1499 fprintf(fd, "<body onload=\"document.pform.submit(); \">\n");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1500 fprintf(fd, "<form name=\"pform\" action=\"%s\" method=\"POST\">\n\n", passport);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1501 fprintf(fd, "<input type=\"hidden\" name=\"mode\" value=\"ttl\">\n");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1502 fprintf(fd, "<input type=\"hidden\" name=\"login\" value=\"%s\">\n", gc->username);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1503 fprintf(fd, "<input type=\"hidden\" name=\"username\" value=\"%s\">\n", gc->username);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1504 fprintf(fd, "<input type=\"hidden\" name=\"sid\" value=\"%s\">\n", md->sid);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1505 fprintf(fd, "<input type=\"hidden\" name=\"kv\" value=\"%s\">\n", md->kv);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1506 fprintf(fd, "<input type=\"hidden\" name=\"id\" value=\"2\">\n");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1507 fprintf(fd, "<input type=\"hidden\" name=\"sl\" value=\"%ld\">\n", time(NULL) - md->sl);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1508 fprintf(fd, "<input type=\"hidden\" name=\"rru\" value=\"%s\">\n", rru);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1509 fprintf(fd, "<input type=\"hidden\" name=\"auth\" value=\"%s\">\n", md->mspauth);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1510 fprintf(fd, "<input type=\"hidden\" name=\"creds\" value=\"%s\">\n", sendbuf); // Digest me
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1511 fprintf(fd, "<input type=\"hidden\" name=\"svc\" value=\"mail\">\n");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1512 fprintf(fd, "<input type=\"hidden\" name=\"js\" value=\"yes\">\n");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1513 fprintf(fd, "</form></body>\n");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1514 fprintf(fd, "</html>\n");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1515 fclose(fd);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
1516 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1517 } else if (!g_strncasecmp(buf, "SYN", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1518 } else if (!g_strncasecmp(buf, "USR", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1519 } else if (!g_strncasecmp(buf, "XFR", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1520 char *host = strstr(buf, "SB");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1521 int port;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1522 int i = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1523 gboolean switchboard = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1524 char *tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1525
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1526 if (!host) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1527 host = strstr(buf, "NS");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1528 if (!host) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1529 hide_login_progress(gc, _("Got invalid XFR\n"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1530 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1531 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1532 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1533 switchboard = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1534 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1535
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1536 GET_NEXT(host);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1537 while (host[i] && host[i] != ':') i++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1538 if (host[i] == ':') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1539 tmp = &host[i + 1];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1540 host[i] = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1541 while (isdigit(*tmp)) tmp++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1542 *tmp++ = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1543 port = atoi(&host[i + 1]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1544 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1545 port = 1863;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1546 tmp = host;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1547 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1548 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1549
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1550 if (switchboard) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1551 struct msn_switchboard *ms = msn_find_writable_switch(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1552 if (!ms)
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1553 return 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1554
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1555 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1556
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1557 ms->fd = proxy_connect(host, port, msn_ss_xfr_connect, ms);
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1558 if (ms->fd < 0) {
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1559 msn_kill_switch(ms);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1560 return 1;
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1561 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1562 ms->auth = g_strdup(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1563 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1564 close(md->fd);
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1565 gaim_input_remove(md->inpa);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1566 md->inpa = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1567 md->fd = proxy_connect(host, port, msn_login_xfr_connect, gc);
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1568 if (md->fd < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1569 hide_login_progress(gc, _("Error transfering"));
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1570 signoff(gc);
2740
68ad186943e0 [gaim-migrate @ 2753]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2739
diff changeset
1571 return 0;
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1572 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1573 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1574 } else if (isdigit(*buf)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1575 handle_errcode(buf, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1576 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1577 debug_printf("Unhandled message!\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1578 }
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1579
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1580 return 1;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1581 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1582
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1583 static void msn_process_main_msg(struct gaim_connection *gc, char *msg)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1584 {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1585 struct msn_data *md = gc->proto_data;
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
1586 char *skiphead;
3171
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1587 char *content;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1588
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1589 content = strstr(msg, "Content-Type: ");
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1590
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1591 if ((content) && (!g_strncasecmp(content, "Content-Type: text/x-msmsgsprofile",
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1592 strlen("Content-Type: text/x-msmsgsprofile")))) {
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1593
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1594 char *kv,*sid,*mspauth;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1595
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1596 kv = strstr(msg, "kv: ");
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1597 sid = strstr(msg, "sid: ");
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1598 mspauth = strstr(msg, "MSPAuth: ");
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1599
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1600 if (kv) {
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1601 char *tmp;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1602
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1603 kv += strlen("kv: ");
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1604 tmp = strstr(kv, "\r\n"); *tmp = 0;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1605 md->kv = g_strdup(kv);
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1606 }
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1607
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1608 if (sid) {
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1609 char *tmp;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1610
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1611 sid += strlen("sid: ");
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1612 tmp = strstr(sid, "\r\n"); *tmp = 0;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1613 md->sid = g_strdup(sid);
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1614 }
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1615
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1616 if (mspauth) {
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1617 char *tmp;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1618
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1619 mspauth += strlen("MSPAuth: ");
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1620 tmp = strstr(mspauth, "\r\n"); *tmp = 0;
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1621 md->mspauth = g_strdup(mspauth);
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1622 }
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1623
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1624 }
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1625
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1626
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1627
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1628 if (!g_strcasecmp(md->msguser, "hotmail")) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1629 handle_hotmail(gc, msg);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1630 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1631 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1632
3171
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1633
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1634 skiphead = strstr(msg, "\r\n\r\n");
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1635 if (!skiphead || !skiphead[4])
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1636 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1637 skiphead += 4;
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
1638 strip_linefeed(skiphead);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1639
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
1640 serv_got_im(gc, md->msguser, skiphead, 0, time(NULL), -1);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1641 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1642
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1643 static void msn_callback(gpointer data, gint source, GaimInputCondition cond)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1644 {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1645 struct gaim_connection *gc = data;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1646 struct msn_data *md = gc->proto_data;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1647 char buf[MSN_BUF_LEN];
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1648 int cont = 1;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1649 int len;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1650
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1651 len = read(md->fd, buf, sizeof(buf));
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1652 if (len <= 0) {
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
1653 hide_login_progress_error(gc, _("Error reading from server"));
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1654 signoff(gc);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1655 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1656 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1657
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1658 md->rxqueue = g_realloc(md->rxqueue, len + md->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1659 memcpy(md->rxqueue + md->rxlen, buf, len);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1660 md->rxlen += len;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1661
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1662 while (cont) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1663 if (!md->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1664 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1665
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1666 if (md->msg) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1667 char *msg;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1668 if (md->msglen > md->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1669 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1670 msg = md->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1671 md->rxlen -= md->msglen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1672 if (md->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1673 md->rxqueue = g_memdup(msg + md->msglen, md->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1674 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1675 md->rxqueue = NULL;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1676 msg = g_realloc(msg, md->msglen + 1);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1677 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1678 msg[md->msglen] = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1679 md->msglen = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1680 md->msg = FALSE;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1681
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1682 msn_process_main_msg(gc, msg);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1683
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1684 g_free(md->msguser);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1685 g_free(msg);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1686 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1687 char *end = md->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1688 int cmdlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1689 char *cmd;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1690 int i = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1691
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1692 while (i + 1 < md->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1693 if (*end == '\r' && end[1] == '\n')
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1694 break;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1695 end++; i++;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1696 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1697 if (i + 1 == md->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1698 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1699
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1700 cmdlen = end - md->rxqueue + 2;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1701 cmd = md->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1702 md->rxlen -= cmdlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1703 if (md->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1704 md->rxqueue = g_memdup(cmd + cmdlen, md->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1705 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1706 md->rxqueue = NULL;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1707 cmd = g_realloc(cmd, cmdlen + 1);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1708 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1709 cmd[cmdlen] = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1710
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1711 debug_printf("MSN S: %s", cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1712 g_strchomp(cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1713 cont = msn_process_main(gc, cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1714
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1715 g_free(cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1716 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1717 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1718 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1719
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1720 static void msn_login_xfr_connect(gpointer data, gint source, GaimInputCondition cond)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1721 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1722 struct gaim_connection *gc = data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1723 struct msn_data *md;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1724 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1725
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1726 if (!g_slist_find(connections, gc)) {
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1727 close(source);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1728 return;
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1729 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1730
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1731 md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1732
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1733 if (md->fd != source)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1734 md->fd = source;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1735
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1736 if (md->fd == -1) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1737 hide_login_progress(gc, _("Unable to connect to Notification Server"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1738 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1739 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1740 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1741
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1742 g_snprintf(buf, sizeof(buf), "VER %d MSNP5\r\n", ++md->trId);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1743 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1744 hide_login_progress(gc, _("Unable to talk to Notification Server"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1745 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1746 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1747 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1748
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1749 md->inpa = gaim_input_add(md->fd, GAIM_INPUT_READ, msn_login_callback, gc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1750 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1751
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1752 static int msn_process_login(struct gaim_connection *gc, char *buf)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1753 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1754 struct msn_data *md = gc->proto_data;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1755 char sendbuf[MSN_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1756
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1757 if (!g_strncasecmp(buf, "VER", 3)) {
2226
2a09a177ed5f [gaim-migrate @ 2236]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2219
diff changeset
1758 /* we got VER, check to see that MSNP5 is in the list, then send INF */
2a09a177ed5f [gaim-migrate @ 2236]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2219
diff changeset
1759 if (!strstr(buf, "MSNP5")) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1760 hide_login_progress(gc, _("Protocol not supported"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1761 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1762 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1763 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1764
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1765 g_snprintf(sendbuf, sizeof(sendbuf), "INF %d\r\n", ++md->trId);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1766 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1767 hide_login_progress(gc, _("Unable to request INF\n"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1768 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1769 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1770 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1771 } else if (!g_strncasecmp(buf, "INF", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1772 /* check to make sure we can use md5 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1773 if (!strstr(buf, "MD5")) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1774 hide_login_progress(gc, _("Unable to login using MD5"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1775 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1776 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1777 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1778
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1779 g_snprintf(sendbuf, sizeof(sendbuf), "USR %d MD5 I %s\r\n", ++md->trId, gc->username);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1780 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1781 hide_login_progress(gc, _("Unable to send USR\n"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1782 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1783 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1784 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1785
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
1786 set_login_progress(gc, 3, _("Requesting to send password"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1787 } else if (!g_strncasecmp(buf, "USR", 3)) {
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1788 char *resp, *friend, *tmp = buf;
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1789
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1790 GET_NEXT(tmp);
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1791 GET_NEXT(tmp);
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1792 resp = tmp;
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1793 GET_NEXT(tmp);
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1794 GET_NEXT(tmp);
3323
3e6e54051e67 [gaim-migrate @ 3341]
Sean Egan <seanegan@gmail.com>
parents: 3322
diff changeset
1795 friend = url_decode(tmp);
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1796 GET_NEXT(tmp);
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1797
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1798 /* so here, we're either getting the challenge or the OK */
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1799 if (!g_strcasecmp(resp, "OK")) {
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1800 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", friend);
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1801
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1802 g_snprintf(sendbuf, sizeof(sendbuf), "SYN %d 0\r\n", ++md->trId);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1803 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1804 hide_login_progress(gc, _("Unable to write"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1805 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1806 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1807 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1808
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1809 gaim_input_remove(md->inpa);
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1810 md->inpa = gaim_input_add(md->fd, GAIM_INPUT_READ, msn_callback, gc);
2739
7aeedbf29a96 [gaim-migrate @ 2752]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2738
diff changeset
1811 return 0;
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1812 } else if (!g_strcasecmp(resp, "MD5")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1813 char buf2[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1814 md5_state_t st;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1815 md5_byte_t di[16];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1816 int i;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1817
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1818 g_snprintf(buf2, sizeof(buf2), "%s%s", friend, gc->password);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1819
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1820 md5_init(&st);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1821 md5_append(&st, (const md5_byte_t *)buf2, strlen(buf2));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1822 md5_finish(&st, di);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1823
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1824 g_snprintf(sendbuf, sizeof(sendbuf), "USR %d MD5 S ", ++md->trId);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1825 for (i = 0; i < 16; i++) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1826 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1827 strcat(sendbuf, buf2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1828 }
3321
1a1a4243a12c [gaim-migrate @ 3339]
Adam Fritzler <mid@auk.cx>
parents: 3299
diff changeset
1829 strcat(sendbuf, "\r\n");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1830
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1831 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
1832 hide_login_progress(gc, _("Unable to send password"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1833 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1834 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1835 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1836
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
1837 set_login_progress(gc, 4, _("Password sent"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1838 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1839 } else if (!g_strncasecmp(buf, "XFR", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1840 char *host = strstr(buf, "NS");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1841 int port;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1842 int i = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1843
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1844 if (!host) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1845 hide_login_progress(gc, _("Got invalid XFR\n"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1846 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1847 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1848 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1849
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1850 GET_NEXT(host);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1851 while (host[i] && host[i] != ':') i++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1852 if (host[i] == ':') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1853 char *x = &host[i + 1];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1854 host[i] = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1855 port = atoi(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1856 } else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1857 port = 1863;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1858
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1859 close(md->fd);
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1860 gaim_input_remove(md->inpa);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1861 md->inpa = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1862 md->fd = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1863 md->fd = proxy_connect(host, port, msn_login_xfr_connect, gc);
3171
d71c23e4d1c2 [gaim-migrate @ 3187]
Rob Flynn <gaim@robflynn.com>
parents: 3170
diff changeset
1864 md->sl = time(NULL);
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1865 if (md->fd < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1866 hide_login_progress(gc, _("Unable to transfer"));
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1867 signoff(gc);
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1868 }
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1869 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1870 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1871 if (isdigit(*buf))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1872 hide_login_progress(gc, handle_errcode(buf, FALSE));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1873 else
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
1874 hide_login_progress(gc, _("Unable to parse message"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1875 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1876 return 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1877 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1878
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1879 return 1;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1880 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1881
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1882 static void msn_login_callback(gpointer data, gint source, GaimInputCondition cond)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1883 {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1884 struct gaim_connection *gc = data;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1885 struct msn_data *md = gc->proto_data;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1886 char buf[MSN_BUF_LEN];
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1887 int cont = 1;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1888 int len;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1889
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1890 len = read(md->fd, buf, sizeof(buf));
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1891 if (len <= 0) {
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
1892 hide_login_progress(gc, _("Error reading from server"));
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1893 signoff(gc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1894 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1895 }
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1896
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1897 md->rxqueue = g_realloc(md->rxqueue, len + md->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1898 memcpy(md->rxqueue + md->rxlen, buf, len);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1899 md->rxlen += len;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1900
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1901 while (cont) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1902 char *end = md->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1903 int cmdlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1904 char *cmd;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1905 int i = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1906
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1907 if (!md->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1908 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1909
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1910 while (i + 1 < md->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1911 if (*end == '\r' && end[1] == '\n')
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1912 break;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1913 end++; i++;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1914 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1915 if (i + 1 == md->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1916 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1917
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1918 cmdlen = end - md->rxqueue + 2;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1919 cmd = md->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1920 md->rxlen -= cmdlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1921 if (md->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1922 md->rxqueue = g_memdup(cmd + cmdlen, md->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1923 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1924 md->rxqueue = NULL;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1925 cmd = g_realloc(cmd, cmdlen + 1);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1926 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1927 cmd[cmdlen] = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1928
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1929 debug_printf("MSN S: %s", cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1930 g_strchomp(cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1931 cont = msn_process_login(gc, cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1932
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1933 g_free(cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1934 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1935 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1936
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1937 static void msn_login_connect(gpointer data, gint source, GaimInputCondition cond)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1938 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1939 struct gaim_connection *gc = data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1940 struct msn_data *md;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1941 char buf[1024];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1942
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1943 if (!g_slist_find(connections, gc)) {
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1944 close(source);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1945 return;
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1946 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1947
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1948 md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1949
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1950 if (md->fd != source)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1951 md->fd = source;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1952
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1953 if (md->fd == -1) {
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
1954 hide_login_progress(gc, _("Unable to connect"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1955 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1956 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1957 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1958
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1959 g_snprintf(buf, sizeof(buf), "VER %d MSNP5\r\n", ++md->trId);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1960 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
1961 hide_login_progress(gc, _("Unable to write to server"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1962 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1963 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1964 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1965
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1966 md->inpa = gaim_input_add(md->fd, GAIM_INPUT_READ, msn_login_callback, gc);
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
1967 set_login_progress(gc, 2,_("Synching with server"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1968 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1969
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1970 static void msn_login(struct aim_user *user)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1971 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1972 struct gaim_connection *gc = new_gaim_conn(user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1973 struct msn_data *md = gc->proto_data = g_new0(struct msn_data, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1974
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
1975 set_login_progress(gc, 1, _("Connecting"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1976
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1977 g_snprintf(gc->username, sizeof(gc->username), "%s", msn_normalize(gc->username));
3322
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3321
diff changeset
1978
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3321
diff changeset
1979 md->fd = proxy_connect(user->proto_opt[USEROPT_MSNSERVER][0] ? user->proto_opt[USEROPT_MSNSERVER] : MSN_SERVER,
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3321
diff changeset
1980 user->proto_opt[USEROPT_MSNPORT][0] ? atoi(user->proto_opt[USEROPT_MSNPORT]) : MSN_PORT,
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3321
diff changeset
1981 msn_login_connect, gc);
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1982 if (md->fd < 0) {
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
1983 hide_login_progress(gc, _("Unable to connect"));
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1984 signoff(gc);
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1985 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1986 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1987
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1988 static void msn_close(struct gaim_connection *gc)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1989 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1990 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1991 close(md->fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1992 if (md->inpa)
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1993 gaim_input_remove(md->inpa);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1994 g_free(md->rxqueue);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1995 if (md->msg)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1996 g_free(md->msguser);
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
1997 if (md->passport) {
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
1998 unlink(md->passport);
3231
b913fc07e18a [gaim-migrate @ 3248]
Jim Seymour <jseymour>
parents: 3200
diff changeset
1999 g_free(md->passport);
3195
92a763567ddc [gaim-migrate @ 3212]
Sean Egan <seanegan@gmail.com>
parents: 3175
diff changeset
2000 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2001 while (md->switches)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2002 msn_kill_switch(md->switches->data);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2003 while (md->fl) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2004 struct msn_buddy *tmp = md->fl->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2005 md->fl = g_slist_remove(md->fl, tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2006 g_free(tmp->user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2007 g_free(tmp->friend);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2008 g_free(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2009 }
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2010 g_slist_free(md->permit);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2011 g_slist_free(md->deny);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2012 g_free(md);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2013 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2014
3001
87fff45fa36b [gaim-migrate @ 3014]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2015 static int msn_send_typing(struct gaim_connection *gc, char *who, int typing) {
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2016 struct msn_switchboard *ms = msn_find_switch(gc, who);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2017 char header[MSN_BUF_LEN] = "MIME-Version: 1.0\r\n"
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2018 "Content-Type: text/x-msmsgscontrol\r\n"
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2019 "TypingUser: ";
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2020 char buf [MSN_BUF_LEN];
3001
87fff45fa36b [gaim-migrate @ 3014]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2021 if (!ms || !typing)
87fff45fa36b [gaim-migrate @ 3014]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
2022 return 0;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2023 g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s\r\n\r\n\r\n",
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2024 ++ms->trId,
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2025 strlen(header) + strlen("\r\n\r\n\r\n") + strlen(gc->username),
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2026 header, gc->username);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2027 if (msn_write(ms->fd, buf, strlen(buf)) < 0)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2028 msn_kill_switch(ms);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2029 return MSN_TYPING_SEND_TIMEOUT;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2030 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2031
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2032 /* XXX Don't blame me. I stole this from the oscar module! */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2033 static struct msn_file_transfer *find_mft_by_xfer(struct gaim_connection *gc,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2034 struct file_transfer *xfer)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2035 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2036 GSList *g = ((struct msn_data *)gc->proto_data)->file_transfers;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2037 struct msn_file_transfer *f = NULL;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2038
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2039 while (g) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2040 f = (struct msn_file_transfer *)g->data;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2041 if (f->xfer == xfer)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2042 break;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2043
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2044 g = g->next;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2045 f = NULL;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2046 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2047
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2048 return f;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2049 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2050
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2051 /* XXX Don't blame me. I stole this from the oscar module! */
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2052 static struct msn_file_transfer *find_mft_by_cookie(struct gaim_connection *gc,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2053 unsigned long cookie)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2054 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2055 GSList *g = ((struct msn_data *)gc->proto_data)->file_transfers;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2056 struct msn_file_transfer *f = NULL;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2057
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2058 while (g) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2059 f = (struct msn_file_transfer *)g->data;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2060 if (f->cookie == cookie)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2061 break;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2062
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2063 g = g->next;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2064 f = NULL;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2065 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2066
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2067 return f;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2068 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2069
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2070 static void msn_file_transfer_cancel(struct gaim_connection *gc,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2071 struct file_transfer *xfer)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2072 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2073 struct msn_data *md = gc->proto_data;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2074 struct msn_file_transfer *mft = find_mft_by_xfer(gc, xfer);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2075 struct msn_switchboard *ms = msn_find_switch(gc, mft->sn);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2076 char header[MSN_BUF_LEN];
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2077 char buf[MSN_BUF_LEN];
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2078
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2079 if (!ms || !mft)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2080 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2081 debug_printf("Eep! Returning from msn_file_transfer_cancel early");
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2082 return;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2083 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2084
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2085 g_snprintf(header, sizeof(header),
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2086 "MIME-Version: 1.0\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2087 "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2088 "Invitation-Command: CANCEL\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2089 "Invitation-Cookie: %ld\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2090 "Cancel-Code: REJECT\r\n",
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2091 mft->cookie);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2092
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2093 g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s\r\n\r\n",
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2094 ++ms->trId, strlen(header) + strlen("\r\n\r\n"),
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2095 header);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2096
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2097 md->file_transfers = g_slist_remove(md->file_transfers, mft);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2098
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2099 if (msn_write(ms->fd, buf, strlen(buf)) < 0)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2100 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2101 debug_printf("Uh oh! Killing switch.\n");
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2102 msn_kill_switch(ms);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2103 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2104 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2105
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2106 static void msn_file_transfer_in(struct gaim_connection *gc,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2107 struct file_transfer *xfer, int offset)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2108 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2109 struct msn_file_transfer *mft = find_mft_by_xfer(gc, xfer);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2110 struct msn_switchboard *ms = msn_find_switch(gc, mft->sn);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2111 char header[MSN_BUF_LEN];
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2112 char buf[MSN_BUF_LEN];
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2113
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2114 if (!ms || !mft)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2115 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2116 debug_printf("Eep! Returning from msn_file_transfer_in early");
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2117 return;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2118 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2119
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2120 g_snprintf(header, sizeof(header),
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2121 "MIME-Version: 1.0\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2122 "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2123 "Invitation-Command: ACCEPT\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2124 "Invitation-Cookie: %ld\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2125 "Launch-Application: FALSE\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2126 "Request-Data: IP-Address:\r\n",
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2127 mft->cookie);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2128
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2129 g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s\r\n\r\n",
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2130 ++ms->trId, strlen(header) + strlen("\r\n\r\n"),
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2131 header);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2132
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2133 if (msn_write(ms->fd, buf, strlen(buf)) < 0) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2134 msn_kill_switch(ms);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2135 return;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2136 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2137
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2138 mft->xfer = xfer;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2139 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2140
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2141 static void msn_file_transfer_out(struct gaim_connection *gc,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2142 struct file_transfer *xfer,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2143 const char *name, int totfiles, int totsize)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2144 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2145 struct msn_file_transfer *mft = find_mft_by_xfer(gc, xfer);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2146 struct msn_switchboard *ms = msn_find_switch(gc, mft->sn);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2147 char header[MSN_BUF_LEN];
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2148 char buf[MSN_BUF_LEN];
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2149 struct stat sb;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2151 if (!ms)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2152 return;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2153
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2154 if (totfiles > 1)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2155 return;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2156
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2157 if (stat(name, &sb) == -1)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2158 return;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2159
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2160 mft->cookie = 1 + (int)(sizeof(unsigned long) * rand() / (RAND_MAX + 1.0));
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2161
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2162 g_snprintf(header, sizeof(header),
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2163 "MIME-Version: 1.0\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2164 "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2165 "Application-Name: File Transfer\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2166 "Application-GUID: {5D3E02AB-6190-11d3-BBBB-00C04F795683}\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2167 "Invitation-Command: INVITE\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2168 "Invitation-Cookie: %ld\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2169 "Application-File: %s\r\n"
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2170 "Application-FileSize: %ld\r\n",
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2171 mft->cookie, name, sb.st_size);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2172
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2173 g_snprintf(buf, sizeof(buf), "MSG %d A %d\r\n%s\r\n\r\n",
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2174 ++ms->trId,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2175 strlen(header) + strlen("\r\n\r\n"),
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2176 header);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2177
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2178 if (msn_write(ms->fd, buf, strlen(buf)) < 0)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2179 msn_kill_switch(ms);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2180
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2181 debug_printf("\n");
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2182 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2183
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2184 static void msn_file_transfer_done(struct gaim_connection *gc,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2185 struct file_transfer *xfer)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2186 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2187 struct msn_data *md = (struct msn_data *)gc->proto_data;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2188 struct msn_file_transfer *mft = find_mft_by_xfer(gc, xfer);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2189 char buf[MSN_BUF_LEN];
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2190
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2191 g_snprintf(buf, sizeof(buf), "BYE 16777989\r\n");
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2192
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2193 msn_write(mft->fd, buf, strlen(buf));
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2194
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2195 md->file_transfers = g_slist_remove(md->file_transfers, mft);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2196
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2197 gaim_input_remove(mft->inpa);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2198
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2199 close(mft->fd);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2200
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2201 g_free(mft->filename);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2202 g_free(mft->sn);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2203 g_free(mft);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2204 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2205
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2206 static size_t msn_file_transfer_read(struct gaim_connection *gc,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2207 struct file_transfer *xfer, int fd,
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2208 char **buf)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2209 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2210 unsigned char header[3];
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2211 size_t len, size;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2212
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2213 if (read(fd, header, sizeof(header)) < 3)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2214 return 0;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2215
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2216 if (header[0] != 0) {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2217 debug_printf("Invalid header[0]: %d. Aborting.\n", header[0]);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2218 return 0;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2219 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2220
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2221 size = header[1] | (header[2] << 8);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2222
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2223 *buf = g_new0(char, size);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2224
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2225 for (len = 0; len < size; len += read(fd, *buf + len, size - len));
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2226
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2227 return len;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2228 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2229
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3020
diff changeset
2230 static int msn_send_im(struct gaim_connection *gc, char *who, char *message, int len, int flags)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2231 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2232 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2233 struct msn_switchboard *ms = msn_find_switch(gc, who);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2234 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2235
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2236 if (ms) {
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
2237 char *send;
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2238
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2239 if (ms->txqueue) {
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2240 debug_printf("appending to queue\n");
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2241 ms->txqueue = g_slist_append(ms->txqueue, g_strdup(message));
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2242 return 1;
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2243 }
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2244
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2245 send = add_cr(message);
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
2246 g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s", ++ms->trId,
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
2247 strlen(MIME_HEADER) + strlen(send),
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
2248 MIME_HEADER, send);
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2249 g_free(send);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2250 if (msn_write(ms->fd, buf, strlen(buf)) < 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2251 msn_kill_switch(ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2252 debug_printf("\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2253 } else if (strcmp(who, gc->username)) {
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2254 g_snprintf(buf, MSN_BUF_LEN, "XFR %d SB\r\n", ++md->trId);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2255 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2256 hide_login_progress(gc, _("Write error"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2257 signoff(gc);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2258 return 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2259 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2260
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2261 ms = g_new0(struct msn_switchboard, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2262 md->switches = g_slist_append(md->switches, ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2263 ms->user = g_strdup(who);
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2264 ms->txqueue = g_slist_append(ms->txqueue, g_strdup(message));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2265 ms->gc = gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2266 ms->fd = -1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2267 } else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2268 /* in msn you can't send messages to yourself, so we'll fake like we received it ;) */
2856
b1e300a85678 [gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2842
diff changeset
2269 serv_got_im(gc, who, message, flags | IM_FLAG_GAIMUSER, time(NULL), -1);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
2270 return 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2271 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2272
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
2273 static int msn_chat_send(struct gaim_connection *gc, int id, char *message)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2274 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2275 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2276 char buf[MSN_BUF_LEN];
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
2277 char *send;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2278
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2279 if (!ms)
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
2280 return -EINVAL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2281
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2282 send = add_cr(message);
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
2283 g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s", ++ms->trId,
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
2284 strlen(MIME_HEADER) + strlen(send),
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
2285 MIME_HEADER, send);
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2286 g_free(send);
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2287 if (msn_write(ms->fd, buf, strlen(buf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2288 msn_kill_switch(ms);
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2289 return 0;
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2290 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2291 debug_printf("\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2292 serv_got_chat_in(gc, id, gc->username, 0, message, time(NULL));
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
2293 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2294 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2295
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3456
diff changeset
2296 static void msn_chat_invite(struct gaim_connection *gc, int id, const char *msg, const char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2297 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2298 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2299 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2300
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2301 if (!ms)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2302 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2303
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2304 g_snprintf(buf, sizeof(buf), "CAL %d %s\r\n", ++ms->trId, who);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2305 if (msn_write(ms->fd, buf, strlen(buf)) < 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2306 msn_kill_switch(ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2307 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2308
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2309 static void msn_chat_leave(struct gaim_connection *gc, int id)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2310 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2311 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2312 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2313
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2314 if (!ms)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2315 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2316
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2317 g_snprintf(buf, sizeof(buf), "OUT\r\n");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2318 if (msn_write(ms->fd, buf, strlen(buf)) < 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2319 msn_kill_switch(ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2320 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2321
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
2322 static GList *msn_away_states(struct gaim_connection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2323 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2324 GList *m = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2325
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
2326 m = g_list_append(m, _("Available"));
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
2327 m = g_list_append(m, _("Away From Computer"));
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
2328 m = g_list_append(m, _("Be Right Back"));
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
2329 m = g_list_append(m, _("Busy"));
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
2330 m = g_list_append(m, _("On The Phone"));
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
2331 m = g_list_append(m, _("Out To Lunch"));
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
2332 m = g_list_append(m, _("Hidden"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2333
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2334 return m;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2335 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2336
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2337 static void msn_set_away(struct gaim_connection *gc, char *state, char *msg)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2338 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2339 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2340 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2341 char *away;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2342
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4069
diff changeset
2343 if (gc->away) {
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4069
diff changeset
2344 g_free(gc->away);
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4069
diff changeset
2345 gc->away = NULL;
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4069
diff changeset
2346 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2347
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2348 if (msg) {
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4069
diff changeset
2349 gc->away = g_strdup("");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2350 away = "AWY";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2351 } else if (state) {
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4069
diff changeset
2352 gc->away = g_strdup("");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2353
3538
9431b31f8f62 [gaim-migrate @ 3612]
Luke Schierer <lschiere@pidgin.im>
parents: 3504
diff changeset
2354 if (!strcmp(state, _("Away From Computer")))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2355 away = "AWY";
3538
9431b31f8f62 [gaim-migrate @ 3612]
Luke Schierer <lschiere@pidgin.im>
parents: 3504
diff changeset
2356 else if (!strcmp(state, _("Be Right Back")))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2357 away = "BRB";
3538
9431b31f8f62 [gaim-migrate @ 3612]
Luke Schierer <lschiere@pidgin.im>
parents: 3504
diff changeset
2358 else if (!strcmp(state, _("Busy")))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2359 away = "BSY";
3538
9431b31f8f62 [gaim-migrate @ 3612]
Luke Schierer <lschiere@pidgin.im>
parents: 3504
diff changeset
2360 else if (!strcmp(state, _("On The Phone")))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2361 away = "PHN";
3538
9431b31f8f62 [gaim-migrate @ 3612]
Luke Schierer <lschiere@pidgin.im>
parents: 3504
diff changeset
2362 else if (!strcmp(state, _("Out To Lunch")))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2363 away = "LUN";
3538
9431b31f8f62 [gaim-migrate @ 3612]
Luke Schierer <lschiere@pidgin.im>
parents: 3504
diff changeset
2364 else if (!strcmp(state, _("Hidden")))
2152
f631cfc8e824 [gaim-migrate @ 2162]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2123
diff changeset
2365 away = "HDN";
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2366 else {
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4069
diff changeset
2367 g_free(gc->away);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2368 gc->away = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2369 away = "NLN";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2370 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2371 } else if (gc->is_idle)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2372 away = "IDL";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2373 else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2374 away = "NLN";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2375
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2376 g_snprintf(buf, sizeof(buf), "CHG %d %s\r\n", ++md->trId, away);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2377 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2378 hide_login_progress(gc, _("Write error"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2379 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2380 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2381 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2382 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2383
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2384 static void msn_set_idle(struct gaim_connection *gc, int idle)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2385 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2386 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2387 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2388
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2389 if (gc->away)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2390 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2391 if (idle)
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2392 g_snprintf(buf, sizeof(buf), "CHG %d IDL\r\n", ++md->trId);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2393 else
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2394 g_snprintf(buf, sizeof(buf), "CHG %d NLN\r\n", ++md->trId);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2395 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2396 hide_login_progress(gc, _("Write error"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2397 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2398 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2399 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2400 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2401
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2402 static char **msn_list_icon(int uc)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2403 {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
2404 if (uc == 0)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2405 return msn_online_xpm;
3175
1c351bbdebf0 [gaim-migrate @ 3191]
Rob Flynn <gaim@robflynn.com>
parents: 3171
diff changeset
2406
1c351bbdebf0 [gaim-migrate @ 3191]
Rob Flynn <gaim@robflynn.com>
parents: 3171
diff changeset
2407 uc >>= 1;
1c351bbdebf0 [gaim-migrate @ 3191]
Rob Flynn <gaim@robflynn.com>
parents: 3171
diff changeset
2408
1c351bbdebf0 [gaim-migrate @ 3191]
Rob Flynn <gaim@robflynn.com>
parents: 3171
diff changeset
2409 if (uc == 2 || uc == 6)
1c351bbdebf0 [gaim-migrate @ 3191]
Rob Flynn <gaim@robflynn.com>
parents: 3171
diff changeset
2410 return msn_occ_xpm;
1c351bbdebf0 [gaim-migrate @ 3191]
Rob Flynn <gaim@robflynn.com>
parents: 3171
diff changeset
2411
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2412 return msn_away_xpm;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2413 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2414
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2415 static char *msn_get_away_text(int s)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2416 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2417 switch (s) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2418 case MSN_BUSY :
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2419 return _("Busy");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2420 case MSN_BRB :
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2421 return _("Be right back");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2422 case MSN_AWAY :
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2423 return _("Away from the computer");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2424 case MSN_PHONE :
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2425 return _("On the phone");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2426 case MSN_LUNCH :
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2427 return _("Out to lunch");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2428 case MSN_IDLE :
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2429 return _("Idle");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2430 default:
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2431 return _("Available");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2432 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2433 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2434
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2435 static void msn_ask_send_file(struct gaim_connection *gc, char *destsn)
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2436 {
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2437 struct msn_data *md = (struct msn_data *)gc->proto_data;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2438 struct msn_file_transfer *mft = g_new0(struct msn_file_transfer, 1);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2439
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2440 mft->type = MFT_SENDFILE_OUT;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2441 mft->sn = g_strdup(destsn);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2442 mft->gc = gc;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2443
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2444 md->file_transfers = g_slist_append(md->file_transfers, mft);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2445
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2446 mft->xfer = transfer_out_add(gc, mft->sn);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2447 }
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2448
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
2449 static GList *msn_buddy_menu(struct gaim_connection *gc, char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2450 {
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
2451 GList *m = NULL;
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
2452 struct proto_buddy_menu *pbm;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2453 struct buddy *b = find_buddy(gc, who);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
2454 static char buf[MSN_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2455
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
2456 pbm = g_new0(struct proto_buddy_menu, 1);
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2457 pbm->label = _("Send File");
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2458 pbm->callback = msn_ask_send_file;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2459 pbm->gc = gc;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2460 m = g_list_append(m, pbm);
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2461
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
2462 if (!b || !(b->uc >> 1))
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
2463 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2464
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
2465 pbm = g_new0(struct proto_buddy_menu, 1);
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
2466 g_snprintf(buf, sizeof(buf), _("Status: %s"), msn_get_away_text(b->uc >> 1));
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
2467 pbm->label = buf;
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
2468 pbm->callback = NULL;
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
2469 pbm->gc = gc;
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
2470 m = g_list_append(m, pbm);
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
2471
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
2472 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2473 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2474
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3456
diff changeset
2475 static void msn_add_buddy(struct gaim_connection *gc, const char *name)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2476 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2477 struct msn_data *md = gc->proto_data;
2588
a3117e29317d [gaim-migrate @ 2601]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2582
diff changeset
2478 char *who = msn_normalize(name);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2479 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2480 GSList *l = md->fl;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2481
2600
8aade06646b5 [gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
2482 if (who[0] == '@')
8aade06646b5 [gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
2483 /* how did this happen? */
8aade06646b5 [gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
2484 return;
8aade06646b5 [gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
2485
2953
fa76b0156259 [gaim-migrate @ 2966]
Rob Flynn <gaim@robflynn.com>
parents: 2952
diff changeset
2486 if (strchr(who, ' '))
2952
7a32dca869a8 [gaim-migrate @ 2965]
Rob Flynn <gaim@robflynn.com>
parents: 2932
diff changeset
2487 /* This is a broken blist entry. */
7a32dca869a8 [gaim-migrate @ 2965]
Rob Flynn <gaim@robflynn.com>
parents: 2932
diff changeset
2488 return;
7a32dca869a8 [gaim-migrate @ 2965]
Rob Flynn <gaim@robflynn.com>
parents: 2932
diff changeset
2489
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2490 while (l) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2491 struct msn_buddy *b = l->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2492 if (!g_strcasecmp(who, b->user))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2493 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2494 l = l->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2495 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2496 if (l)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2497 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2498
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2499 g_snprintf(buf, sizeof(buf), "ADD %d FL %s %s\r\n", ++md->trId, who, who);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2500 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2501 hide_login_progress(gc, _("Write error"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2502 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2503 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2504 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2505 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2506
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2665
diff changeset
2507 static void msn_rem_buddy(struct gaim_connection *gc, char *who, char *group)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2508 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2509 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2510 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2511
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2512 g_snprintf(buf, sizeof(buf), "REM %d FL %s\r\n", ++md->trId, who);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2513 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2514 hide_login_progress(gc, _("Write error"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2515 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2516 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2517 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2518 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2519
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2520 static void msn_act_id(gpointer data, char *entry)
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2521 {
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2522 struct gaim_connection *gc = data;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2523 struct msn_data *md = gc->proto_data;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2524 char buf[MSN_BUF_LEN];
3323
3e6e54051e67 [gaim-migrate @ 3341]
Sean Egan <seanegan@gmail.com>
parents: 3322
diff changeset
2525 char *alias;
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2526
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3456
diff changeset
2527 if (!entry || *entry == '\0')
3448
0a0cc45267d4 [gaim-migrate @ 3490]
Sean Egan <seanegan@gmail.com>
parents: 3447
diff changeset
2528 alias = g_strdup("");
0a0cc45267d4 [gaim-migrate @ 3490]
Sean Egan <seanegan@gmail.com>
parents: 3447
diff changeset
2529 else
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3630
diff changeset
2530 alias = g_strdup(entry);
3323
3e6e54051e67 [gaim-migrate @ 3341]
Sean Egan <seanegan@gmail.com>
parents: 3322
diff changeset
2531
3e6e54051e67 [gaim-migrate @ 3341]
Sean Egan <seanegan@gmail.com>
parents: 3322
diff changeset
2532 if (strlen(alias) >= BUDDY_ALIAS_MAXLEN) {
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
2533 do_error_dialog(_("New MSN friendly name too long."), NULL, GAIM_ERROR);
3020
c3a29bd2a2d7 [gaim-migrate @ 3033]
Sean Egan <seanegan@gmail.com>
parents: 3018
diff changeset
2534 return;
c3a29bd2a2d7 [gaim-migrate @ 3033]
Sean Egan <seanegan@gmail.com>
parents: 3018
diff changeset
2535 }
c3a29bd2a2d7 [gaim-migrate @ 3033]
Sean Egan <seanegan@gmail.com>
parents: 3018
diff changeset
2536
3456
b48065e52337 [gaim-migrate @ 3503]
Sean Egan <seanegan@gmail.com>
parents: 3448
diff changeset
2537 g_snprintf(buf, sizeof(buf), "REA %d %s %s\r\n", ++md->trId, gc->username, url_encode(alias));
3323
3e6e54051e67 [gaim-migrate @ 3341]
Sean Egan <seanegan@gmail.com>
parents: 3322
diff changeset
2538 g_free(alias);
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2539 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2540 hide_login_progress(gc, _("Write error"));
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2541 signoff(gc);
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2542 return;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2543 }
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2544 }
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2545
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2546 static void msn_do_action(struct gaim_connection *gc, char *act)
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2547 {
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
2548 if (!strcmp(act, _("Set Friendly Name"))) {
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
2549 do_prompt_dialog(_("Set Friendly Name:"), gc->displayname, gc, msn_act_id, NULL);
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2550 }
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2551 }
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2552
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2553 static GList *msn_actions()
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2554 {
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2555 GList *m = NULL;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2556
3263
73fd73188485 [gaim-migrate @ 3281]
Rob Flynn <gaim@robflynn.com>
parents: 3231
diff changeset
2557 m = g_list_append(m, _("Set Friendly Name"));
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2558
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2559 return m;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2560 }
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2561
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2562 static void msn_convo_closed(struct gaim_connection *gc, char *who)
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2563 {
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2564 struct msn_switchboard *ms = msn_find_switch(gc, who);
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2565
4069
5b56c42c2717 [gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents: 4068
diff changeset
2566 if (ms) {
5b56c42c2717 [gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents: 4068
diff changeset
2567 char sendbuf[256];
5b56c42c2717 [gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents: 4068
diff changeset
2568
5b56c42c2717 [gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents: 4068
diff changeset
2569 g_snprintf(sendbuf, sizeof(sendbuf), "BYE %s\r\n", gc->username);
5b56c42c2717 [gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents: 4068
diff changeset
2570
5b56c42c2717 [gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents: 4068
diff changeset
2571 msn_write(ms->fd, sendbuf, strlen(sendbuf));
5b56c42c2717 [gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents: 4068
diff changeset
2572
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2573 msn_kill_switch(ms);
4069
5b56c42c2717 [gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents: 4068
diff changeset
2574 }
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2575 }
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2576
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2577 static void msn_keepalive(struct gaim_connection *gc)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2578 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2579 struct msn_data *md = gc->proto_data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2580 char buf[MSN_BUF_LEN];
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2581
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2582 g_snprintf(buf, sizeof(buf), "PNG\r\n");
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2583 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2584 hide_login_progress(gc, _("Write error"));
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2585 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2586 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2587 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2588 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2589
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2590 static void msn_set_permit_deny(struct gaim_connection *gc)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2591 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2592 struct msn_data *md = gc->proto_data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2593 char buf[MSN_BUF_LEN];
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2594 GSList *s, *t = NULL;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2595
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2596 if (gc->permdeny == PERMIT_ALL || gc->permdeny == DENY_SOME)
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2597 g_snprintf(buf, sizeof(buf), "BLP %d AL\r\n", ++md->trId);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2598 else
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2599 g_snprintf(buf, sizeof(buf), "BLP %d BL\r\n", ++md->trId);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2600
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2601 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2602 hide_login_progress(gc, _("Write error"));
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2603 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2604 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2605 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2606
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2607 /* this is safe because we'll always come here after we've gotten the list off the server,
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2608 * and data is never removed. So if the lengths are equal we don't know about anyone locally
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2609 * and so there's no sense in going through them all. */
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2610 if (g_slist_length(gc->permit) == g_slist_length(md->permit)) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2611 g_slist_free(md->permit);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2612 md->permit = NULL;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2613 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2614 if (g_slist_length(gc->deny) == g_slist_length(md->deny)) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2615 g_slist_free(md->deny);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2616 md->deny = NULL;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2617 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2618 if (!md->permit && !md->deny)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2619 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2620
3200
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2621 if (md->permit) {
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2622 s = g_slist_nth(gc->permit, g_slist_length(md->permit));
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2623 while (s) {
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2624 char *who = s->data;
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2625 char *dupl;
3200
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2626 s = s->next;
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2627 if (!strchr(who, '@')) {
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2628 t = g_slist_append(t, who);
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2629 continue;
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2630 }
3296
56df4d1dcad5 [gaim-migrate @ 3314]
Sean Egan <seanegan@gmail.com>
parents: 3295
diff changeset
2631 if ((dupl = (char *)g_slist_find(md->deny, who))) {
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2632 t = g_slist_append(t, who);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2633 continue;
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2634 }
3200
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2635 g_snprintf(buf, sizeof(buf), "ADD %d AL %s %s\r\n", ++md->trId, who, who);
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2636 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2637 hide_login_progress(gc, _("Write error"));
3200
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2638 signoff(gc);
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2639 return;
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2640 }
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2641 }
3200
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2642 while (t) {
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2643 char *who = t->data;
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2644 gc->permit = g_slist_remove(gc->permit, who);
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2645 g_free(who);
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2646 t = t->next;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2647 }
3200
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2648 if (t)
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2649 g_slist_free(t);
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2650 t = NULL;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2651 g_slist_free(md->permit);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2652 md->permit = NULL;
3200
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2653 }
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2654
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2655 if (md->deny) {
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2656 s = g_slist_nth(gc->deny, g_slist_length(md->deny));
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2657 while (s) {
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2658 char *who = s->data;
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2659 char *dupl;
3200
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2660 s = s->next;
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2661 if (!strchr(who, '@')) {
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2662 t = g_slist_append(t, who);
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2663 continue;
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2664 }
3296
56df4d1dcad5 [gaim-migrate @ 3314]
Sean Egan <seanegan@gmail.com>
parents: 3295
diff changeset
2665 if ((dupl = (char *)g_slist_find(md->deny, who))) {
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2666 t = g_slist_append(t, who);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2667 continue;
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2668 }
3200
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2669 g_snprintf(buf, sizeof(buf), "ADD %d BL %s %s\r\n", ++md->trId, who, who);
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2670 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2671 hide_login_progress(gc, _("Write error"));
3200
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2672 signoff(gc);
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2673 return;
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2674 }
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2675 }
3200
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2676 while (t) {
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2677 char *who = t->data;
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2678 gc->deny = g_slist_remove(gc->deny, who);
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2679 g_free(who);
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2680 t = t->next;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2681 }
3200
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2682 if (t)
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2683 g_slist_free(t);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2684 g_slist_free(md->deny);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2685 md->deny = NULL;
3200
c98dc4884ea3 [gaim-migrate @ 3217]
Sean Egan <seanegan@gmail.com>
parents: 3195
diff changeset
2686 }
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2687 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2688
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2689 static void msn_add_permit(struct gaim_connection *gc, char *who)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2690 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2691 struct msn_data *md = gc->proto_data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2692 char buf[MSN_BUF_LEN];
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2693 char *dupl;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2694
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2695 if (!strchr(who, '@')) {
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
2696 g_snprintf(buf, sizeof(buf),
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
2697 _("An MSN screenname must be in the form \"user@server.com\". "
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
2698 "Perhaps you meant %s@hotmail.com. No changes were made to your "
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
2699 "allow list."), who);
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
2700 do_error_dialog(_("Invalid MSN screenname"), buf, GAIM_ERROR);
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2701 gc->permit = g_slist_remove(gc->permit, who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2702 g_free(who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2703 return;
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2704 }
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2705
3296
56df4d1dcad5 [gaim-migrate @ 3314]
Sean Egan <seanegan@gmail.com>
parents: 3295
diff changeset
2706 if ((dupl = (char *)g_slist_find_custom(gc->deny, who,
56df4d1dcad5 [gaim-migrate @ 3314]
Sean Egan <seanegan@gmail.com>
parents: 3295
diff changeset
2707 (GCompareFunc)strcmp))) {
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2708 debug_printf("MSN: Moving %s from BL to AL\n", who);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2709 gc->deny = g_slist_remove(gc->deny, dupl);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2710 g_snprintf(buf, sizeof(buf), "REM %d BL %s\r\n", ++md->trId, who);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2711 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2712 hide_login_progress(gc, _("Write error"));
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2713 signoff(gc);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2714 return;
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2715 }
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2716 }
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2717 g_snprintf(buf, sizeof(buf), "ADD %d AL %s %s\r\n", ++md->trId, who, who);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2718 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2719 hide_login_progress(gc, _("Write error"));
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2720 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2721 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2722 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2723 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2724
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2725 static void msn_rem_permit(struct gaim_connection *gc, char *who)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2726 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2727 struct msn_data *md = gc->proto_data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2728 char buf[MSN_BUF_LEN];
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2729
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2730 g_snprintf(buf, sizeof(buf), "REM %d AL %s\r\n", ++md->trId, who);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2731 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2732 hide_login_progress(gc, _("Write error"));
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2733 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2734 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2735 }
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2736
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2737 g_slist_append(gc->deny, who);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2738 g_snprintf(buf, sizeof(buf), "ADD %d BL %s %s\r\n", ++md->trId, who, who);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2739 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2740 hide_login_progress(gc, _("Write error"));
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2741 signoff(gc);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2742 return;
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2743 }
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2744 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2745
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2746 static void msn_add_deny(struct gaim_connection *gc, char *who)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2747 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2748 struct msn_data *md = gc->proto_data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2749 char buf[MSN_BUF_LEN];
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2750 char *dupl;
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2751
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2752 if (!strchr(who, '@')) {
3427
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
2753 g_snprintf(buf, sizeof(buf),
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
2754 _("An MSN screenname must be in the form \"user@server.com\". "
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
2755 "Perhaps you meant %s@hotmail.com. No changes were made to your "
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
2756 "block list."), who);
8fa61405af2b [gaim-migrate @ 3453]
Sean Egan <seanegan@gmail.com>
parents: 3375
diff changeset
2757 do_error_dialog(_("Invalid MSN screenname"), buf, GAIM_ERROR);
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2758 gc->deny = g_slist_remove(gc->deny, who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2759 g_free(who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2760 return;
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2761 }
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
2762
3296
56df4d1dcad5 [gaim-migrate @ 3314]
Sean Egan <seanegan@gmail.com>
parents: 3295
diff changeset
2763 if ((dupl = (char *)g_slist_find_custom(gc->permit, who,
56df4d1dcad5 [gaim-migrate @ 3314]
Sean Egan <seanegan@gmail.com>
parents: 3295
diff changeset
2764 (GCompareFunc)strcmp))) {
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2765 debug_printf("MSN: Moving %s from AL to BL\n", who);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2766 gc->permit = g_slist_remove(gc->permit, dupl);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2767 g_snprintf(buf, sizeof(buf), "REM %d AL %s\r\n", ++md->trId, who);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2768 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2769 hide_login_progress(gc, _("Write error"));
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2770 signoff(gc);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2771 return;
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2772 }
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2773 }
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2774
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2775
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2776 g_snprintf(buf, sizeof(buf), "ADD %d BL %s %s\r\n", ++md->trId, who, who);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2777 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2778 hide_login_progress(gc, _("Write error"));
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2779 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2780 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2781 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2782 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2783
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2784 static void msn_rem_deny(struct gaim_connection *gc, char *who)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2785 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2786 struct msn_data *md = gc->proto_data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2787 char buf[MSN_BUF_LEN];
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2788
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
2789 g_snprintf(buf, sizeof(buf), "REM %d BL %s\r\n", ++md->trId, who);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2790 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2791 hide_login_progress(gc, _("Write error"));
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2792 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2793 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2794 }
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2795
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2796 g_slist_append(gc->permit, who);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2797 g_snprintf(buf, sizeof(buf), "ADD %d AL %s %s\r\n", ++md->trId, who, who);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2798 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
4056
4f3fb54ee669 [gaim-migrate @ 4266]
Luke Schierer <lschiere@pidgin.im>
parents: 4044
diff changeset
2799 hide_login_progress(gc, _("Write error"));
3294
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2800 signoff(gc);
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2801 return;
f50db65fda5f [gaim-migrate @ 3312]
Sean Egan <seanegan@gmail.com>
parents: 3293
diff changeset
2802 }
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2803 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2804
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
2805 static void msn_buddy_free(struct buddy *b)
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
2806 {
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
2807 if (b->proto_data)
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
2808 g_free(b->proto_data);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
2809 }
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
2810
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
2811 G_MODULE_EXPORT void msn_init(struct prpl *ret)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2812 {
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2813 struct proto_user_opt *puo;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2814 ret->protocol = PROTO_MSN;
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
2815 ret->options = OPT_PROTO_MAIL_CHECK;
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2816 ret->name = g_strdup("MSN");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2817 ret->list_icon = msn_list_icon;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2818 ret->buddy_menu = msn_buddy_menu;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2819 ret->login = msn_login;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2820 ret->close = msn_close;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2821 ret->send_im = msn_send_im;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2970
diff changeset
2822 ret->send_typing = msn_send_typing;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2823 ret->away_states = msn_away_states;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2824 ret->set_away = msn_set_away;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2825 ret->set_idle = msn_set_idle;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2826 ret->add_buddy = msn_add_buddy;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2827 ret->remove_buddy = msn_rem_buddy;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2828 ret->chat_send = msn_chat_send;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2829 ret->chat_invite = msn_chat_invite;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2830 ret->chat_leave = msn_chat_leave;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2831 ret->normalize = msn_normalize;
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2832 ret->do_action = msn_do_action;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
2833 ret->actions = msn_actions;
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
2834 ret->convo_closed = msn_convo_closed;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2835 ret->keepalive = msn_keepalive;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2836 ret->set_permit_deny = msn_set_permit_deny;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2837 ret->add_permit = msn_add_permit;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2838 ret->rem_permit = msn_rem_permit;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2839 ret->add_deny = msn_add_deny;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
2840 ret->rem_deny = msn_rem_deny;
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
2841 ret->buddy_free = msn_buddy_free;
4150
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2842 ret->file_transfer_cancel = msn_file_transfer_cancel;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2843 ret->file_transfer_in = msn_file_transfer_in;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2844 ret->file_transfer_out = msn_file_transfer_out;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2845 ret->file_transfer_done = msn_file_transfer_done;
1bd663beada5 [gaim-migrate @ 4369]
Rob Flynn <gaim@robflynn.com>
parents: 4115
diff changeset
2846 ret->file_transfer_read = msn_file_transfer_read;
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2847
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2848 puo = g_new0(struct proto_user_opt, 1);
4115
474265997752 [gaim-migrate @ 4332]
Luke Schierer <lschiere@pidgin.im>
parents: 4112
diff changeset
2849 puo->label = g_strdup(_("Server:"));
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2850 puo->def = g_strdup(MSN_SERVER);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2851 puo->pos = USEROPT_MSNSERVER;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2852 ret->user_opts = g_list_append(ret->user_opts, puo);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2853
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2854 puo = g_new0(struct proto_user_opt, 1);
4115
474265997752 [gaim-migrate @ 4332]
Luke Schierer <lschiere@pidgin.im>
parents: 4112
diff changeset
2855 puo->label = g_strdup(_("Port:"));
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2856 puo->def = g_strdup("1863");
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2857 puo->pos = USEROPT_MSNPORT;
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2858 ret->user_opts = g_list_append(ret->user_opts, puo);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2859
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2860 my_protocol = ret;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2861 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2862
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2863 #ifndef STATIC
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2864
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
2865 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2866 {
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2867 msn_init(prpl);
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3538
diff changeset
2868 prpl->plug->desc.api_version = PLUGIN_API_VERSION;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2869 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2870
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
2871 G_MODULE_EXPORT void gaim_plugin_remove()
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2872 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2873 struct prpl *p = find_prpl(PROTO_MSN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2874 if (p == my_protocol)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2875 unload_protocol(p);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2876 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2877
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
2878 G_MODULE_EXPORT char *name()
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2879 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2880 return "MSN";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2881 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2882
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3592
diff changeset
2883 G_MODULE_EXPORT char *description()
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2884 {
2162
a464da684307 [gaim-migrate @ 2172]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2153
diff changeset
2885 return PRPL_DESC("MSN");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2886 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2887
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2888 #endif