annotate src/protocols/msn/msn.c @ 2758:269fb9005d13

[gaim-migrate @ 2771] Travis Farley (siege_2004)'s patch committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 19 Nov 2001 09:45:22 +0000
parents 51fc8e5acd7a
children a0fd8f91e294
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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 #include <stdlib.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 #include <string.h>
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
5 #include <errno.h>
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 #include <stdio.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 #include <unistd.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 #include <ctype.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 #include "gaim.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 #include "prpl.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 #include "proxy.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 #include "md5.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 #include "pixmaps/msn_online.xpm"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 #include "pixmaps/msn_away.xpm"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 #define MSN_BUF_LEN 8192
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 #define MIME_HEADER "MIME-Version: 1.0\r\n" \
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 "Content-Type: text/plain; charset=UTF-8\r\n" \
2273
0b5c3338fa3d [gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2265
diff changeset
20 "User-Agent: Gaim/" VERSION "\r\n" \
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 "X-MMS-IM-Format: FN=MS%20Sans%20Serif; EF=; CO=0; PF=0\r\n\r\n"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
23 #define HOTMAIL_URL "http://www.hotmail.com/cgi-bin/folders"
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
24
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 #define MSN_ONLINE 1
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #define MSN_BUSY 2
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #define MSN_IDLE 3
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #define MSN_BRB 4
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #define MSN_AWAY 5
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #define MSN_PHONE 6
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #define MSN_LUNCH 7
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #define MSN_OFFLINE 8
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 #define MSN_HIDDEN 9
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #define USEROPT_HOTMAIL 0
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 struct msn_data {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 int fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 int trId;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 int inpa;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
41
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
42 char *rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
43 int rxlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
44 gboolean msg;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
45 char *msguser;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
46 int msglen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
47
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 GSList *switches;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 GSList *fl;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
50 GSList *permit;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
51 GSList *deny;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 };
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 struct msn_switchboard {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 struct gaim_connection *gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 struct conversation *chat;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 int fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 int inpa;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
59
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
60 char *rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
61 int rxlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
62 gboolean msg;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
63 char *msguser;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
64 int msglen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
65
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 char *sessid;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 char *auth;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 int trId;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 int total;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 char *user;
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
71 GSList *txqueue;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 struct msn_buddy {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 char *user;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 char *friend;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
79 static void msn_login_callback(gpointer, gint, GaimInputCondition);
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
80 static void msn_login_xfr_connect(gpointer, gint, GaimInputCondition);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 #define GET_NEXT(tmp) while (*(tmp) && !isspace(*(tmp))) \
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 (tmp)++; \
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 *(tmp)++ = 0; \
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 while (*(tmp) && isspace(*(tmp))) \
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 (tmp)++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 static char *msn_name()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 return "MSN";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 static char *msn_normalize(const char *s)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 static char buf[BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 g_return_val_if_fail(s != NULL, NULL);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 g_snprintf(buf, sizeof(buf), "%s%s", s, strchr(s, '@') ? "" : "@hotmail.com");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 return buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 static int msn_write(int fd, void *data, int len)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 {
2311
019832e79d9f [gaim-migrate @ 2321]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2303
diff changeset
106 debug_printf("MSN C: %s", data);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 return write(fd, data, len);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 static char *url_decode(const char *msg)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 static char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 int i, j = 0;
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 bzero(buf, sizeof(buf));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 for (i = 0; i < strlen(msg); i++) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 char hex[3];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 if (msg[i] != '%') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 buf[j++] = msg[i];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 continue;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 }
2093
83d8a9b7e89b [gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2090
diff changeset
122 strncpy(hex, msg + ++i, 2); hex[2] = 0;
83d8a9b7e89b [gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2090
diff changeset
123 /* i is pointing to the start of the number */
83d8a9b7e89b [gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2090
diff changeset
124 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
125 will be at the next character */
83d8a9b7e89b [gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2090
diff changeset
126 buf[j++] = strtol(hex, NULL, 16);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 buf[j] = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 return buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132
2219
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
133 static char *url_encode(const char *msg)
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
134 {
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
135 static char buf[MSN_BUF_LEN];
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
136 int i, j = 0;
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
137
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
138 bzero(buf, sizeof(buf));
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
139 for (i = 0; i < strlen(msg); i++) {
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
140 if (isalnum(msg[i]))
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
141 buf[j++] = msg[i];
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
142 else {
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
143 sprintf(buf + j, "%%%02x", (unsigned char)msg[i]);
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
144 j += 3;
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
145 }
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
146 }
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
147 buf[j] = 0;
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
148
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
149 return buf;
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
150 }
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
151
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 static char *handle_errcode(char *buf, gboolean show)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 int errcode;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 static char msg[MSN_BUF_LEN];
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 buf[4] = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 errcode = atoi(buf);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 switch (errcode) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 case 200:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 g_snprintf(msg, sizeof(msg), "Syntax Error (probably a Gaim bug)");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 case 201:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 g_snprintf(msg, sizeof(msg), "Invalid Parameter (probably a Gaim bug)");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 case 205:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 g_snprintf(msg, sizeof(msg), "Invalid User");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 case 206:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 g_snprintf(msg, sizeof(msg), "Fully Qualified Domain Name missing");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 case 207:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 g_snprintf(msg, sizeof(msg), "Already Login");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 case 208:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 g_snprintf(msg, sizeof(msg), "Invalid Username");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 case 209:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 g_snprintf(msg, sizeof(msg), "Invalid Friendly Name");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 case 210:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 g_snprintf(msg, sizeof(msg), "List Full");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 case 215:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 g_snprintf(msg, sizeof(msg), "Already there");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 case 216:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 g_snprintf(msg, sizeof(msg), "Not on list");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 case 218:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 g_snprintf(msg, sizeof(msg), "Already in the mode");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 case 219:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 g_snprintf(msg, sizeof(msg), "Already in opposite list");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 case 280:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 g_snprintf(msg, sizeof(msg), "Switchboard failed");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 case 281:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 g_snprintf(msg, sizeof(msg), "Notify Transfer failed");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204 case 300:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 g_snprintf(msg, sizeof(msg), "Required fields missing");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 case 302:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 g_snprintf(msg, sizeof(msg), "Not logged in");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211 case 500:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212 g_snprintf(msg, sizeof(msg), "Internal server error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 case 501:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 g_snprintf(msg, sizeof(msg), "Database server error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 case 510:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 g_snprintf(msg, sizeof(msg), "File operation error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 case 520:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221 g_snprintf(msg, sizeof(msg), "Memory allocation error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 case 600:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 g_snprintf(msg, sizeof(msg), "Server busy");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 case 601:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228 g_snprintf(msg, sizeof(msg), "Server unavailable");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230 case 602:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
231 g_snprintf(msg, sizeof(msg), "Peer Notification server down");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 case 603:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 g_snprintf(msg, sizeof(msg), "Database connect error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236 case 604:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 g_snprintf(msg, sizeof(msg), "Server is going down (abandon ship)");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 case 707:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241 g_snprintf(msg, sizeof(msg), "Error creating connection");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 case 711:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 g_snprintf(msg, sizeof(msg), "Unable to write");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 case 712:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 g_snprintf(msg, sizeof(msg), "Session overload");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 case 713:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 g_snprintf(msg, sizeof(msg), "User is too active");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 case 714:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 g_snprintf(msg, sizeof(msg), "Too many sessions");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 case 715:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 g_snprintf(msg, sizeof(msg), "Not expected");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 case 717:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 g_snprintf(msg, sizeof(msg), "Bad friend file");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 case 911:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263 g_snprintf(msg, sizeof(msg), "Authentication failed");
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 913:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 g_snprintf(msg, sizeof(msg), "Not allowed when offline");
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 case 920:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 g_snprintf(msg, sizeof(msg), "Not accepting new users");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 default:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 g_snprintf(msg, sizeof(msg), "Unknown Error Code");
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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 if (show)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 do_error_dialog(msg, "MSN Error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 return msg;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 static void handle_hotmail(struct gaim_connection *gc, char *data)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 {
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
285 if (strstr(data, "Content-Type: text/x-msmsgsinitialemailnotification;")) {
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
286 char *x = strstr(data, "Inbox-Unread:");
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
287 if (!x) return;
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
288 x += strlen("Inbox-Unread: ");
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
289 connection_has_mail(gc, atoi(x), NULL, NULL, HOTMAIL_URL);
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
290 } else if (strstr(data, "Content-Type: text/x-msmsgsemailnotification;")) {
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
291 char *from = strstr(data, "From:");
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
292 char *subject = strstr(data, "Subject:");
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
293 char *x;
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
294 if (!from || !subject) {
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
295 connection_has_mail(gc, 1, NULL, NULL, HOTMAIL_URL);
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
296 return;
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
297 }
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
298 from += strlen("From: ");
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
299 x = strstr(from, "\r\n"); *x = 0;
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
300 subject += strlen("Subject: ");
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
301 x = strstr(subject, "\r\n"); *x = 0;
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
302 connection_has_mail(gc, -1, from, subject, HOTMAIL_URL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 }
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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 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
307 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 GSList *m = md->switches;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 while (m) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 struct msn_switchboard *ms = m->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 m = m->next;
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
314 if ((ms->total <= 1) && !g_strcasecmp(ms->user, id))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 return ms;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321 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
322 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324 GSList *m = md->switches;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 while (m) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 struct msn_switchboard *ms = m->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328 m = m->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329 if (ms->chat && (ms->chat->id == id))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330 return ms;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
333 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336 static struct msn_switchboard *msn_find_writable_switch(struct gaim_connection *gc)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 GSList *m = md->switches;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 while (m) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 struct msn_switchboard *ms = m->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 m = m->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 if (ms->txqueue)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 return ms;
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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 return NULL;
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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351 static void msn_kill_switch(struct msn_switchboard *ms)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 struct gaim_connection *gc = ms->gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 if (ms->inpa)
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
357 gaim_input_remove(ms->inpa);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 close(ms->fd);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
359 g_free(ms->rxqueue);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
360 if (ms->msg)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
361 g_free(ms->msguser);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362 if (ms->sessid)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 g_free(ms->sessid);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 g_free(ms->auth);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 if (ms->user)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 g_free(ms->user);
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
367 while (ms->txqueue) {
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
368 g_free(ms->txqueue->data);
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
369 ms->txqueue = g_slist_remove(ms->txqueue, ms->txqueue->data);
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
370 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 if (ms->chat)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372 serv_got_chat_left(gc, ms->chat->id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 md->switches = g_slist_remove(md->switches, ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376 g_free(ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
379 static int msn_process_switch(struct msn_switchboard *ms, char *buf)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381 struct gaim_connection *gc = ms->gc;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
382 char sendbuf[MSN_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383 static int id = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385 if (!g_strncasecmp(buf, "ACK", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386 } else if (!g_strncasecmp(buf, "ANS", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
387 if (ms->chat)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388 add_chat_buddy(ms->chat, gc->username);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389 } else if (!g_strncasecmp(buf, "BYE", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 if (ms->chat) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 char *user, *tmp = buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 remove_chat_buddy(ms->chat, user);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
395 } else {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396 msn_kill_switch(ms);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
397 return 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
398 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 } else if (!g_strncasecmp(buf, "CAL", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 } else if (!g_strncasecmp(buf, "IRO", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 char *tot, *user, *tmp = buf;
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 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406 tot = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408 ms->total = atoi(tot);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412 if (ms->total > 1) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413 if (!ms->chat)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414 ms->chat = serv_got_joined_chat(gc, ++id, "MSN Chat");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415 add_chat_buddy(ms->chat, user);
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 } else if (!g_strncasecmp(buf, "JOI", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418 char *user, *tmp = buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
419 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
420 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
421 GET_NEXT(tmp);
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 if (ms->total == 1) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 ms->chat = serv_got_joined_chat(gc, ++id, "MSN Chat");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 add_chat_buddy(ms->chat, ms->user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 add_chat_buddy(ms->chat, gc->username);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427 g_free(ms->user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428 ms->user = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430 if (ms->chat)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 add_chat_buddy(ms->chat, user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 ms->total++;
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
433 while (ms->txqueue) {
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
434 char *send = add_cr(ms->txqueue->data);
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
435 char *utf8 = str_to_utf8(send);
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
436 g_free(send);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
437 g_snprintf(sendbuf, sizeof(sendbuf), "MSG %d N %d\r\n%s%s", ++ms->trId,
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 strlen(MIME_HEADER) + strlen(utf8),
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 MIME_HEADER, utf8);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440 g_free(utf8);
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
441 g_free(ms->txqueue->data);
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
442 ms->txqueue = g_slist_remove(ms->txqueue, ms->txqueue->data);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
443 if (msn_write(ms->fd, sendbuf, strlen(sendbuf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444 msn_kill_switch(ms);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
445 return 0;
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
446 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 debug_printf("\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 } else if (!g_strncasecmp(buf, "MSG", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
450 char *user, *tmp = buf;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
451 int length;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
453 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459 length = atoi(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
461 ms->msg = TRUE;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
462 ms->msguser = g_strdup(user);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
463 ms->msglen = length;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464 } else if (!g_strncasecmp(buf, "NAK", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 do_error_dialog("A message may not have been received.", "MSN Error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 } else if (!g_strncasecmp(buf, "NLN", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
467 } else if (!g_strncasecmp(buf, "OUT", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468 if (ms->chat)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
469 serv_got_chat_left(gc, ms->chat->id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470 msn_kill_switch(ms);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
471 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
472 } else if (!g_strncasecmp(buf, "USR", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
473 /* 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
474 struct msn_switchboard *ms = msn_find_writable_switch(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
476 if (!ms)
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
477 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
478
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
479 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
480 if (msn_write(ms->fd, sendbuf, strlen(sendbuf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
481 msn_kill_switch(ms);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
482 return 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
483 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
484 } else if (isdigit(*buf)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
485 handle_errcode(buf, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487 debug_printf("Unhandled message!\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
488 }
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
489
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
490 return 1;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
491 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
492
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
493 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
494 {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
495 char *content, *agent, *utf;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
496 int flags = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
497
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
498 agent = strstr(msg, "User-Agent: ");
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
499 if (agent) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
500 if (!g_strncasecmp(agent, "User-Agent: Gaim", strlen("User-Agent: Gaim")))
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
501 flags |= IM_FLAG_GAIMUSER;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
502 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
503 content = strstr(msg, "Content-Type: ");
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
504 if (!content)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
505 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
506 if (!g_strncasecmp(content, "Content-Type: text/plain",
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
507 strlen("Content-Type: text/plain"))) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
508 char *skiphead;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
509 skiphead = strstr(msg, "\r\n\r\n");
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
510 if (!skiphead || !skiphead[4]) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
511 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
512 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
513 skiphead += 4;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
514 utf = utf8_to_str(skiphead);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
515 strip_linefeed(utf);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
516
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
517 if (ms->chat)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
518 serv_got_chat_in(ms->gc, ms->chat->id, ms->msguser, flags, utf, time(NULL));
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
519 else
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
520 serv_got_im(ms->gc, ms->msguser, utf, flags, time(NULL));
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
521
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
522 g_free(utf);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
523 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
524 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
525
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
526 static void msn_switchboard_callback(gpointer data, gint source, GaimInputCondition cond)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
527 {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
528 struct msn_switchboard *ms = data;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
529 char buf[MSN_BUF_LEN];
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
530 int cont = 1;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
531 int len;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
532
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
533 len = read(ms->fd, buf, sizeof(buf));
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
534
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
535 if (len <= 0) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
536 msn_kill_switch(ms);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
537 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
538 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
539
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
540 ms->rxqueue = g_realloc(ms->rxqueue, len + ms->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
541 memcpy(ms->rxqueue + ms->rxlen, buf, len);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
542 ms->rxlen += len;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
543
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
544 while (cont) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
545 if (!ms->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
546 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
547
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
548 if (ms->msg) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
549 char *msg;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
550 if (ms->msglen > ms->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
551 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
552 msg = ms->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
553 ms->rxlen -= ms->msglen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
554 if (ms->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
555 ms->rxqueue = g_memdup(msg + ms->msglen, ms->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
556 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
557 ms->rxqueue = NULL;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
558 msg = g_realloc(msg, ms->msglen + 1);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
559 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
560 msg[ms->msglen] = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
561 ms->msglen = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
562 ms->msg = FALSE;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
563
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
564 msn_process_switch_msg(ms, msg);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
565
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
566 g_free(ms->msguser);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
567 g_free(msg);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
568 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
569 char *end = ms->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
570 int cmdlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
571 char *cmd;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
572 int i = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
573
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
574 while (i + 1 < ms->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
575 if (*end == '\r' && end[1] == '\n')
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
576 break;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
577 end++; i++;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
578 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
579 if (i + 1 == ms->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
580 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
581
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
582 cmdlen = end - ms->rxqueue + 2;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
583 cmd = ms->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
584 ms->rxlen -= cmdlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
585 if (ms->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
586 ms->rxqueue = g_memdup(cmd + cmdlen, ms->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
587 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
588 ms->rxqueue = NULL;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
589 cmd = g_realloc(cmd, cmdlen + 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 cmd[cmdlen] = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
592
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
593 debug_printf("MSN S: %s", cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
594 g_strchomp(cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
595 cont = msn_process_switch(ms, cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
596
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
597 g_free(cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
598 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
599 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
600 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
601
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
602 static void msn_rng_connect(gpointer data, gint source, GaimInputCondition cond)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
603 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
604 struct msn_switchboard *ms = data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
605 struct gaim_connection *gc = ms->gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
606 struct msn_data *md;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
608
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
609 if (source == -1 || !g_slist_find(connections, gc)) {
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
610 close(source);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
611 g_free(ms->sessid);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
612 g_free(ms->auth);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
613 g_free(ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
614 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
615 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
616
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
617 md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
618
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
619 if (ms->fd != source)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
620 ms->fd = source;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
621
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
622 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
623 if (msn_write(ms->fd, buf, strlen(buf)) < 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
624 close(ms->fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
625 g_free(ms->sessid);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
626 g_free(ms->auth);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
627 g_free(ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
628 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
629 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
630
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
631 md->switches = g_slist_append(md->switches, ms);
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
632 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
633 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
634
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
635 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
636 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
637 struct msn_switchboard *ms = data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
638 struct gaim_connection *gc = ms->gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
639 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
640
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
641 if (source == -1 || !g_slist_find(connections, gc)) {
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
642 close(source);
2265
2f03cfd21fc2 [gaim-migrate @ 2275]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
643 if (g_slist_find(connections, gc)) {
2f03cfd21fc2 [gaim-migrate @ 2275]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
644 msn_kill_switch(ms);
2f03cfd21fc2 [gaim-migrate @ 2275]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
645 do_error_dialog(_("MSN Error"), _("Gaim was unable to send a message"));
2f03cfd21fc2 [gaim-migrate @ 2275]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
646 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
647 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
648 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
649
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650 if (ms->fd != source)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
651 ms->fd = source;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
652
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
653 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
654 if (msn_write(ms->fd, buf, strlen(buf)) < 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
655 g_free(ms->auth);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656 g_free(ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
660 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
661 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
662
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
663 struct msn_add_permit {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
664 struct gaim_connection *gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
665 char *user;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
666 char *friend;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
667 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
668
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
669 static void msn_accept_add(gpointer w, struct msn_add_permit *map)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
670 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
671 struct msn_data *md = map->gc->proto_data;
2747
51fc8e5acd7a [gaim-migrate @ 2760]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2740
diff changeset
672 char *user;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
673 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
674
2747
51fc8e5acd7a [gaim-migrate @ 2760]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2740
diff changeset
675 user = g_strdup(url_encode(map->user));
51fc8e5acd7a [gaim-migrate @ 2760]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2740
diff changeset
676 g_snprintf(buf, sizeof(buf), "ADD %d AL %s %s\r\n", ++md->trId, user, url_encode(map->friend));
51fc8e5acd7a [gaim-migrate @ 2760]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2740
diff changeset
677 g_free(user);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
678 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
679 hide_login_progress(map->gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
680 signoff(map->gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
681 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
682 }
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
683 build_allow_list(); /* er. right. we'll need to have a thing for this in CUI too */
2582
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2541
diff changeset
684
5efa8077107f [gaim-migrate @ 2595]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2541
diff changeset
685 show_got_added(map->gc, NULL, map->user, map->friend, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
686 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
687
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
688 static void msn_cancel_add(gpointer w, struct msn_add_permit *map)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
689 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
690 g_free(map->user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
691 g_free(map->friend);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
692 g_free(map);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
693 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
694
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
695 static int msn_process_main(struct gaim_connection *gc, char *buf)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
696 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
697 struct msn_data *md = gc->proto_data;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
698 char sendbuf[MSN_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
699
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
700 if (!g_strncasecmp(buf, "ADD", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
701 char *list, *user, *friend, *tmp = buf;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
702 struct msn_add_permit *ap;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
703 GSList *perm = gc->permit;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
704 char msg[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
705
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
706 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
707 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
708 list = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
709
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
710 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
711 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
712 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
713
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
714 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
715 friend = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
716
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
717 if (g_strcasecmp(list, "RL"))
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
718 return 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
719
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
720 while (perm) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
721 if (!g_strcasecmp(perm->data, user))
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
722 return 1;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
723 perm = perm->next;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
724 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
725
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
726 ap = g_new0(struct msn_add_permit, 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
727 ap->user = g_strdup(user);
2611
d324478ee203 [gaim-migrate @ 2624]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2607
diff changeset
728 ap->friend = g_strdup(url_decode(friend));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
729 ap->gc = gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
730
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
731 g_snprintf(msg, sizeof(msg), "The user %s (%s) wants to add you to their buddy list.",
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
732 ap->user, url_decode(ap->friend));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
733
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
734 do_ask_dialog(msg, ap, msn_accept_add, msn_cancel_add);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
735 } else if (!g_strncasecmp(buf, "BLP", 3)) {
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
736 char *type, *tmp = buf;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
737
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
738 GET_NEXT(tmp);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
739 GET_NEXT(tmp);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
740 GET_NEXT(tmp);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
741 type = tmp;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
742
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
743 if (!g_strcasecmp(type, "AL")) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
744 /* If the current setting is AL, messages
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
745 * from users who are not in BL will be delivered
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
746 *
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
747 * In other words, deny some */
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
748 gc->permdeny = DENY_SOME;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
749 } else {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
750 /* If the current
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
751 * 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
752 * delivered.
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
753 *
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
754 * In other words, permit some */
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
755 gc->permdeny = PERMIT_SOME;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
756 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
757 } else if (!g_strncasecmp(buf, "BPR", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
758 } else if (!g_strncasecmp(buf, "CHG", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
759 } else if (!g_strncasecmp(buf, "CHL", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
760 char *hash = buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
761 char buf2[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
762 md5_state_t st;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
763 md5_byte_t di[16];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
764 int i;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
765
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
766 GET_NEXT(hash);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
767 GET_NEXT(hash);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
768
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
769 md5_init(&st);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
770 md5_append(&st, (const md5_byte_t *)hash, strlen(hash));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
771 md5_append(&st, (const md5_byte_t *)"Q1P7W2E4J9R8U3S5", strlen("Q1P7W2E4J9R8U3S5"));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
772 md5_finish(&st, di);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
773
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
774 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
775 for (i = 0; i < 16; i++) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
776 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
777 strcat(sendbuf, buf2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
778 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
779
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
780 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
781 hide_login_progress(gc, "Unable to write to server");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
782 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
783 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
784
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
785 debug_printf("\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
786 } else if (!g_strncasecmp(buf, "FLN", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
787 char *usr = buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
788
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
789 GET_NEXT(usr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
790 serv_got_update(gc, usr, 0, 0, 0, 0, 0, 0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
791 } else if (!g_strncasecmp(buf, "GTC", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
792 } else if (!g_strncasecmp(buf, "INF", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
793 } else if (!g_strncasecmp(buf, "ILN", 3)) {
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
794 char *state, *user, *friend, *tmp = buf;
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
795 struct buddy *b;
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
796 int status = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
797
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
798 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
799
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
800 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
801 state = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
802
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
803 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
804 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
805
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
806 GET_NEXT(tmp);
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
807 friend = url_decode(tmp);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
808
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
809 if ((b = find_buddy(gc, user)) != NULL) {
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
810 if (b->proto_data)
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
811 g_free(b->proto_data);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
812 b->proto_data = g_strdup(friend);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
813 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
814
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
815 if (!g_strcasecmp(state, "BSY")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
816 status |= UC_UNAVAILABLE | (MSN_BUSY << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
817 } else if (!g_strcasecmp(state, "IDL")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
818 status |= UC_UNAVAILABLE | (MSN_IDLE << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
819 } else if (!g_strcasecmp(state, "BRB")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
820 status |= UC_UNAVAILABLE | (MSN_BRB << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
821 } else if (!g_strcasecmp(state, "AWY")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
822 status |= UC_UNAVAILABLE | (MSN_AWAY << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
823 } else if (!g_strcasecmp(state, "PHN")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
824 status |= UC_UNAVAILABLE | (MSN_PHONE << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
825 } else if (!g_strcasecmp(state, "LUN")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
826 status |= UC_UNAVAILABLE | (MSN_LUNCH << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
827 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
828
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
829 serv_got_update(gc, user, 1, 0, 0, 0, status, 0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
830 } else if (!g_strncasecmp(buf, "LST", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
831 char *which, *who, *friend, *tmp = buf;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
832 int pos, tot;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
833
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
834 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
835 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
836 which = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
837
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
838 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
839 GET_NEXT(tmp);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
840 pos = strtol(tmp, NULL, 10);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
841 GET_NEXT(tmp);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
842 tot = strtol(tmp, NULL, 10);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
843 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
844 who = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
845
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
846 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
847 friend = url_decode(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
848
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
849 if (!g_strcasecmp(which, "FL") && pos) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
850 struct msn_buddy *b = g_new0(struct msn_buddy, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
851 b->user = g_strdup(who);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
852 b->friend = g_strdup(friend);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
853 md->fl = g_slist_append(md->fl, b);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
854 } else if (!g_strcasecmp(which, "AL") && pos) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
855 gc->permit = g_slist_append(gc->permit, g_strdup(who));
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
856 } else if (!g_strcasecmp(which, "BL") && pos) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
857 gc->deny = g_slist_append(gc->deny, g_strdup(who));
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
858 } else if (!g_strcasecmp(which, "RL")) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
859 if (pos != tot)
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
860 return 1;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
861
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
862 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
863 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
864 hide_login_progress(gc, "Unable to write");
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
865 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
866 return 0;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
867 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
868
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
869 account_online(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
870 serv_finish_login(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
871
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
872 md->permit = g_slist_copy(gc->permit);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
873 md->deny = g_slist_copy(gc->deny);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
874
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
875 if (bud_list_cache_exists(gc))
2382
569ae9f2bb89 [gaim-migrate @ 2395]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2311
diff changeset
876 do_import(gc, NULL);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
877 else {
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
878 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
879 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
880 hide_login_progress(gc, "Unable to write");
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
881 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
882 return 0;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
883 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
884 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
885 while (md->fl) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
886 struct msn_buddy *mb = md->fl->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
887 struct buddy *b;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
888 md->fl = g_slist_remove(md->fl, mb);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
889 if (!(b = find_buddy(gc, mb->user)))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
890 add_buddy(gc, "Buddies", mb->user, mb->friend);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
891 else if (!g_strcasecmp(b->name, b->show)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
892 g_snprintf(b->show, sizeof(b->show), "%s", mb->friend);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
893 handle_buddy_rename(b, b->name);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
894 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
895 g_free(mb->user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
896 g_free(mb->friend);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
897 g_free(mb);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
898 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
899 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
900 } else if (!g_strncasecmp(buf, "MSG", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
901 char *user, *tmp = buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
902 int length;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
903
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
904 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
905 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
906
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
907 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
908
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
909 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
910 length = atoi(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
911
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
912 md->msg = TRUE;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
913 md->msguser = g_strdup(user);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
914 md->msglen = length;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
915 } else if (!g_strncasecmp(buf, "NLN", 3)) {
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
916 char *state, *user, *friend, *tmp = buf;
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
917 struct buddy *b;
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
918 int status = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
919
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
920 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
921 state = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
922
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
923 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
924 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
925
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
926 GET_NEXT(tmp);
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
927 friend = url_decode(tmp);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
928
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
929 if ((b = find_buddy(gc, user)) != NULL) {
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
930 if (b->proto_data)
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
931 g_free(b->proto_data);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
932 b->proto_data = g_strdup(friend);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
933 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
934
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
935 if (!g_strcasecmp(state, "BSY")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
936 status |= UC_UNAVAILABLE | (MSN_BUSY << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
937 } else if (!g_strcasecmp(state, "IDL")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
938 status |= UC_UNAVAILABLE | (MSN_IDLE << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
939 } else if (!g_strcasecmp(state, "BRB")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
940 status |= UC_UNAVAILABLE | (MSN_BRB << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
941 } else if (!g_strcasecmp(state, "AWY")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
942 status |= UC_UNAVAILABLE | (MSN_AWAY << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
943 } else if (!g_strcasecmp(state, "PHN")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
944 status |= UC_UNAVAILABLE | (MSN_PHONE << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
945 } else if (!g_strcasecmp(state, "LUN")) {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
946 status |= UC_UNAVAILABLE | (MSN_LUNCH << 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
947 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
948
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
949 serv_got_update(gc, user, 1, 0, 0, 0, status, 0);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
950 } else if (!g_strncasecmp(buf, "OUT", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
951 } else if (!g_strncasecmp(buf, "PRP", 3)) {
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
952 } else if (!g_strncasecmp(buf, "QNG", 3)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
953 } else if (!g_strncasecmp(buf, "QRY", 3)) {
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
954 } else if (!g_strncasecmp(buf, "REA", 3)) {
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
955 char *friend, *tmp = buf;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
956
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
957 GET_NEXT(tmp);
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
958 GET_NEXT(tmp);
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
959 GET_NEXT(tmp);
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
960 GET_NEXT(tmp);
2219
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
961 friend = url_decode(tmp);
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
962
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
963 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", friend);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
964 } else if (!g_strncasecmp(buf, "REM", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
965 } else if (!g_strncasecmp(buf, "RNG", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
966 struct msn_switchboard *ms;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
967 char *sessid, *ssaddr, *auth, *user;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
968 int port, i = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
969 char *tmp = buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
970
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
971 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
972 sessid = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
973
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
974 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
975 ssaddr = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
976
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
977 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
978
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
979 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
980 auth = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
981
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
982 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
983 user = tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
984 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
985
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
986 while (ssaddr[i] && ssaddr[i] != ':') i++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
987 if (ssaddr[i] == ':') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
988 char *x = &ssaddr[i + 1];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
989 ssaddr[i] = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
990 port = atoi(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
991 } else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
992 port = 1863;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
993
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
994 ms = g_new0(struct msn_switchboard, 1);
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
995 ms->fd = proxy_connect(ssaddr, port, msn_rng_connect, ms);
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
996 if (ms->fd < 0) {
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
997 g_free(ms);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
998 return 1;
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
999 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1000 ms->user = g_strdup(user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1001 ms->sessid = g_strdup(sessid);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1002 ms->auth = g_strdup(auth);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1003 ms->gc = gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1004 } else if (!g_strncasecmp(buf, "SYN", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1005 } else if (!g_strncasecmp(buf, "USR", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1006 } else if (!g_strncasecmp(buf, "XFR", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1007 char *host = strstr(buf, "SB");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1008 int port;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1009 int i = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1010 gboolean switchboard = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1011 char *tmp;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1012
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1013 if (!host) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1014 host = strstr(buf, "NS");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1015 if (!host) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1016 hide_login_progress(gc, "Got invalid XFR\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1017 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1018 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1019 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1020 switchboard = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1021 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1022
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1023 GET_NEXT(host);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1024 while (host[i] && host[i] != ':') i++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1025 if (host[i] == ':') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1026 tmp = &host[i + 1];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1027 host[i] = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1028 while (isdigit(*tmp)) tmp++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1029 *tmp++ = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1030 port = atoi(&host[i + 1]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1031 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1032 port = 1863;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1033 tmp = host;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1034 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1035 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1036
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1037 if (switchboard) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1038 struct msn_switchboard *ms = msn_find_writable_switch(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1039 if (!ms)
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1040 return 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1041
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1042 GET_NEXT(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1043
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1044 ms->fd = proxy_connect(host, port, msn_ss_xfr_connect, ms);
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1045 if (ms->fd < 0) {
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1046 msn_kill_switch(ms);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1047 return 1;
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1048 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1049 ms->auth = g_strdup(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1050 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1051 close(md->fd);
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1052 gaim_input_remove(md->inpa);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1053 md->inpa = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1054 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
1055 if (md->fd < 0) {
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1056 hide_login_progress(gc, "Error transfering");
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1057 signoff(gc);
2740
68ad186943e0 [gaim-migrate @ 2753]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2739
diff changeset
1058 return 0;
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1059 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1060 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1061 } else if (isdigit(*buf)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1062 handle_errcode(buf, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1063 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1064 debug_printf("Unhandled message!\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1065 }
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1066
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1067 return 1;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1068 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1069
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1070 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
1071 {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1072 struct msn_data *md = gc->proto_data;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1073 char *skiphead, *utf;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1074
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1075 if (!g_strcasecmp(md->msguser, "hotmail")) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1076 handle_hotmail(gc, msg);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1077 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1078 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1079
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1080 skiphead = strstr(msg, "\r\n\r\n");
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1081 if (!skiphead || !skiphead[4])
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1082 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1083 skiphead += 4;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1084 utf = utf8_to_str(skiphead);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1085 strip_linefeed(utf);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1086
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1087 serv_got_im(gc, md->msguser, utf, 0, time(NULL));
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1088
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1089 g_free(utf);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1090 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1091
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1092 static void msn_callback(gpointer data, gint source, GaimInputCondition cond)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1093 {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1094 struct gaim_connection *gc = data;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1095 struct msn_data *md = gc->proto_data;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1096 char buf[MSN_BUF_LEN];
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1097 int cont = 1;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1098 int len;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1099
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1100 len = read(md->fd, buf, sizeof(buf));
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1101
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1102 if (len <= 0) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1103 hide_login_progress(gc, "Error reading from server");
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1104 signoff(gc);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1105 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1106 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1107
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1108 md->rxqueue = g_realloc(md->rxqueue, len + md->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1109 memcpy(md->rxqueue + md->rxlen, buf, len);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1110 md->rxlen += len;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1111
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1112 while (cont) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1113 if (!md->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1114 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1115
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1116 if (md->msg) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1117 char *msg;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1118 if (md->msglen > md->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1119 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1120 msg = md->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1121 md->rxlen -= md->msglen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1122 if (md->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1123 md->rxqueue = g_memdup(msg + md->msglen, md->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1124 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1125 md->rxqueue = NULL;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1126 msg = g_realloc(msg, md->msglen + 1);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1127 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1128 msg[md->msglen] = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1129 md->msglen = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1130 md->msg = FALSE;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1131
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1132 msn_process_main_msg(gc, msg);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1133
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1134 g_free(md->msguser);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1135 g_free(msg);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1136 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1137 char *end = md->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1138 int cmdlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1139 char *cmd;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1140 int i = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1141
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1142 while (i + 1 < md->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1143 if (*end == '\r' && end[1] == '\n')
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1144 break;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1145 end++; i++;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1146 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1147 if (i + 1 == md->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1148 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1149
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1150 cmdlen = end - md->rxqueue + 2;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1151 cmd = md->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1152 md->rxlen -= cmdlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1153 if (md->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1154 md->rxqueue = g_memdup(cmd + cmdlen, md->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1155 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1156 md->rxqueue = NULL;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1157 cmd = g_realloc(cmd, cmdlen + 1);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1158 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1159 cmd[cmdlen] = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1160
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1161 debug_printf("MSN S: %s", cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1162 g_strchomp(cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1163 cont = msn_process_main(gc, cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1164
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1165 g_free(cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1166 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1167 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1168 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1169
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1170 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
1171 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1172 struct gaim_connection *gc = data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1173 struct msn_data *md;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1174 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1175
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1176 if (!g_slist_find(connections, gc)) {
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1177 close(source);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1178 return;
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1179 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1180
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1181 md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1182
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1183 if (md->fd != source)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1184 md->fd = source;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1185
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1186 if (md->fd == -1) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1187 hide_login_progress(gc, "Unable to connect to Notification Server");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1188 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1189 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1190 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1191
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1192 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
1193 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1194 hide_login_progress(gc, "Unable to talk to Notification Server");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1195 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1196 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1197 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1198
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1199 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
1200 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1201
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1202 static int msn_process_login(struct gaim_connection *gc, char *buf)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1203 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1204 struct msn_data *md = gc->proto_data;
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1205 char sendbuf[MSN_BUF_LEN];
2086
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 if (!g_strncasecmp(buf, "VER", 3)) {
2226
2a09a177ed5f [gaim-migrate @ 2236]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2219
diff changeset
1208 /* 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
1209 if (!strstr(buf, "MSNP5")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1210 hide_login_progress(gc, "Protocol not supported");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1211 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1212 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1213 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1214
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1215 g_snprintf(sendbuf, sizeof(sendbuf), "INF %d\r\n", ++md->trId);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1216 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1217 hide_login_progress(gc, "Unable to request INF\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1218 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1219 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1220 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1221 } else if (!g_strncasecmp(buf, "INF", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1222 /* check to make sure we can use md5 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1223 if (!strstr(buf, "MD5")) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1224 hide_login_progress(gc, "Unable to login using MD5");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1225 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1226 return 0;
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
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1229 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
1230 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1231 hide_login_progress(gc, "Unable to send USR\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1232 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1233 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1234 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1235
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1236 set_login_progress(gc, 3, "Requesting to send password");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1237 } else if (!g_strncasecmp(buf, "USR", 3)) {
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1238 char *resp, *friend, *tmp = buf;
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1239
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1240 GET_NEXT(tmp);
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1241 GET_NEXT(tmp);
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1242 resp = tmp;
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1243 GET_NEXT(tmp);
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1244 GET_NEXT(tmp);
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1245 friend = tmp;
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1246 GET_NEXT(tmp);
2219
20a4d5da0b95 [gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2213
diff changeset
1247 friend = url_decode(friend);
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1248
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1249 /* 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
1250 if (!g_strcasecmp(resp, "OK")) {
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1251 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", friend);
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1252
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1253 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
1254 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1255 hide_login_progress(gc, "Unable to write");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1256 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1257 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1258 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1259
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1260 gaim_input_remove(md->inpa);
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1261 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
1262 return 0;
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1263 } else if (!g_strcasecmp(resp, "MD5")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1264 char buf2[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1265 md5_state_t st;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1266 md5_byte_t di[16];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1267 int i;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1268
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1269 g_snprintf(buf2, sizeof(buf2), "%s%s", friend, gc->password);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1270
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1271 md5_init(&st);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1272 md5_append(&st, (const md5_byte_t *)buf2, strlen(buf2));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1273 md5_finish(&st, di);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1274
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1275 g_snprintf(sendbuf, sizeof(sendbuf), "USR %d MD5 S ", ++md->trId);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1276 for (i = 0; i < 16; i++) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1277 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1278 strcat(sendbuf, buf2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1279 }
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1280 strcat(sendbuf, "\n");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1281
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1282 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1283 hide_login_progress(gc, "Unable to send password");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1284 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1285 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1286 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1287
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1288 set_login_progress(gc, 4, "Password sent");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1289 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1290 } else if (!g_strncasecmp(buf, "XFR", 3)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1291 char *host = strstr(buf, "NS");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1292 int port;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1293 int i = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1294
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1295 if (!host) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1296 hide_login_progress(gc, "Got invalid XFR\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1297 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1298 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1299 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1300
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1301 GET_NEXT(host);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1302 while (host[i] && host[i] != ':') i++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1303 if (host[i] == ':') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1304 char *x = &host[i + 1];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1305 host[i] = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1306 port = atoi(x);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1307 } else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1308 port = 1863;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1309
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1310 close(md->fd);
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1311 gaim_input_remove(md->inpa);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1312 md->inpa = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1313 md->fd = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1314 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
1315 if (md->fd < 0) {
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1316 hide_login_progress(gc, "Unable to transfer");
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1317 signoff(gc);
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1318 }
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1319 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1320 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1321 if (isdigit(*buf))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1322 hide_login_progress(gc, handle_errcode(buf, FALSE));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1323 else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1324 hide_login_progress(gc, "Unable to parse message");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1325 signoff(gc);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1326 return 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1327 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1328
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1329 return 1;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1330 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1331
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1332 static void msn_login_callback(gpointer data, gint source, GaimInputCondition cond)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1333 {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1334 struct gaim_connection *gc = data;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1335 struct msn_data *md = gc->proto_data;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1336 char buf[MSN_BUF_LEN];
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1337 int cont = 1;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1338 int len;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1339
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1340 len = read(md->fd, buf, sizeof(buf));
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1341
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1342 if (len <= 0) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1343 hide_login_progress(gc, "Error reading from server");
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1344 signoff(gc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1345 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1346 }
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1347
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1348 md->rxqueue = g_realloc(md->rxqueue, len + md->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1349 memcpy(md->rxqueue + md->rxlen, buf, len);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1350 md->rxlen += len;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1351
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1352 while (cont) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1353 char *end = md->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1354 int cmdlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1355 char *cmd;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1356 int i = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1357
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1358 if (!md->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1359 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1360
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1361 while (i + 1 < md->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1362 if (*end == '\r' && end[1] == '\n')
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1363 break;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1364 end++; i++;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1365 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1366 if (i + 1 == md->rxlen)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1367 return;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1368
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1369 cmdlen = end - md->rxqueue + 2;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1370 cmd = md->rxqueue;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1371 md->rxlen -= cmdlen;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1372 if (md->rxlen) {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1373 md->rxqueue = g_memdup(cmd + cmdlen, md->rxlen);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1374 } else {
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1375 md->rxqueue = NULL;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1376 cmd = g_realloc(cmd, cmdlen + 1);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1377 }
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1378 cmd[cmdlen] = 0;
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1379
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1380 debug_printf("MSN S: %s", cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1381 g_strchomp(cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1382 cont = msn_process_login(gc, cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1383
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1384 g_free(cmd);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1385 }
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
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1388 static void msn_login_connect(gpointer data, gint source, GaimInputCondition cond)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1389 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1390 struct gaim_connection *gc = data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1391 struct msn_data *md;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1392 char buf[1024];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1393
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1394 if (!g_slist_find(connections, gc)) {
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1395 close(source);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1396 return;
2210
3a6fd1e8f00a [gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1397 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1398
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1399 md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1400
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1401 if (md->fd != source)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1402 md->fd = source;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1403
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1404 if (md->fd == -1) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1405 hide_login_progress(gc, "Unable to connect");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1406 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1407 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1408 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1409
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1410 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
1411 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1412 hide_login_progress(gc, "Unable to write to server");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1413 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1414 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1415 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1416
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1417 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
1418 set_login_progress(gc, 2, "Synching with server");
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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1421 static void msn_login(struct aim_user *user)
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 struct gaim_connection *gc = new_gaim_conn(user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1424 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
1425
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1426 set_login_progress(gc, 1, "Connecting");
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 g_snprintf(gc->username, sizeof(gc->username), "%s", msn_normalize(gc->username));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1429
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1430 md->fd = proxy_connect("messenger.hotmail.com", 1863, msn_login_connect, gc);
2688
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1431 if (md->fd < 0) {
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1432 hide_login_progress(gc, "Unable to connect");
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1433 signoff(gc);
98b1ac8ddea3 [gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
1434 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1435 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1436
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1437 static void msn_close(struct gaim_connection *gc)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1438 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1439 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1440 close(md->fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1441 if (md->inpa)
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
1442 gaim_input_remove(md->inpa);
2738
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1443 g_free(md->rxqueue);
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1444 if (md->msg)
01f0497fe6c8 [gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
1445 g_free(md->msguser);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1446 while (md->switches)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1447 msn_kill_switch(md->switches->data);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1448 while (md->fl) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1449 struct msn_buddy *tmp = md->fl->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1450 md->fl = g_slist_remove(md->fl, tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1451 g_free(tmp->user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1452 g_free(tmp->friend);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1453 g_free(tmp);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1454 }
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1455 g_slist_free(md->permit);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1456 g_slist_free(md->deny);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1457 g_free(md);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1458 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1459
2231
8c4ff1a368bd [gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2230
diff changeset
1460 static int msn_send_im(struct gaim_connection *gc, char *who, char *message, int flags)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1461 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1462 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1463 struct msn_switchboard *ms = msn_find_switch(gc, who);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1464 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1465
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1466 if (ms) {
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1467 char *utf8, *send;
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1468
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1469 if (ms->txqueue) {
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1470 debug_printf("appending to queue\n");
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1471 ms->txqueue = g_slist_append(ms->txqueue, g_strdup(message));
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1472 return 1;
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1473 }
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1474
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1475 send = add_cr(message);
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1476 utf8 = str_to_utf8(send);
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1477 g_free(send);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1478 g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s", ++ms->trId,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1479 strlen(MIME_HEADER) + strlen(utf8),
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1480 MIME_HEADER, utf8);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1481 g_free(utf8);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1482 if (msn_write(ms->fd, buf, strlen(buf)) < 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1483 msn_kill_switch(ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1484 debug_printf("\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1485 } else if (strcmp(who, gc->username)) {
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1486 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
1487 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1488 hide_login_progress(gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1489 signoff(gc);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1490 return 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1491 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1492
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1493 ms = g_new0(struct msn_switchboard, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1494 md->switches = g_slist_append(md->switches, ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1495 ms->user = g_strdup(who);
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1496 ms->txqueue = g_slist_append(ms->txqueue, g_strdup(message));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1497 ms->gc = gc;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1498 ms->fd = -1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1499 } else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1500 /* in msn you can't send messages to yourself, so we'll fake like we received it ;) */
2273
0b5c3338fa3d [gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2265
diff changeset
1501 serv_got_im(gc, who, message, flags | IM_FLAG_GAIMUSER, time(NULL));
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
1502 return 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1503 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1504
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
1505 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
1506 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1507 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1508 char buf[MSN_BUF_LEN];
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1509 char *utf8, *send;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1510
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1511 if (!ms)
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
1512 return -EINVAL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1513
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1514 send = add_cr(message);
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1515 utf8 = str_to_utf8(send);
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1516 g_free(send);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1517 g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s", ++ms->trId,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1518 strlen(MIME_HEADER) + strlen(message),
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1519 MIME_HEADER, utf8);
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1520 g_free(utf8);
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1521 if (msn_write(ms->fd, buf, strlen(buf)) < 0) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1522 msn_kill_switch(ms);
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1523 return 0;
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1524 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1525 debug_printf("\n");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1526 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
1527 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1528 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1529
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1530 static void msn_chat_invite(struct gaim_connection *gc, int id, char *msg, char *who)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1531 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1532 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1533 char buf[MSN_BUF_LEN];
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 if (!ms)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1536 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1537
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1538 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
1539 if (msn_write(ms->fd, buf, strlen(buf)) < 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1540 msn_kill_switch(ms);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1541 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1542
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1543 static void msn_chat_leave(struct gaim_connection *gc, int id)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1544 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1545 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1546 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1547
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1548 if (!ms)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1549 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1550
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1551 g_snprintf(buf, sizeof(buf), "OUT\r\n");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1552 if (msn_write(ms->fd, buf, strlen(buf)) < 0)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1553 msn_kill_switch(ms);
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
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1556 static GList *msn_away_states(struct gaim_connection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1557 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1558 GList *m = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1559
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1560 m = g_list_append(m, "Available");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1561 m = g_list_append(m, "Away From Computer");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1562 m = g_list_append(m, "Be Right Back");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1563 m = g_list_append(m, "Busy");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1564 m = g_list_append(m, "On The Phone");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1565 m = g_list_append(m, "Out To Lunch");
2152
f631cfc8e824 [gaim-migrate @ 2162]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2123
diff changeset
1566 m = g_list_append(m, "Hidden");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1567
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1568 return m;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1569 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1570
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1571 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
1572 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1573 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1574 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1575 char *away;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1576
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1577 gc->away = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1578
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1579 if (msg) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1580 gc->away = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1581 away = "AWY";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1582 } else if (state) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1583 gc->away = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1584
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1585 if (!strcmp(state, "Away From Computer"))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1586 away = "AWY";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1587 else if (!strcmp(state, "Be Right Back"))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1588 away = "BRB";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1589 else if (!strcmp(state, "Busy"))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1590 away = "BSY";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1591 else if (!strcmp(state, "On The Phone"))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1592 away = "PHN";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1593 else if (!strcmp(state, "Out To Lunch"))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1594 away = "LUN";
2152
f631cfc8e824 [gaim-migrate @ 2162]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2123
diff changeset
1595 else if (!strcmp(state, "Hidden"))
f631cfc8e824 [gaim-migrate @ 2162]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2123
diff changeset
1596 away = "HDN";
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1597 else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1598 gc->away = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1599 away = "NLN";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1600 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1601 } else if (gc->is_idle)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1602 away = "IDL";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1603 else
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1604 away = "NLN";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1605
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1606 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
1607 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1608 hide_login_progress(gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1609 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1610 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1611 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1612 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1613
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1614 static void msn_set_idle(struct gaim_connection *gc, int idle)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1615 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1616 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1617 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1618
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1619 if (gc->away)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1620 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1621 if (idle)
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1622 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
1623 else
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1624 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
1625 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1626 hide_login_progress(gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1627 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1628 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1629 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1630 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1631
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1632 static char **msn_list_icon(int uc)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1633 {
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1634 if (uc == 0)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1635 return msn_online_xpm;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1636
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1637 return msn_away_xpm;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1638 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1639
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1640 static char *msn_get_away_text(int s)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1641 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1642 switch (s) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1643 case MSN_BUSY :
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1644 return "Busy";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1645 case MSN_BRB :
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1646 return "Be right back";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1647 case MSN_AWAY :
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1648 return "Away from the computer";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1649 case MSN_PHONE :
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1650 return "On the phone";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1651 case MSN_LUNCH :
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1652 return "Out to lunch";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1653 case MSN_IDLE :
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1654 return "Idle";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1655 default:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1656 return "Available";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1657 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1658 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1659
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1660 static void msn_reset_friend(struct gaim_connection *gc, char *who)
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1661 {
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1662 struct buddy *b = find_buddy(gc, who);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1663 if (!b || !b->proto_data)
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1664 return;
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1665 g_snprintf(b->show, sizeof(b->show), "%s", (char *)b->proto_data);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1666 handle_buddy_rename(b, b->name);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1667 }
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1668
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
1669 static GList *msn_buddy_menu(struct gaim_connection *gc, char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1670 {
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
1671 GList *m = NULL;
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
1672 struct proto_buddy_menu *pbm;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1673 struct buddy *b = find_buddy(gc, who);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
1674 static char buf[MSN_BUF_LEN];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1675
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1676 pbm = g_new0(struct proto_buddy_menu, 1);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1677 pbm->label = "Reset friendly name";
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1678 pbm->callback = msn_reset_friend;
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1679 pbm->gc = gc;
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1680 m = g_list_append(m, pbm);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1681
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1682 if (!b || !(b->uc >> 1))
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
1683 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1684
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
1685 pbm = g_new0(struct proto_buddy_menu, 1);
2501
227cc42ffa6e [gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2494
diff changeset
1686 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
1687 pbm->label = buf;
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
1688 pbm->callback = NULL;
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
1689 pbm->gc = gc;
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
1690 m = g_list_append(m, pbm);
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
1691
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2169
diff changeset
1692 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1693 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1694
2588
a3117e29317d [gaim-migrate @ 2601]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2582
diff changeset
1695 static void msn_add_buddy(struct gaim_connection *gc, char *name)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1696 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1697 struct msn_data *md = gc->proto_data;
2588
a3117e29317d [gaim-migrate @ 2601]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2582
diff changeset
1698 char *who = msn_normalize(name);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1699 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1700 GSList *l = md->fl;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1701
2600
8aade06646b5 [gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
1702 if (who[0] == '@')
8aade06646b5 [gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
1703 /* how did this happen? */
8aade06646b5 [gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
1704 return;
8aade06646b5 [gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2597
diff changeset
1705
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1706 while (l) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1707 struct msn_buddy *b = l->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1708 if (!g_strcasecmp(who, b->user))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1709 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1710 l = l->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1711 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1712 if (l)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1713 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1714
2747
51fc8e5acd7a [gaim-migrate @ 2760]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2740
diff changeset
1715 who = url_encode(who);
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1716 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
1717 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1718 hide_login_progress(gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1719 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1720 return;
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 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1723
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2665
diff changeset
1724 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
1725 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1726 struct msn_data *md = gc->proto_data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1727 char buf[MSN_BUF_LEN];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1728
2747
51fc8e5acd7a [gaim-migrate @ 2760]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2740
diff changeset
1729 who = url_encode(who);
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1730 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
1731 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1732 hide_login_progress(gc, "Write error");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1733 signoff(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1734 return;
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 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1737
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1738 static void msn_act_id(gpointer data, char *entry)
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1739 {
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1740 struct gaim_connection *gc = data;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1741 struct msn_data *md = gc->proto_data;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1742 char buf[MSN_BUF_LEN];
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1743
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1744 g_snprintf(buf, sizeof(buf), "REA %d %s %s\r\n", ++md->trId, gc->username, url_encode(entry));
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1745 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1746 hide_login_progress(gc, "Write error");
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1747 signoff(gc);
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1748 return;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1749 }
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1750 }
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1751
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1752 static void msn_do_action(struct gaim_connection *gc, char *act)
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1753 {
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1754 if (!strcmp(act, "Set Friendly Name")) {
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2501
diff changeset
1755 do_prompt_dialog("Set Friendly Name:", gc->displayname, gc, msn_act_id, NULL);
2758
269fb9005d13 [gaim-migrate @ 2771]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2747
diff changeset
1756 } else if (!strcmp(act, "Reset All Friendly Names")) {
269fb9005d13 [gaim-migrate @ 2771]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2747
diff changeset
1757 GSList *g = gc->groups;
269fb9005d13 [gaim-migrate @ 2771]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2747
diff changeset
1758 while (g) {
269fb9005d13 [gaim-migrate @ 2771]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2747
diff changeset
1759 GSList *m = ((struct group *)g->data)->members;
269fb9005d13 [gaim-migrate @ 2771]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2747
diff changeset
1760 while (m) {
269fb9005d13 [gaim-migrate @ 2771]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2747
diff changeset
1761 struct buddy *b = m->data;
269fb9005d13 [gaim-migrate @ 2771]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2747
diff changeset
1762 if (b->present)
269fb9005d13 [gaim-migrate @ 2771]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2747
diff changeset
1763 msn_reset_friend(gc, b->name);
269fb9005d13 [gaim-migrate @ 2771]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2747
diff changeset
1764 m = m->next;
269fb9005d13 [gaim-migrate @ 2771]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2747
diff changeset
1765 }
269fb9005d13 [gaim-migrate @ 2771]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2747
diff changeset
1766 g = g->next;
269fb9005d13 [gaim-migrate @ 2771]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2747
diff changeset
1767 }
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1768 }
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1769 }
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1770
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1771 static GList *msn_actions()
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1772 {
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1773 GList *m = NULL;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1774
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1775 m = g_list_append(m, "Set Friendly Name");
2758
269fb9005d13 [gaim-migrate @ 2771]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2747
diff changeset
1776 m = g_list_append(m, "Reset All Friendly Names");
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1777
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1778 return m;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1779 }
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1780
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1781 static void msn_convo_closed(struct gaim_connection *gc, char *who)
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1782 {
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1783 struct msn_switchboard *ms = msn_find_switch(gc, who);
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1784
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1785 if (ms)
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1786 msn_kill_switch(ms);
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1787 }
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1788
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1789 static void msn_keepalive(struct gaim_connection *gc)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1790 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1791 struct msn_data *md = gc->proto_data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1792 char buf[MSN_BUF_LEN];
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1793
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1794 g_snprintf(buf, sizeof(buf), "PNG\r\n");
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1795 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1796 hide_login_progress(gc, "Write error");
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1797 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1798 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1799 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1800 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1801
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1802 static void msn_set_permit_deny(struct gaim_connection *gc)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1803 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1804 struct msn_data *md = gc->proto_data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1805 char buf[MSN_BUF_LEN];
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1806 GSList *s, *t = NULL;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1807
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1808 if (gc->permdeny == PERMIT_ALL || gc->permdeny == DENY_SOME)
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1809 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
1810 else
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1811 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
1812
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1813 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1814 hide_login_progress(gc, "Write error");
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1815 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1816 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1817 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1818
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1819 /* 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
1820 * 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
1821 * and so there's no sense in going through them all. */
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1822 if (g_slist_length(gc->permit) == g_slist_length(md->permit)) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1823 g_slist_free(md->permit);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1824 md->permit = NULL;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1825 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1826 if (g_slist_length(gc->deny) == g_slist_length(md->deny)) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1827 g_slist_free(md->deny);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1828 md->deny = NULL;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1829 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1830 if (!md->permit && !md->deny)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1831 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1832
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1833 s = g_slist_nth(gc->permit, g_slist_length(md->permit));
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1834 while (s) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1835 char *who = s->data;
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1836 s = s->next;
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1837 if (!strchr(who, '@')) {
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1838 t = g_slist_append(t, who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1839 continue;
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1840 }
2747
51fc8e5acd7a [gaim-migrate @ 2760]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2740
diff changeset
1841 who = url_encode(who);
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1842 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
1843 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1844 hide_login_progress(gc, "Write error");
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1845 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1846 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1847 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1848 }
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1849 while (t) {
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1850 char *who = t->data;
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1851 gc->permit = g_slist_remove(gc->permit, who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1852 g_free(who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1853 t = t->next;
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1854 }
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1855 if (t)
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1856 g_slist_free(t);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1857 t = NULL;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1858 g_slist_free(md->permit);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1859 md->permit = NULL;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1860
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1861 s = g_slist_nth(gc->deny, g_slist_length(md->deny));
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1862 while (s) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1863 char *who = s->data;
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1864 s = s->next;
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1865 if (!strchr(who, '@')) {
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1866 t = g_slist_append(t, who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1867 continue;
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1868 }
2747
51fc8e5acd7a [gaim-migrate @ 2760]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2740
diff changeset
1869 who = url_encode(who);
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1870 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
1871 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1872 hide_login_progress(gc, "Write error");
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1873 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1874 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1875 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1876 }
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1877 while (t) {
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1878 char *who = t->data;
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1879 gc->deny = g_slist_remove(gc->deny, who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1880 g_free(who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1881 t = t->next;
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1882 }
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1883 if (t)
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1884 g_slist_free(t);
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1885 g_slist_free(md->deny);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1886 md->deny = NULL;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1887 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1888
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1889 static void msn_add_permit(struct gaim_connection *gc, char *who)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1890 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1891 struct msn_data *md = gc->proto_data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1892 char buf[MSN_BUF_LEN];
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1893
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1894 if (!strchr(who, '@')) {
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1895 do_error_dialog(_("Invalid name"), _("MSN Error"));
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1896 gc->permit = g_slist_remove(gc->permit, who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1897 g_free(who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1898 return;
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1899 }
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1900
2747
51fc8e5acd7a [gaim-migrate @ 2760]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2740
diff changeset
1901 who = url_encode(who);
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1902 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
1903 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1904 hide_login_progress(gc, "Write error");
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1905 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1906 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1907 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1908 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1909
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1910 static void msn_rem_permit(struct gaim_connection *gc, char *who)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1911 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1912 struct msn_data *md = gc->proto_data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1913 char buf[MSN_BUF_LEN];
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1914
2747
51fc8e5acd7a [gaim-migrate @ 2760]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2740
diff changeset
1915 who = url_encode(who);
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1916 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
1917 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1918 hide_login_progress(gc, "Write error");
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1919 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1920 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1921 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1922 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1923
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1924 static void msn_add_deny(struct gaim_connection *gc, char *who)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1925 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1926 struct msn_data *md = gc->proto_data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1927 char buf[MSN_BUF_LEN];
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1928
2665
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1929 if (!strchr(who, '@')) {
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1930 do_error_dialog(_("Invalid name"), _("MSN Error"));
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1931 gc->deny = g_slist_remove(gc->deny, who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1932 g_free(who);
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1933 return;
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1934 }
b0478af51be0 [gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2611
diff changeset
1935
2747
51fc8e5acd7a [gaim-migrate @ 2760]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2740
diff changeset
1936 who = url_encode(who);
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1937 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
1938 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1939 hide_login_progress(gc, "Write error");
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1940 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1941 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1942 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1943 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1944
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1945 static void msn_rem_deny(struct gaim_connection *gc, char *who)
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1946 {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1947 struct msn_data *md = gc->proto_data;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1948 char buf[MSN_BUF_LEN];
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1949
2747
51fc8e5acd7a [gaim-migrate @ 2760]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2740
diff changeset
1950 who = url_encode(who);
2603
24664768a739 [gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2600
diff changeset
1951 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
1952 if (msn_write(md->fd, buf, strlen(buf)) < 0) {
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1953 hide_login_progress(gc, "Write error");
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1954 signoff(gc);
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1955 return;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1956 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1957 }
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1958
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1959 static void msn_buddy_free(struct buddy *b)
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1960 {
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1961 if (b->proto_data)
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1962 g_free(b->proto_data);
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1963 }
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1964
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1965 static struct prpl *my_protocol = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1966
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1967 void msn_init(struct prpl *ret)
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 ret->protocol = PROTO_MSN;
2153
0befa2d2e540 [gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2152
diff changeset
1970 ret->options = OPT_PROTO_MAIL_CHECK;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1971 ret->name = msn_name;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1972 ret->list_icon = msn_list_icon;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1973 ret->buddy_menu = msn_buddy_menu;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1974 ret->login = msn_login;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1975 ret->close = msn_close;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1976 ret->send_im = msn_send_im;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1977 ret->away_states = msn_away_states;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1978 ret->set_away = msn_set_away;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1979 ret->set_idle = msn_set_idle;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1980 ret->add_buddy = msn_add_buddy;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1981 ret->remove_buddy = msn_rem_buddy;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1982 ret->chat_send = msn_chat_send;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1983 ret->chat_invite = msn_chat_invite;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1984 ret->chat_leave = msn_chat_leave;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1985 ret->normalize = msn_normalize;
2213
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1986 ret->do_action = msn_do_action;
a226ebf4be47 [gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2210
diff changeset
1987 ret->actions = msn_actions;
2591
b771cbe7e161 [gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2588
diff changeset
1988 ret->convo_closed = msn_convo_closed;
2597
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1989 ret->keepalive = msn_keepalive;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1990 ret->set_permit_deny = msn_set_permit_deny;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1991 ret->add_permit = msn_add_permit;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1992 ret->rem_permit = msn_rem_permit;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1993 ret->add_deny = msn_add_deny;
2ced57c58653 [gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2591
diff changeset
1994 ret->rem_deny = msn_rem_deny;
2607
e0d4a23aac89 [gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2603
diff changeset
1995 ret->buddy_free = msn_buddy_free;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1996
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1997 my_protocol = ret;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1998 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1999
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2000 #ifndef STATIC
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2001
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2002 char *gaim_plugin_init(GModule *handle)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2003 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2004 load_protocol(msn_init, sizeof(struct prpl));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2005 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2006 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2007
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2008 void gaim_plugin_remove()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2009 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2010 struct prpl *p = find_prpl(PROTO_MSN);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2011 if (p == my_protocol)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2012 unload_protocol(p);
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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2015 char *name()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2016 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2017 return "MSN";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2018 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2019
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2020 char *description()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2021 {
2162
a464da684307 [gaim-migrate @ 2172]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2153
diff changeset
2022 return PRPL_DESC("MSN");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2023 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2024
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2025 #endif