Mercurial > pidgin
annotate plugins/msn/msn.c @ 2039:859e9c2c5813
[gaim-migrate @ 2049]
utf8
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 16 Jun 2001 19:16:25 +0000 |
parents | cb4fbcdae9eb |
children | 64a07b9e9202 |
rev | line source |
---|---|
1514
0dd012166152
[gaim-migrate @ 1524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
1 #include "config.h" |
1259 | 2 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
3 #include <stdlib.h> |
1259 | 4 #include <gtk/gtk.h> |
5 #include <string.h> | |
6 #include <stdio.h> | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
7 #include <unistd.h> |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
8 #include <ctype.h> |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
9 #include "gaim.h" |
1259 | 10 #include "prpl.h" |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
11 #include "proxy.h" |
1259 | 12 #include "md5.h" |
13 | |
1284 | 14 #include "pixmaps/msn_online.xpm" |
1285 | 15 #include "pixmaps/msn_away.xpm" |
1259 | 16 |
1567 | 17 #define MSN_BUF_LEN 8192 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
18 #define MIME_HEADER "MIME-Version: 1.0\r\n" \ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
19 "Content-Type: text/plain; charset=UTF-8\r\n" \ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
20 "X-MMS-IM-Format: FN=MS%20Sans%20Serif; EF=; CO=0; PF=0\r\n\r\n" |
1259 | 21 |
22 #define MSN_ONLINE 1 | |
23 #define MSN_BUSY 2 | |
24 #define MSN_IDLE 3 | |
25 #define MSN_BRB 4 | |
26 #define MSN_AWAY 5 | |
27 #define MSN_PHONE 6 | |
28 #define MSN_LUNCH 7 | |
29 #define MSN_OFFLINE 8 | |
30 #define MSN_HIDDEN 9 | |
31 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
32 #define USEROPT_HOTMAIL 0 |
1598 | 33 |
1259 | 34 struct msn_data { |
35 int fd; | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
36 int trId; |
1567 | 37 int inpa; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
38 GSList *switches; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
39 GSList *fl; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
40 gboolean imported; |
1259 | 41 }; |
42 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
43 struct msn_switchboard { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
44 struct gaim_connection *gc; |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
45 struct conversation *chat; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
46 int fd; |
1259 | 47 int inpa; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
48 char *sessid; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
49 char *auth; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
50 int trId; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
51 int total; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
52 char *user; |
1584 | 53 char *txqueue; |
1259 | 54 }; |
55 | |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
56 struct msn_buddy { |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
57 char *user; |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
58 char *friend; |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
59 }; |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
60 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
61 static void msn_login_callback(gpointer, gint, GdkInputCondition); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
62 static void msn_login_xfr_connect(gpointer, gint, GdkInputCondition); |
1588 | 63 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
64 #define GET_NEXT(tmp) while (*(tmp) && !isspace(*(tmp))) \ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
65 (tmp)++; \ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
66 *(tmp)++ = 0; \ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
67 while (*(tmp) && isspace(*(tmp))) \ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
68 (tmp)++; |
1259 | 69 |
1282 | 70 char *name() |
71 { | |
1259 | 72 return "MSN"; |
73 } | |
74 | |
1282 | 75 char *description() |
76 { | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
77 return "Allows gaim to use the MSN protocol."; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
78 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
79 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
80 static char *msn_name() |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
81 { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
82 return "MSN"; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
83 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
84 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
85 static char *msn_normalize(const char *s) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
86 { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
87 static char buf[BUF_LEN]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
88 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
89 g_return_val_if_fail(s != NULL, NULL); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
90 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
91 g_snprintf(buf, sizeof(buf), "%s%s", s, strchr(s, '@') ? "" : "@hotmail.com"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
92 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
93 return buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
94 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
95 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
96 static int msn_write(int fd, void *data, int len) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
97 { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
98 debug_printf("C: %s", data); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
99 return write(fd, data, len); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
100 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
101 |
1986
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
102 static char *url_decode(const char *msg) |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
103 { |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
104 static char buf[MSN_BUF_LEN]; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
105 int i, j = 0; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
106 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
107 bzero(buf, sizeof(buf)); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
108 for (i = 0; i < strlen(msg); i++) { |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
109 char hex[3]; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
110 if (msg[i] != '%') { |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
111 buf[j++] = msg[i]; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
112 continue; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
113 } |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
114 g_snprintf(hex, sizeof(hex), "%s", msg + ++i); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
115 i++; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
116 sscanf(hex, "%x", (unsigned int *)&buf[j++]); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
117 } |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
118 buf[j] = 0; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
119 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
120 return buf; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
121 } |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
122 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
123 static char *handle_errcode(char *buf, gboolean show) |
1282 | 124 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
125 int errcode; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
126 static char msg[MSN_BUF_LEN]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
127 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
128 buf[4] = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
129 errcode = atoi(buf); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
130 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
131 switch (errcode) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
132 case 200: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
133 g_snprintf(msg, sizeof(msg), "Syntax Error (probably a Gaim bug)"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
134 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
135 case 201: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
136 g_snprintf(msg, sizeof(msg), "Invalid Parameter (probably a Gaim bug)"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
137 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
138 case 205: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
139 g_snprintf(msg, sizeof(msg), "Invalid User"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
140 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
141 case 206: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
142 g_snprintf(msg, sizeof(msg), "Fully Qualified Domain Name missing"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
143 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
144 case 207: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
145 g_snprintf(msg, sizeof(msg), "Already Login"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
146 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
147 case 208: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
148 g_snprintf(msg, sizeof(msg), "Invalid Username"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
149 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
150 case 209: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
151 g_snprintf(msg, sizeof(msg), "Invalid Friendly Name"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
152 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
153 case 210: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
154 g_snprintf(msg, sizeof(msg), "List Full"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
155 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
156 case 215: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
157 g_snprintf(msg, sizeof(msg), "Already there"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
158 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
159 case 216: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
160 g_snprintf(msg, sizeof(msg), "Not on list"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
161 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
162 case 218: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
163 g_snprintf(msg, sizeof(msg), "Already in the mode"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
164 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
165 case 219: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
166 g_snprintf(msg, sizeof(msg), "Already in opposite list"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
167 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
168 case 280: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
169 g_snprintf(msg, sizeof(msg), "Switchboard failed"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
170 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
171 case 281: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
172 g_snprintf(msg, sizeof(msg), "Notify Transfer failed"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
173 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
174 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
175 case 300: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
176 g_snprintf(msg, sizeof(msg), "Required fields missing"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
177 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
178 case 302: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
179 g_snprintf(msg, sizeof(msg), "Not logged in"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
180 break; |
1567 | 181 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
182 case 500: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
183 g_snprintf(msg, sizeof(msg), "Internal server error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
184 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
185 case 501: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
186 g_snprintf(msg, sizeof(msg), "Database server error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
187 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
188 case 510: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
189 g_snprintf(msg, sizeof(msg), "File operation error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
190 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
191 case 520: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
192 g_snprintf(msg, sizeof(msg), "Memory allocation error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
193 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
194 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
195 case 600: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
196 g_snprintf(msg, sizeof(msg), "Server busy"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
197 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
198 case 601: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
199 g_snprintf(msg, sizeof(msg), "Server unavailable"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
200 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
201 case 602: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
202 g_snprintf(msg, sizeof(msg), "Peer Notification server down"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
203 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
204 case 603: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
205 g_snprintf(msg, sizeof(msg), "Database connect error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
206 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
207 case 604: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
208 g_snprintf(msg, sizeof(msg), "Server is going down (abandon ship)"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
209 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
210 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
211 case 707: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
212 g_snprintf(msg, sizeof(msg), "Error creating connection"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
213 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
214 case 711: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
215 g_snprintf(msg, sizeof(msg), "Unable to write"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
216 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
217 case 712: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
218 g_snprintf(msg, sizeof(msg), "Session overload"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
219 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
220 case 713: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
221 g_snprintf(msg, sizeof(msg), "User is too active"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
222 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
223 case 714: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
224 g_snprintf(msg, sizeof(msg), "Too many sessions"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
225 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
226 case 715: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
227 g_snprintf(msg, sizeof(msg), "Not expected"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
228 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
229 case 717: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
230 g_snprintf(msg, sizeof(msg), "Bad friend file"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
231 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
232 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
233 case 911: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
234 g_snprintf(msg, sizeof(msg), "Authentication failed"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
235 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
236 case 913: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
237 g_snprintf(msg, sizeof(msg), "Not allowed when offline"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
238 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
239 case 920: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
240 g_snprintf(msg, sizeof(msg), "Not accepting new users"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
241 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
242 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
243 default: |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
244 g_snprintf(msg, sizeof(msg), "Unknown Error Code"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
245 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
246 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
247 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
248 if (show) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
249 do_error_dialog(msg, "MSN Error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
250 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
251 return msg; |
1733 | 252 } |
253 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
254 static void handle_hotmail(struct gaim_connection *gc, char *data) |
1733 | 255 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
256 char *mailct, *mailp, *from = NULL, *subj = NULL, notice[MSN_BUF_LEN]; |
1733 | 257 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
258 if (gc->user->proto_opt[USEROPT_HOTMAIL][0] != '1') return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
259 mailct = strstr(data, "Content-Type: "); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
260 mailp = strstr(mailct, ";"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
261 if (mailct && mailp && (mailp > mailct) && |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
262 !strncmp(mailct, "Content-Type: text/x-msmsgsemailnotification", mailp - mailct - 1)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
263 from = strstr(mailp, "From: "); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
264 subj = strstr(mailp, "Subject: "); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
265 } |
1733 | 266 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
267 if (!from || !subj) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
268 return; |
1733 | 269 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
270 from += strlen("From: "); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
271 mailp = strstr(from, "\r\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
272 if (!mailp) return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
273 *mailp = 0; |
1733 | 274 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
275 subj += strlen("Subject: "); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
276 mailp = strstr(from, "\r\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
277 if (!mailp) return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
278 *mailp = 0; |
1833 | 279 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
280 g_snprintf(notice, sizeof(notice), "Mail from %s, re: %s", from, subj); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
281 do_error_dialog(notice, "New MSN Mail"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
282 } |
1733 | 283 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
284 static struct msn_switchboard *msn_find_switch(struct gaim_connection *gc, char *id) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
285 { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
286 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
287 GSList *m = md->switches; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
288 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
289 while (m) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
290 struct msn_switchboard *ms = m->data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
291 m = m->next; |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
292 if ((ms->total == 1) && !g_strcasecmp(ms->user, id)) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
293 return ms; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
294 } |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
295 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
296 return NULL; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
297 } |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
298 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
299 static struct msn_switchboard *msn_find_switch_by_id(struct gaim_connection *gc, int id) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
300 { |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
301 struct msn_data *md = gc->proto_data; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
302 GSList *m = md->switches; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
303 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
304 while (m) { |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
305 struct msn_switchboard *ms = m->data; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
306 m = m->next; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
307 if (ms->chat && (ms->chat->id == id)) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
308 return ms; |
1733 | 309 } |
310 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
311 return NULL; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
312 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
313 |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
314 static struct msn_switchboard *msn_find_writable_switch(struct gaim_connection *gc) |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
315 { |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
316 struct msn_data *md = gc->proto_data; |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
317 GSList *m = md->switches; |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
318 |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
319 while (m) { |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
320 struct msn_switchboard *ms = m->data; |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
321 m = m->next; |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
322 if (ms->txqueue) |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
323 return ms; |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
324 } |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
325 |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
326 return NULL; |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
327 } |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
328 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
329 static void msn_kill_switch(struct msn_switchboard *ms) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
330 { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
331 struct gaim_connection *gc = ms->gc; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
332 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
333 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
334 gdk_input_remove(ms->inpa); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
335 close(ms->fd); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
336 if (ms->sessid) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
337 g_free(ms->sessid); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
338 g_free(ms->auth); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
339 if (ms->user) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
340 g_free(ms->user); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
341 if (ms->txqueue) |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
342 g_free(ms->txqueue); |
2024
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
343 if (ms->chat) |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
344 serv_got_chat_left(gc, ms->chat->id); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
345 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
346 md->switches = g_slist_remove(md->switches, ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
347 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
348 g_free(ms); |
1567 | 349 } |
1259 | 350 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
351 static void msn_switchboard_callback(gpointer data, gint source, GdkInputCondition cond) |
1572 | 352 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
353 struct msn_switchboard *ms = data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
354 struct gaim_connection *gc = ms->gc; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
355 char buf[MSN_BUF_LEN]; |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
356 static int id = 0; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
357 int i = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
358 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
359 bzero(buf, sizeof(buf)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
360 while ((read(ms->fd, buf + i, 1) > 0) && (buf[i++] != '\n')) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
361 if (i == sizeof(buf)) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
362 i--; /* yes i know this loses data but we shouldn't get messages this long |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
363 and it's better than possibly writing past our buffer */ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
364 if (i == 0 || buf[i - 1] != '\n') { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
365 msn_kill_switch(ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
366 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
367 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
368 debug_printf("S: %s", buf); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
369 g_strchomp(buf); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
370 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
371 if (!g_strncasecmp(buf, "ACK", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
372 } else if (!g_strncasecmp(buf, "ANS", 3)) { |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
373 if (ms->chat) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
374 add_chat_buddy(ms->chat, gc->username); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
375 } else if (!g_strncasecmp(buf, "BYE", 3)) { |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
376 if (ms->chat) { |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
377 char *user, *tmp = buf; |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
378 GET_NEXT(tmp); |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
379 user = tmp; |
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
380 remove_chat_buddy(ms->chat, user); |
2038
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
381 } else |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
382 msn_kill_switch(ms); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
383 } else if (!g_strncasecmp(buf, "CAL", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
384 } else if (!g_strncasecmp(buf, "IRO", 3)) { |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
385 char *tot, *user, *tmp = buf; |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
386 |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
387 GET_NEXT(tmp); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
388 GET_NEXT(tmp); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
389 GET_NEXT(tmp); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
390 tot = tmp; |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
391 GET_NEXT(tmp); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
392 ms->total = atoi(tot); |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
393 user = tmp; |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
394 GET_NEXT(tmp); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
395 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
396 if (ms->total > 1) { |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
397 if (!ms->chat) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
398 ms->chat = serv_got_joined_chat(gc, ++id, "MSN Chat"); |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
399 add_chat_buddy(ms->chat, user); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
400 } |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
401 } else if (!g_strncasecmp(buf, "JOI", 3)) { |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
402 char *user, *tmp = buf; |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
403 GET_NEXT(tmp); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
404 user = tmp; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
405 GET_NEXT(tmp); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
406 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
407 if (ms->total == 1) { |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
408 ms->chat = serv_got_joined_chat(gc, ++id, "MSN Chat"); |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
409 add_chat_buddy(ms->chat, ms->user); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
410 add_chat_buddy(ms->chat, gc->username); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
411 g_free(ms->user); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
412 ms->user = NULL; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
413 } |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
414 if (ms->chat) |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
415 add_chat_buddy(ms->chat, user); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
416 ms->total++; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
417 if (ms->txqueue) { |
2039
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2038
diff
changeset
|
418 char *utf8 = str_to_utf8(ms->txqueue); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
419 g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s", ++ms->trId, |
2039
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2038
diff
changeset
|
420 strlen(MIME_HEADER) + strlen(utf8), |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2038
diff
changeset
|
421 MIME_HEADER, utf8); |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2038
diff
changeset
|
422 g_free(utf8); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
423 g_free(ms->txqueue); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
424 ms->txqueue = NULL; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
425 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
426 msn_kill_switch(ms); |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
427 debug_printf("\n"); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
428 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
429 } else if (!g_strncasecmp(buf, "MSG", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
430 char *user, *tmp = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
431 int length; |
2038
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
432 char *msg, *content, *utf; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
433 int len; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
434 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
435 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
436 user = tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
437 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
438 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
439 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
440 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
441 length = atoi(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
442 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
443 msg = g_new0(char, MAX(length + 1, MSN_BUF_LEN)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
444 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
445 if (read(ms->fd, msg, length) != length) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
446 g_free(msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
447 hide_login_progress(gc, "Unable to read message"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
448 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
449 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
450 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
451 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
452 |
1992
5121e706af6d
[gaim-migrate @ 2002]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1991
diff
changeset
|
453 content = strstr(msg, "Content-Type: "); |
2038
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
454 if (!content) { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
455 g_free(msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
456 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
457 } |
2038
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
458 if (!g_strncasecmp(content, "Content-Type: text/plain", |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
459 strlen("Content-Type: text/plain"))) { |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
460 char *final, *skiphead; |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
461 skiphead = strstr(msg, "\r\n\r\n"); |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
462 if (!skiphead || !skiphead[4]) { |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
463 g_free(msg); |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
464 return; |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
465 } |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
466 skiphead += 4; |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
467 utf = utf8_to_str(skiphead); |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
468 len = MAX(strlen(utf) + 1, BUF_LEN); |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
469 final = g_malloc(len); |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
470 g_snprintf(final, len, "%s", utf); |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
471 g_free(utf); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
472 |
2038
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
473 if (ms->chat) |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
474 serv_got_chat_in(gc, ms->chat->id, user, 0, final, time(NULL)); |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
475 else |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
476 serv_got_im(gc, user, final, 0, time(NULL)); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
477 |
2038
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
478 g_free(final); |
cb4fbcdae9eb
[gaim-migrate @ 2048]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2024
diff
changeset
|
479 } |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
480 g_free(msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
481 } else if (!g_strncasecmp(buf, "NAK", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
482 do_error_dialog("A message may not have been received.", "MSN Error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
483 } else if (!g_strncasecmp(buf, "NLN", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
484 } else if (!g_strncasecmp(buf, "OUT", 3)) { |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
485 if (ms->chat) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
486 serv_got_chat_left(gc, ms->chat->id); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
487 msn_kill_switch(ms); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
488 } else if (!g_strncasecmp(buf, "USR", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
489 /* good, we got USR, now we need to find out who we want to talk to */ |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
490 struct msn_switchboard *ms = msn_find_writable_switch(gc); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
491 |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
492 if (!ms) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
493 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
494 |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
495 g_snprintf(buf, sizeof(buf), "CAL %d %s\n", ++ms->trId, ms->user); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
496 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
497 msn_kill_switch(ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
498 } else if (isdigit(*buf)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
499 handle_errcode(buf, TRUE); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
500 } else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
501 debug_printf("Unhandled message!\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
502 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
503 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
504 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
505 static void msn_rng_connect(gpointer data, gint source, GdkInputCondition cond) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
506 { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
507 struct msn_switchboard *ms = data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
508 struct gaim_connection *gc = ms->gc; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
509 struct msn_data *md; |
1572 | 510 char buf[MSN_BUF_LEN]; |
511 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
512 if (source == -1 || !g_slist_find(connections, gc)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
513 g_free(ms->sessid); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
514 g_free(ms->auth); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
515 g_free(ms); |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
516 return; |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
517 } |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
518 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
519 md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
520 |
2015
0d11fd498068
[gaim-migrate @ 2025]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2014
diff
changeset
|
521 if (ms->fd != source) |
0d11fd498068
[gaim-migrate @ 2025]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2014
diff
changeset
|
522 ms->fd = source; |
1572 | 523 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
524 g_snprintf(buf, sizeof(buf), "ANS %d %s %s %s\n", ++ms->trId, gc->username, ms->auth, ms->sessid); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
525 if (msn_write(ms->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
526 close(ms->fd); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
527 g_free(ms->sessid); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
528 g_free(ms->auth); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
529 g_free(ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
530 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
531 } |
1572 | 532 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
533 md->switches = g_slist_append(md->switches, ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
534 ms->inpa = gdk_input_add(ms->fd, GDK_INPUT_READ, msn_switchboard_callback, ms); |
1572 | 535 } |
536 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
537 static void msn_ss_xfr_connect(gpointer data, gint source, GdkInputCondition cond) |
1584 | 538 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
539 struct msn_switchboard *ms = data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
540 struct gaim_connection *gc = ms->gc; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
541 char buf[MSN_BUF_LEN]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
542 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
543 if (source == -1 || !g_slist_find(connections, gc)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
544 g_free(ms->auth); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
545 g_free(ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
546 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
547 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
548 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
549 if (ms->fd != source) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
550 ms->fd = source; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
551 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
552 g_snprintf(buf, sizeof(buf), "USR %d %s %s\n", ++ms->trId, gc->username, ms->auth); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
553 if (msn_write(ms->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
554 g_free(ms->auth); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
555 g_free(ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
556 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
557 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
558 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
559 ms->inpa = gdk_input_add(ms->fd, GDK_INPUT_READ, msn_switchboard_callback, ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
560 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
561 |
1986
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
562 struct msn_add_permit { |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
563 struct gaim_connection *gc; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
564 char *user; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
565 char *friend; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
566 }; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
567 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
568 static void msn_accept_add(gpointer w, struct msn_add_permit *map) |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
569 { |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
570 struct msn_data *md = map->gc->proto_data; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
571 char buf[MSN_BUF_LEN]; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
572 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
573 g_snprintf(buf, sizeof(buf), "ADD %d AL %s %s\n", ++md->trId, map->user, map->friend); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
574 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
575 hide_login_progress(map->gc, "Write error"); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
576 signoff(map->gc); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
577 return; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
578 } |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
579 } |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
580 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
581 static void msn_cancel_add(gpointer w, struct msn_add_permit *map) |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
582 { |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
583 g_free(map->user); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
584 g_free(map->friend); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
585 g_free(map); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
586 } |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
587 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
588 static void msn_callback(gpointer data, gint source, GdkInputCondition cond) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
589 { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
590 struct gaim_connection *gc = data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
591 struct msn_data *md = gc->proto_data; |
1584 | 592 char buf[MSN_BUF_LEN]; |
593 int i = 0; | |
594 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
595 bzero(buf, sizeof(buf)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
596 while ((read(md->fd, buf + i, 1) > 0) && (buf[i++] != '\n')) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
597 if (i == sizeof(buf)) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
598 i--; /* yes i know this loses data but we shouldn't get messages this long |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
599 and it's better than possibly writing past our buffer */ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
600 if (i == 0 || buf[i - 1] != '\n') { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
601 hide_login_progress(gc, "Error reading from server"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
602 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
603 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
604 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
605 debug_printf("S: %s", buf); |
1584 | 606 g_strchomp(buf); |
607 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
608 if (!g_strncasecmp(buf, "ADD", 3)) { |
1986
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
609 char *list, *user, *friend, *tmp = buf; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
610 struct msn_add_permit *ap = g_new0(struct msn_add_permit, 1); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
611 char msg[MSN_BUF_LEN]; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
612 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
613 GET_NEXT(tmp); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
614 GET_NEXT(tmp); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
615 list = tmp; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
616 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
617 GET_NEXT(tmp); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
618 GET_NEXT(tmp); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
619 user = tmp; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
620 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
621 GET_NEXT(tmp); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
622 friend = tmp; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
623 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
624 if (g_strcasecmp(list, "RL")) |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
625 return; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
626 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
627 ap->user = g_strdup(user); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
628 ap->friend = g_strdup(friend); |
1986
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
629 ap->gc = gc; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
630 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
631 g_snprintf(msg, sizeof(msg), "The user %s (%s) wants to add you to their buddy list.", |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
632 ap->user, url_decode(ap->friend)); |
1986
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
633 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
634 do_ask_dialog(msg, ap, msn_accept_add, msn_cancel_add); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
635 } else if (!g_strncasecmp(buf, "BLP", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
636 } else if (!g_strncasecmp(buf, "BPR", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
637 } else if (!g_strncasecmp(buf, "CHG", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
638 } else if (!g_strncasecmp(buf, "FLN", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
639 char *usr = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
640 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
641 GET_NEXT(usr); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
642 serv_got_update(gc, usr, 0, 0, 0, 0, 0, 0); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
643 } else if (!g_strncasecmp(buf, "GTC", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
644 } else if (!g_strncasecmp(buf, "INF", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
645 } else if (!g_strncasecmp(buf, "ILN", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
646 char *state, *user, *tmp = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
647 int status = UC_NORMAL; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
648 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
649 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
650 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
651 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
652 state = tmp; |
1584 | 653 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
654 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
655 user = tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
656 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
657 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
658 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
659 if (!g_strcasecmp(state, "BSY")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
660 status |= (MSN_BUSY << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
661 } else if (!g_strcasecmp(state, "IDL")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
662 status |= (MSN_IDLE << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
663 } else if (!g_strcasecmp(state, "BRB")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
664 status |= (MSN_BRB << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
665 } else if (!g_strcasecmp(state, "AWY")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
666 status = UC_UNAVAILABLE; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
667 } else if (!g_strcasecmp(state, "PHN")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
668 status |= (MSN_PHONE << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
669 } else if (!g_strcasecmp(state, "LUN")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
670 status |= (MSN_LUNCH << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
671 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
672 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
673 serv_got_update(gc, user, 1, 0, 0, 0, status, 0); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
674 } else if (!g_strncasecmp(buf, "LST", 3)) { |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
675 char *which, *who, *friend, *tmp = buf; |
1584 | 676 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
677 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
678 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
679 which = tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
680 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
681 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
682 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
683 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
684 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
685 who = tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
686 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
687 GET_NEXT(tmp); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
688 friend = url_decode(tmp); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
689 |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
690 if (!g_strcasecmp(which, "FL")) { |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
691 struct msn_buddy *b = g_new0(struct msn_buddy, 1); |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
692 b->user = g_strdup(who); |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
693 b->friend = g_strdup(friend); |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
694 md->fl = g_slist_append(md->fl, b); |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
695 } else if (!md->imported) { |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
696 if (bud_list_cache_exists(gc)) |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
697 do_import(NULL, gc); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
698 md->imported = TRUE; |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
699 while (md->fl) { |
1994
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
700 struct msn_buddy *mb = md->fl->data; |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
701 struct buddy *b; |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
702 md->fl = g_slist_remove(md->fl, mb); |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
703 if (!(b = find_buddy(gc, mb->user))) |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
704 add_buddy(gc, "Buddies", mb->user, mb->friend); |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
705 else if (!g_strcasecmp(b->name, b->show)) { |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
706 g_snprintf(b->show, sizeof(b->show), "%s", mb->friend); |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
707 handle_buddy_rename(b, b->name); |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
708 } |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
709 g_free(mb->user); |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
710 g_free(mb->friend); |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
711 g_free(mb); |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
712 } |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
713 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
714 } else if (!g_strncasecmp(buf, "MSG", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
715 char *user, *tmp = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
716 int length; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
717 char *msg, *skiphead, *utf, *final; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
718 int len; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
719 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
720 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
721 user = tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
722 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
723 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
724 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
725 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
726 length = atoi(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
727 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
728 msg = g_new0(char, MAX(length + 1, MSN_BUF_LEN)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
729 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
730 if (read(md->fd, msg, length) != length) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
731 g_free(msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
732 hide_login_progress(gc, "Unable to read message"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
733 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
734 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
735 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
736 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
737 if (!g_strcasecmp(user, "hotmail")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
738 handle_hotmail(gc, msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
739 g_free(msg); |
1584 | 740 return; |
741 } | |
742 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
743 skiphead = strstr(msg, "\r\n\r\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
744 if (!skiphead || !skiphead[4]) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
745 g_free(msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
746 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
747 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
748 skiphead += 4; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
749 utf = utf8_to_str(skiphead); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
750 len = MAX(strlen(utf) + 1, BUF_LEN); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
751 final = g_malloc(len); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
752 g_snprintf(final, len, "%s", utf); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
753 g_free(utf); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
754 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
755 serv_got_im(gc, user, final, 0, time(NULL)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
756 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
757 g_free(final); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
758 g_free(msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
759 } else if (!g_strncasecmp(buf, "NLN", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
760 char *state, *user, *tmp = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
761 int status = UC_NORMAL; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
762 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
763 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
764 state = tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
765 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
766 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
767 user = tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
768 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
769 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
770 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
771 if (!g_strcasecmp(state, "BSY")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
772 status |= (MSN_BUSY << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
773 } else if (!g_strcasecmp(state, "IDL")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
774 status |= (MSN_IDLE << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
775 } else if (!g_strcasecmp(state, "BRB")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
776 status |= (MSN_BRB << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
777 } else if (!g_strcasecmp(state, "AWY")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
778 status = UC_UNAVAILABLE; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
779 } else if (!g_strcasecmp(state, "PHN")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
780 status |= (MSN_PHONE << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
781 } else if (!g_strcasecmp(state, "LUN")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
782 status |= (MSN_LUNCH << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
783 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
784 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
785 serv_got_update(gc, user, 1, 0, 0, 0, status, 0); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
786 } else if (!g_strncasecmp(buf, "OUT", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
787 } else if (!g_strncasecmp(buf, "PRP", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
788 } else if (!g_strncasecmp(buf, "REM", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
789 } else if (!g_strncasecmp(buf, "RNG", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
790 struct msn_switchboard *ms; |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
791 char *sessid, *ssaddr, *auth, *user; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
792 int port, i = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
793 char *tmp = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
794 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
795 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
796 sessid = tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
797 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
798 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
799 ssaddr = tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
800 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
801 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
802 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
803 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
804 auth = tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
805 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
806 GET_NEXT(tmp); |
1989
21c595ef11c8
[gaim-migrate @ 1999]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1988
diff
changeset
|
807 user = tmp; |
21c595ef11c8
[gaim-migrate @ 1999]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1988
diff
changeset
|
808 GET_NEXT(tmp); |
1584 | 809 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
810 while (ssaddr[i] && ssaddr[i] != ':') i++; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
811 if (ssaddr[i] == ':') { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
812 char *x = &ssaddr[i + 1]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
813 ssaddr[i] = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
814 port = atoi(x); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
815 } else |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
816 port = 1863; |
1584 | 817 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
818 ms = g_new0(struct msn_switchboard, 1); |
1989
21c595ef11c8
[gaim-migrate @ 1999]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1988
diff
changeset
|
819 ms->user = g_strdup(user); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
820 ms->sessid = g_strdup(sessid); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
821 ms->auth = g_strdup(auth); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
822 ms->gc = gc; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
823 ms->fd = proxy_connect(ssaddr, port, msn_rng_connect, ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
824 } else if (!g_strncasecmp(buf, "SYN", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
825 } else if (!g_strncasecmp(buf, "USR", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
826 } else if (!g_strncasecmp(buf, "XFR", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
827 char *host = strstr(buf, "SB"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
828 int port; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
829 int i = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
830 gboolean switchboard = TRUE; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
831 char *tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
832 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
833 if (!host) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
834 host = strstr(buf, "NS"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
835 if (!host) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
836 hide_login_progress(gc, "Got invalid XFR\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
837 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
838 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
839 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
840 switchboard = FALSE; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
841 } |
1584 | 842 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
843 GET_NEXT(host); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
844 while (host[i] && host[i] != ':') i++; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
845 if (host[i] == ':') { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
846 tmp = &host[i + 1]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
847 host[i] = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
848 while (isdigit(*tmp)) tmp++; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
849 *tmp++ = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
850 port = atoi(&host[i + 1]); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
851 } else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
852 port = 1863; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
853 tmp = host; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
854 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
855 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
856 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
857 if (switchboard) { |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
858 struct msn_switchboard *ms = msn_find_writable_switch(gc); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
859 if (!ms) |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
860 return; |
1584 | 861 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
862 GET_NEXT(tmp); |
1584 | 863 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
864 ms->auth = g_strdup(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
865 ms->fd = proxy_connect(host, port, msn_ss_xfr_connect, ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
866 } else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
867 close(md->fd); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
868 gdk_input_remove(md->inpa); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
869 md->inpa = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
870 md->fd = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
871 md->fd = proxy_connect(host, port, msn_login_xfr_connect, gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
872 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
873 } else if (isdigit(*buf)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
874 handle_errcode(buf, TRUE); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
875 } else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
876 debug_printf("Unhandled message!\n"); |
1584 | 877 } |
878 } | |
879 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
880 static void msn_login_xfr_connect(gpointer data, gint source, GdkInputCondition cond) |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
881 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
882 struct gaim_connection *gc = data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
883 struct msn_data *md; |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
884 char buf[MSN_BUF_LEN]; |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
885 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
886 if (!g_slist_find(connections, gc)) |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
887 return; |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
888 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
889 md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
890 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
891 if (md->fd != source) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
892 md->fd = source; |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
893 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
894 if (md->fd == -1) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
895 hide_login_progress(gc, "Unable to connect to Notification Server"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
896 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
897 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
898 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
899 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
900 g_snprintf(buf, sizeof(buf), "USR %d MD5 I %s\n", ++md->trId, gc->username); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
901 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
902 hide_login_progress(gc, "Unable to talk to Notification Server"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
903 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
904 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
905 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
906 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
907 md->inpa = gdk_input_add(md->fd, GDK_INPUT_READ, msn_login_callback, gc); |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
908 } |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
909 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
910 static void msn_login_callback(gpointer data, gint source, GdkInputCondition cond) |
1567 | 911 { |
912 struct gaim_connection *gc = data; | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
913 struct msn_data *md = gc->proto_data; |
1567 | 914 char buf[MSN_BUF_LEN]; |
915 int i = 0; | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
916 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
917 bzero(buf, sizeof(buf)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
918 while ((read(md->fd, buf + i, 1) > 0) && (buf[i++] != '\n')) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
919 if (i == sizeof(buf)) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
920 i--; /* yes i know this loses data but we shouldn't get messages this long |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
921 and it's better than possibly writing past our buffer */ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
922 if (i == 0 || buf[i - 1] != '\n') { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
923 hide_login_progress(gc, "Error reading from server"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
924 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
925 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
926 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
927 debug_printf("S: %s", buf); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
928 g_strchomp(buf); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
929 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
930 if (!g_strncasecmp(buf, "VER", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
931 /* we got VER, check to see that MSNP2 is in the list, then send INF */ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
932 if (!strstr(buf, "MSNP2")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
933 hide_login_progress(gc, "Protocol not supported"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
934 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
935 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
936 } |
1259 | 937 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
938 g_snprintf(buf, sizeof(buf), "INF %d\n", ++md->trId); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
939 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
940 hide_login_progress(gc, "Unable to request INF\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
941 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
942 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
943 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
944 } else if (!g_strncasecmp(buf, "INF", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
945 /* check to make sure we can use md5 */ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
946 if (!strstr(buf, "MD5")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
947 hide_login_progress(gc, "Unable to login using MD5"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
948 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
949 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
950 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
951 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
952 g_snprintf(buf, sizeof(buf), "USR %d MD5 I %s\n", ++md->trId, gc->username); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
953 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
954 hide_login_progress(gc, "Unable to send USR\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
955 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
956 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
957 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
958 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
959 set_login_progress(gc, 3, "Requesting to send password"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
960 } else if (!g_strncasecmp(buf, "USR", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
961 /* so here, we're either getting the challenge or the OK */ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
962 if (strstr(buf, "OK")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
963 g_snprintf(buf, sizeof(buf), "SYN %d 0\n", ++md->trId); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
964 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
965 hide_login_progress(gc, "Unable to write"); |
1588 | 966 signoff(gc); |
1984
e90a0164436c
[gaim-migrate @ 1994]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1982
diff
changeset
|
967 return; |
1588 | 968 } |
969 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
970 g_snprintf(buf, sizeof(buf), "CHG %d NLN\n", ++md->trId); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
971 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
972 hide_login_progress(gc, "Unable to write"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
973 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
974 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
975 } |
1567 | 976 |
1987
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
977 g_snprintf(buf, sizeof(buf), "BLP %d AL\n", ++md->trId); |
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
978 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
979 hide_login_progress(gc, "Unable to write"); |
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
980 signoff(gc); |
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
981 return; |
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
982 } |
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
983 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
984 account_online(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
985 serv_finish_login(gc); |
1569 | 986 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
987 gdk_input_remove(md->inpa); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
988 md->inpa = gdk_input_add(md->fd, GDK_INPUT_READ, msn_callback, gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
989 } else if (strstr(buf, "MD5")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
990 char *challenge = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
991 char buf2[MSN_BUF_LEN]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
992 md5_state_t st; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
993 md5_byte_t di[16]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
994 int spaces = 4; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
995 int i; |
1569 | 996 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
997 while (spaces) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
998 if (isspace(*challenge)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
999 spaces--; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1000 while (isspace(challenge[1])) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1001 challenge++; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1002 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1003 challenge++; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1004 } |
1833 | 1005 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1006 g_snprintf(buf2, sizeof(buf2), "%s%s", challenge, gc->password); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1007 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1008 md5_init(&st); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1009 md5_append(&st, (const md5_byte_t *)buf2, strlen(buf2)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1010 md5_finish(&st, di); |
1833 | 1011 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1012 g_snprintf(buf, sizeof(buf), "USR %d MD5 S ", ++md->trId); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1013 for (i = 0; i < 16; i++) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1014 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1015 strcat(buf, buf2); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1016 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1017 strcat(buf, "\n"); |
1628 | 1018 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1019 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1020 hide_login_progress(gc, "Unable to send password"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1021 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1022 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1023 } |
1628 | 1024 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1025 set_login_progress(gc, 4, "Password sent"); |
1628 | 1026 } |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1027 } else if (!g_strncasecmp(buf, "XFR", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1028 char *host = strstr(buf, "NS"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1029 int port; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1030 int i = 0; |
1572 | 1031 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1032 if (!host) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1033 hide_login_progress(gc, "Got invalid XFR\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1034 signoff(gc); |
1572 | 1035 return; |
1036 } | |
1037 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1038 GET_NEXT(host); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1039 while (host[i] && host[i] != ':') i++; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1040 if (host[i] == ':') { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1041 char *x = &host[i + 1]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1042 host[i] = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1043 port = atoi(x); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1044 } else |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1045 port = 1863; |
1584 | 1046 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1047 close(md->fd); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1048 gdk_input_remove(md->inpa); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1049 md->inpa = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1050 md->fd = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1051 md->fd = proxy_connect(host, port, msn_login_xfr_connect, gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1052 } else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1053 if (isdigit(*buf)) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1054 hide_login_progress(gc, handle_errcode(buf, FALSE)); |
1628 | 1055 else |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1056 hide_login_progress(gc, "Unable to parse message"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1057 signoff(gc); |
1628 | 1058 return; |
1059 } | |
1259 | 1060 } |
1061 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1062 static void msn_login_connect(gpointer data, gint source, GdkInputCondition cond) |
1282 | 1063 { |
1567 | 1064 struct gaim_connection *gc = data; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1065 struct msn_data *md; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1066 char buf[1024]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1067 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1068 if (!g_slist_find(connections, gc)) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1069 return; |
1282 | 1070 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1071 md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1072 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1073 if (md->fd != source) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1074 md->fd = source; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1075 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1076 if (md->fd == -1) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1077 hide_login_progress(gc, "Unable to connect"); |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1078 signoff(gc); |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1079 return; |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1080 } |
1567 | 1081 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1082 g_snprintf(buf, sizeof(buf), "VER %d MSNP2\n", ++md->trId); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1083 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1084 hide_login_progress(gc, "Unable to write to server"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1085 signoff(gc); |
1567 | 1086 return; |
1087 } | |
1088 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1089 md->inpa = gdk_input_add(md->fd, GDK_INPUT_READ, msn_login_callback, gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1090 set_login_progress(gc, 2, "Synching with server"); |
1259 | 1091 } |
1092 | |
1891
1c977d995da9
[gaim-migrate @ 1901]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1881
diff
changeset
|
1093 static void msn_login(struct aim_user *user) |
1282 | 1094 { |
1567 | 1095 struct gaim_connection *gc = new_gaim_conn(user); |
1096 struct msn_data *md = gc->proto_data = g_new0(struct msn_data, 1); | |
1282 | 1097 |
1098 set_login_progress(gc, 1, "Connecting"); | |
1259 | 1099 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1100 g_snprintf(gc->username, sizeof(gc->username), "%s", msn_normalize(gc->username)); |
1567 | 1101 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1102 md->fd = proxy_connect("messenger.hotmail.com", 1863, msn_login_connect, gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1103 } |
1282 | 1104 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1105 static void msn_close(struct gaim_connection *gc) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1106 { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1107 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1108 close(md->fd); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1109 if (md->inpa) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1110 gdk_input_remove(md->inpa); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1111 while (md->switches) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1112 msn_kill_switch(md->switches->data); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1113 while (md->fl) { |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
1114 struct msn_buddy *tmp = md->fl->data; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1115 md->fl = g_slist_remove(md->fl, tmp); |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
1116 g_free(tmp->user); |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
1117 g_free(tmp->friend); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1118 g_free(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1119 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1120 g_free(md); |
1284 | 1121 } |
1122 | |
1891
1c977d995da9
[gaim-migrate @ 1901]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1881
diff
changeset
|
1123 static void msn_send_im(struct gaim_connection *gc, char *who, char *message, int away) |
1584 | 1124 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1125 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1126 struct msn_switchboard *ms = msn_find_switch(gc, who); |
1584 | 1127 char buf[MSN_BUF_LEN]; |
1128 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1129 if (ms) { |
2039
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2038
diff
changeset
|
1130 char *utf8 = str_to_utf8(message); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1131 g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s", ++ms->trId, |
2039
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2038
diff
changeset
|
1132 strlen(MIME_HEADER) + strlen(utf8), |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2038
diff
changeset
|
1133 MIME_HEADER, utf8); |
859e9c2c5813
[gaim-migrate @ 2049]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2038
diff
changeset
|
1134 g_free(utf8); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1135 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1136 msn_kill_switch(ms); |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1137 debug_printf("\n"); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1138 } else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1139 g_snprintf(buf, MSN_BUF_LEN, "XFR %d SB\n", ++md->trId); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1140 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1141 hide_login_progress(gc, "Write error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1142 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1143 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1144 } |
1584 | 1145 |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1146 ms = g_new0(struct msn_switchboard, 1); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1147 md->switches = g_slist_append(md->switches, ms); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1148 ms->user = g_strdup(who); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1149 ms->txqueue = g_strdup(message); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1150 ms->gc = gc; |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1151 ms->fd = -1; |
1585 | 1152 } |
1598 | 1153 } |
1154 | |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1155 static void msn_chat_send(struct gaim_connection *gc, int id, char *message) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1156 { |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1157 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1158 char buf[MSN_BUF_LEN]; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1159 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1160 if (!ms) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1161 return; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1162 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1163 g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s", ++ms->trId, |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1164 strlen(MIME_HEADER) + strlen(message), |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1165 MIME_HEADER, message); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1166 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1167 msn_kill_switch(ms); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1168 debug_printf("\n"); |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
1169 serv_got_chat_in(gc, id, gc->username, 0, message, time(NULL)); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1170 } |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1171 |
2024
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1172 static void msn_chat_invite(struct gaim_connection *gc, int id, char *msg, char *who) |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1173 { |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1174 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id); |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1175 char buf[MSN_BUF_LEN]; |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1176 |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1177 if (!ms) |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1178 return; |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1179 |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1180 g_snprintf(buf, sizeof(buf), "CAL %d %s\n", ++ms->trId, who); |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1181 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1182 msn_kill_switch(ms); |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1183 } |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1184 |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1185 static void msn_chat_leave(struct gaim_connection *gc, int id) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1186 { |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1187 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1188 char buf[MSN_BUF_LEN]; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1189 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1190 if (!ms) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1191 return; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1192 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1193 g_snprintf(buf, sizeof(buf), "OUT\n"); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1194 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1195 msn_kill_switch(ms); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1196 } |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1197 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1198 static GList *msn_away_states() |
1630 | 1199 { |
1200 GList *m = NULL; | |
1201 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1202 m = g_list_append(m, "Available"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1203 m = g_list_append(m, "Away From Computer"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1204 m = g_list_append(m, "Be Right Back"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1205 m = g_list_append(m, "Busy"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1206 m = g_list_append(m, "On The Phone"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1207 m = g_list_append(m, "Out To Lunch"); |
1630 | 1208 |
1209 return m; | |
1210 } | |
1211 | |
1600 | 1212 static void msn_set_away(struct gaim_connection *gc, char *state, char *msg) |
1213 { | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1214 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1215 char buf[MSN_BUF_LEN]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1216 char *away; |
1630 | 1217 |
1218 gc->away = NULL; | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1219 |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1220 if (msg) { |
1630 | 1221 gc->away = ""; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1222 away = "AWY"; |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1223 } else if (state) { |
1630 | 1224 gc->away = ""; |
1225 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1226 if (!strcmp(state, "Away From Computer")) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1227 away = "AWY"; |
1630 | 1228 else if (!strcmp(state, "Be Right Back")) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1229 away = "BRB"; |
1630 | 1230 else if (!strcmp(state, "Busy")) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1231 away = "BSY"; |
1630 | 1232 else if (!strcmp(state, "On The Phone")) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1233 away = "PHN"; |
1630 | 1234 else if (!strcmp(state, "Out To Lunch")) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1235 away = "LUN"; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1236 else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1237 gc->away = NULL; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1238 away = "NLN"; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1239 } |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1240 } else if (gc->is_idle) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1241 away = "IDL"; |
1600 | 1242 else |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1243 away = "NLN"; |
1600 | 1244 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1245 g_snprintf(buf, sizeof(buf), "CHG %d %s\n", ++md->trId, away); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1246 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1247 hide_login_progress(gc, "Write error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1248 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1249 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1250 } |
1600 | 1251 } |
1252 | |
1253 static void msn_set_idle(struct gaim_connection *gc, int idle) | |
1254 { | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1255 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1256 char buf[MSN_BUF_LEN]; |
1600 | 1257 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1258 if (gc->away) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1259 return; |
1600 | 1260 if (idle) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1261 g_snprintf(buf, sizeof(buf), "CHG %d IDL\n", ++md->trId); |
1600 | 1262 else |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1263 g_snprintf(buf, sizeof(buf), "CHG %d NLN\n", ++md->trId); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1264 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1265 hide_login_progress(gc, "Write error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1266 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1267 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1268 } |
1600 | 1269 } |
1270 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1271 static char **msn_list_icon(int uc) |
1600 | 1272 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1273 if (uc == UC_NORMAL) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1274 return msn_online_xpm; |
1600 | 1275 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1276 return msn_away_xpm; |
1600 | 1277 } |
1278 | |
1639 | 1279 static char *msn_get_away_text(int s) |
1280 { | |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1281 switch (s) { |
1639 | 1282 case MSN_BUSY : |
1283 return "Busy"; | |
1284 case MSN_BRB : | |
1285 return "Be right back"; | |
1286 case MSN_AWAY : | |
1287 return "Away from the computer"; | |
1288 case MSN_PHONE : | |
1289 return "On the phone"; | |
1290 case MSN_LUNCH : | |
1291 return "Out to lunch"; | |
1640 | 1292 case MSN_IDLE : |
1293 return "Idle"; | |
1639 | 1294 default: |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1295 return "Available"; |
1639 | 1296 } |
1297 } | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1298 |
1639 | 1299 static void msn_buddy_menu(GtkWidget *menu, struct gaim_connection *gc, char *who) |
1300 { | |
1301 struct buddy *b = find_buddy(gc, who); | |
1302 char buf[MSN_BUF_LEN]; | |
1303 GtkWidget *button; | |
1304 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1305 if (!b || !(b->uc >> 5)) |
1639 | 1306 return; |
1307 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1308 g_snprintf(buf, sizeof(buf), "Status: %s", msn_get_away_text(b->uc >> 5)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1309 |
1639 | 1310 button = gtk_menu_item_new_with_label(buf); |
1311 gtk_menu_append(GTK_MENU(menu), button); | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1312 gtk_widget_show(button); |
1639 | 1313 } |
1314 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1315 struct mod_usr_opt { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1316 struct aim_user *user; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1317 int opt; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1318 }; |
1717 | 1319 |
1320 static void mod_opt(GtkWidget *b, struct mod_usr_opt *m) | |
1321 { | |
1322 if (m->user) { | |
1323 if (m->user->proto_opt[m->opt][0] == '1') | |
1324 m->user->proto_opt[m->opt][0] = '\0'; | |
1325 else | |
1326 strcpy(m->user->proto_opt[m->opt],"1"); | |
1327 } | |
1328 } | |
1329 | |
1330 static void free_muo(GtkWidget *b, struct mod_usr_opt *m) | |
1331 { | |
1332 g_free(m); | |
1333 } | |
1334 | |
1335 static GtkWidget *msn_protoopt_button(const char *text, struct aim_user *u, int option, GtkWidget *box) | |
1336 { | |
1337 GtkWidget *button; | |
1338 struct mod_usr_opt *muo = g_new0(struct mod_usr_opt, 1); | |
1339 button = gtk_check_button_new_with_label(text); | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1340 if (u) |
1717 | 1341 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (u->proto_opt[option][0] == '1')); |
1342 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); | |
1343 muo->user = u; | |
1344 muo->opt = option; | |
1345 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(mod_opt), muo); | |
1346 gtk_signal_connect(GTK_OBJECT(button), "destroy", GTK_SIGNAL_FUNC(free_muo), muo); | |
1347 gtk_widget_show(button); | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1348 |
1717 | 1349 return button; |
1350 } | |
1351 | |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1352 static void msn_user_opts(GtkWidget* book, struct aim_user *user) |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1353 { |
1717 | 1354 GtkWidget *vbox; |
1355 | |
1356 vbox = gtk_vbox_new(FALSE, 5); | |
1357 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); | |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1358 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, gtk_label_new("MSN Options")); |
1717 | 1359 gtk_widget_show(vbox); |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1360 |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1361 msn_protoopt_button("Notify me of new HotMail",user,USEROPT_HOTMAIL,vbox); |
1717 | 1362 } |
1363 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1364 static void msn_add_buddy(struct gaim_connection *gc, char *who) |
1717 | 1365 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1366 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1367 char buf[MSN_BUF_LEN]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1368 GSList *l = md->fl; |
1717 | 1369 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1370 while (l) { |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
1371 struct msn_buddy *b = l->data; |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
1372 if (!g_strcasecmp(who, b->user)) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1373 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1374 l = l->next; |
1717 | 1375 } |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1376 if (l) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1377 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1378 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1379 g_snprintf(buf, sizeof(buf), "ADD %d FL %s %s\n", ++md->trId, who, who); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1380 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1381 hide_login_progress(gc, "Write error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1382 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1383 return; |
1717 | 1384 } |
1385 } | |
1386 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1387 static void msn_rem_buddy(struct gaim_connection *gc, char *who) |
1833 | 1388 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1389 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1390 char buf[MSN_BUF_LEN]; |
1833 | 1391 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1392 g_snprintf(buf, sizeof(buf), "REM %d FL %s\n", ++md->trId, who); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1393 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1394 hide_login_progress(gc, "Write error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1395 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1396 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1397 } |
1572 | 1398 } |
1399 | |
1259 | 1400 static struct prpl *my_protocol = NULL; |
1401 | |
1891
1c977d995da9
[gaim-migrate @ 1901]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1881
diff
changeset
|
1402 static void msn_init(struct prpl *ret) |
1282 | 1403 { |
1259 | 1404 ret->protocol = PROTO_MSN; |
1405 ret->name = msn_name; | |
1572 | 1406 ret->list_icon = msn_list_icon; |
1639 | 1407 ret->buddy_menu = msn_buddy_menu; |
1717 | 1408 ret->user_opts = msn_user_opts; |
1259 | 1409 ret->login = msn_login; |
1600 | 1410 ret->close = msn_close; |
1584 | 1411 ret->send_im = msn_send_im; |
1630 | 1412 ret->away_states = msn_away_states; |
1600 | 1413 ret->set_away = msn_set_away; |
1414 ret->set_idle = msn_set_idle; | |
1598 | 1415 ret->add_buddy = msn_add_buddy; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1416 ret->remove_buddy = msn_rem_buddy; |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1417 ret->chat_send = msn_chat_send; |
2024
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1418 ret->chat_invite = msn_chat_invite; |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1419 ret->chat_leave = msn_chat_leave; |
1756 | 1420 ret->normalize = msn_normalize; |
1259 | 1421 |
1422 my_protocol = ret; | |
1423 } | |
1424 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1425 char *gaim_plugin_init(GModule *handle) |
1282 | 1426 { |
1443
336fc98b7f90
[gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1327
diff
changeset
|
1427 load_protocol(msn_init, sizeof(struct prpl)); |
1259 | 1428 return NULL; |
1429 } | |
1430 | |
1282 | 1431 void gaim_plugin_remove() |
1432 { | |
1259 | 1433 struct prpl *p = find_prpl(PROTO_MSN); |
1434 if (p == my_protocol) | |
1435 unload_protocol(p); | |
1436 } |