Mercurial > pidgin
annotate plugins/msn/msn.c @ 2024:b86f639ff99f
[gaim-migrate @ 2034]
wee, invites. now i just have to make it so you can go from convo to chat on your own.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 16 Jun 2001 00:30:44 +0000 |
parents | 3ab2082d125f |
children | cb4fbcdae9eb |
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); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
381 } |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
382 } else if (!g_strncasecmp(buf, "CAL", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
383 } else if (!g_strncasecmp(buf, "IRO", 3)) { |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
384 char *tot, *user, *tmp = buf; |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
385 |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
386 GET_NEXT(tmp); |
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 tot = tmp; |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
390 GET_NEXT(tmp); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
391 ms->total = atoi(tot); |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
392 user = tmp; |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
393 GET_NEXT(tmp); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
394 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
395 if (ms->total > 1) { |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
396 if (!ms->chat) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
397 ms->chat = serv_got_joined_chat(gc, ++id, "MSN Chat"); |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
398 add_chat_buddy(ms->chat, user); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
399 } |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
400 } else if (!g_strncasecmp(buf, "JOI", 3)) { |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
401 char *user, *tmp = buf; |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
402 GET_NEXT(tmp); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
403 user = tmp; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
404 GET_NEXT(tmp); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
405 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
406 if (ms->total == 1) { |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
407 ms->chat = serv_got_joined_chat(gc, ++id, "MSN Chat"); |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
408 add_chat_buddy(ms->chat, ms->user); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
409 add_chat_buddy(ms->chat, gc->username); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
410 g_free(ms->user); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
411 ms->user = NULL; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
412 } |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
413 if (ms->chat) |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
414 add_chat_buddy(ms->chat, user); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
415 ms->total++; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
416 if (ms->txqueue) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
417 g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s", ++ms->trId, |
1988
2bb74a5a574f
[gaim-migrate @ 1998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1987
diff
changeset
|
418 strlen(MIME_HEADER) + strlen(ms->txqueue), |
2bb74a5a574f
[gaim-migrate @ 1998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1987
diff
changeset
|
419 MIME_HEADER, ms->txqueue); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
420 g_free(ms->txqueue); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
421 ms->txqueue = NULL; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
422 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
423 msn_kill_switch(ms); |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
424 debug_printf("\n"); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
425 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
426 } else if (!g_strncasecmp(buf, "MSG", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
427 char *user, *tmp = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
428 int length; |
1992
5121e706af6d
[gaim-migrate @ 2002]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1991
diff
changeset
|
429 char *msg, *content, *skiphead, *utf, *final; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
430 int len; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
431 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
432 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
433 user = tmp; |
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 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
437 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
438 length = atoi(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 msg = g_new0(char, MAX(length + 1, MSN_BUF_LEN)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
441 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
442 if (read(ms->fd, msg, length) != length) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
443 g_free(msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
444 hide_login_progress(gc, "Unable to read message"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
445 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
446 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
447 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
448 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
449 |
1992
5121e706af6d
[gaim-migrate @ 2002]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1991
diff
changeset
|
450 content = strstr(msg, "Content-Type: "); |
5121e706af6d
[gaim-migrate @ 2002]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1991
diff
changeset
|
451 if (content) { |
5121e706af6d
[gaim-migrate @ 2002]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1991
diff
changeset
|
452 if (g_strncasecmp(content, "Content-Type: text/plain", |
5121e706af6d
[gaim-migrate @ 2002]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1991
diff
changeset
|
453 strlen("Content-Type: text/plain"))) { |
5121e706af6d
[gaim-migrate @ 2002]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1991
diff
changeset
|
454 g_free(msg); |
5121e706af6d
[gaim-migrate @ 2002]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1991
diff
changeset
|
455 return; |
5121e706af6d
[gaim-migrate @ 2002]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1991
diff
changeset
|
456 } |
5121e706af6d
[gaim-migrate @ 2002]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1991
diff
changeset
|
457 } |
5121e706af6d
[gaim-migrate @ 2002]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1991
diff
changeset
|
458 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
459 skiphead = strstr(msg, "\r\n\r\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
460 if (!skiphead || !skiphead[4]) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
461 g_free(msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
462 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
463 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
464 skiphead += 4; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
465 utf = utf8_to_str(skiphead); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
466 len = MAX(strlen(utf) + 1, BUF_LEN); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
467 final = g_malloc(len); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
468 g_snprintf(final, len, "%s", utf); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
469 g_free(utf); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
470 |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
471 if (ms->chat) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
472 serv_got_chat_in(gc, ms->chat->id, user, 0, final, time(NULL)); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
473 else |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
474 serv_got_im(gc, user, final, 0, time(NULL)); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
475 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
476 g_free(final); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
477 g_free(msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
478 } else if (!g_strncasecmp(buf, "NAK", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
479 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
|
480 } else if (!g_strncasecmp(buf, "NLN", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
481 } else if (!g_strncasecmp(buf, "OUT", 3)) { |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
482 if (ms->chat) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
483 serv_got_chat_left(gc, ms->chat->id); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
484 msn_kill_switch(ms); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
485 } else if (!g_strncasecmp(buf, "USR", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
486 /* 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
|
487 struct msn_switchboard *ms = msn_find_writable_switch(gc); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
488 |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
489 if (!ms) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
490 return; |
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 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
|
493 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
494 msn_kill_switch(ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
495 } else if (isdigit(*buf)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
496 handle_errcode(buf, TRUE); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
497 } else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
498 debug_printf("Unhandled message!\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
499 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
500 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
501 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
502 static void msn_rng_connect(gpointer data, gint source, GdkInputCondition cond) |
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 struct msn_switchboard *ms = data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
505 struct gaim_connection *gc = ms->gc; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
506 struct msn_data *md; |
1572 | 507 char buf[MSN_BUF_LEN]; |
508 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
509 if (source == -1 || !g_slist_find(connections, gc)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
510 g_free(ms->sessid); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
511 g_free(ms->auth); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
512 g_free(ms); |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
513 return; |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
514 } |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
515 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
516 md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
517 |
2015
0d11fd498068
[gaim-migrate @ 2025]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2014
diff
changeset
|
518 if (ms->fd != source) |
0d11fd498068
[gaim-migrate @ 2025]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2014
diff
changeset
|
519 ms->fd = source; |
1572 | 520 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
521 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
|
522 if (msn_write(ms->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
523 close(ms->fd); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
524 g_free(ms->sessid); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
525 g_free(ms->auth); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
526 g_free(ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
527 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
528 } |
1572 | 529 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
530 md->switches = g_slist_append(md->switches, ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
531 ms->inpa = gdk_input_add(ms->fd, GDK_INPUT_READ, msn_switchboard_callback, ms); |
1572 | 532 } |
533 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
534 static void msn_ss_xfr_connect(gpointer data, gint source, GdkInputCondition cond) |
1584 | 535 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
536 struct msn_switchboard *ms = data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
537 struct gaim_connection *gc = ms->gc; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
538 char buf[MSN_BUF_LEN]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
539 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
540 if (source == -1 || !g_slist_find(connections, gc)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
541 g_free(ms->auth); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
542 g_free(ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
543 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
544 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
545 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
546 if (ms->fd != source) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
547 ms->fd = source; |
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 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
|
550 if (msn_write(ms->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
551 g_free(ms->auth); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
552 g_free(ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
553 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
554 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
555 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
556 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
|
557 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
558 |
1986
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
559 struct msn_add_permit { |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
560 struct gaim_connection *gc; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
561 char *user; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
562 char *friend; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
563 }; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
564 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
565 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
|
566 { |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
567 struct msn_data *md = map->gc->proto_data; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
568 char buf[MSN_BUF_LEN]; |
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 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
|
571 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
572 hide_login_progress(map->gc, "Write error"); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
573 signoff(map->gc); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
574 return; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
575 } |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
576 } |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
577 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
578 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
|
579 { |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
580 g_free(map->user); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
581 g_free(map->friend); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
582 g_free(map); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
583 } |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
584 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
585 static void msn_callback(gpointer data, gint source, GdkInputCondition cond) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
586 { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
587 struct gaim_connection *gc = data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
588 struct msn_data *md = gc->proto_data; |
1584 | 589 char buf[MSN_BUF_LEN]; |
590 int i = 0; | |
591 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
592 bzero(buf, sizeof(buf)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
593 while ((read(md->fd, buf + i, 1) > 0) && (buf[i++] != '\n')) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
594 if (i == sizeof(buf)) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
595 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
|
596 and it's better than possibly writing past our buffer */ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
597 if (i == 0 || buf[i - 1] != '\n') { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
598 hide_login_progress(gc, "Error reading from server"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
599 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
600 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
601 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
602 debug_printf("S: %s", buf); |
1584 | 603 g_strchomp(buf); |
604 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
605 if (!g_strncasecmp(buf, "ADD", 3)) { |
1986
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
606 char *list, *user, *friend, *tmp = buf; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
607 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
|
608 char msg[MSN_BUF_LEN]; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
609 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
610 GET_NEXT(tmp); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
611 GET_NEXT(tmp); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
612 list = tmp; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
613 |
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 GET_NEXT(tmp); |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
616 user = tmp; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
617 |
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 friend = 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 if (g_strcasecmp(list, "RL")) |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
622 return; |
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 ap->user = g_strdup(user); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
625 ap->friend = g_strdup(friend); |
1986
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
626 ap->gc = gc; |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
627 |
00ef734e92e1
[gaim-migrate @ 1996]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1985
diff
changeset
|
628 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
|
629 ap->user, url_decode(ap->friend)); |
1986
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 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
|
632 } else if (!g_strncasecmp(buf, "BLP", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
633 } else if (!g_strncasecmp(buf, "BPR", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
634 } else if (!g_strncasecmp(buf, "CHG", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
635 } else if (!g_strncasecmp(buf, "FLN", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
636 char *usr = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
637 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
638 GET_NEXT(usr); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
639 serv_got_update(gc, usr, 0, 0, 0, 0, 0, 0); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
640 } else if (!g_strncasecmp(buf, "GTC", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
641 } else if (!g_strncasecmp(buf, "INF", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
642 } else if (!g_strncasecmp(buf, "ILN", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
643 char *state, *user, *tmp = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
644 int status = UC_NORMAL; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
645 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
646 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
647 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
648 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
649 state = tmp; |
1584 | 650 |
1985
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 user = tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
653 |
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 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
656 if (!g_strcasecmp(state, "BSY")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
657 status |= (MSN_BUSY << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
658 } else if (!g_strcasecmp(state, "IDL")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
659 status |= (MSN_IDLE << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
660 } else if (!g_strcasecmp(state, "BRB")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
661 status |= (MSN_BRB << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
662 } else if (!g_strcasecmp(state, "AWY")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
663 status = UC_UNAVAILABLE; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
664 } else if (!g_strcasecmp(state, "PHN")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
665 status |= (MSN_PHONE << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
666 } else if (!g_strcasecmp(state, "LUN")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
667 status |= (MSN_LUNCH << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
668 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
669 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
670 serv_got_update(gc, user, 1, 0, 0, 0, status, 0); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
671 } else if (!g_strncasecmp(buf, "LST", 3)) { |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
672 char *which, *who, *friend, *tmp = buf; |
1584 | 673 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
674 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
675 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
676 which = tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
677 |
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 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
680 GET_NEXT(tmp); |
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 who = tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
683 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
684 GET_NEXT(tmp); |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
685 friend = url_decode(tmp); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
686 |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
687 if (!g_strcasecmp(which, "FL")) { |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
688 struct msn_buddy *b = g_new0(struct msn_buddy, 1); |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
689 b->user = g_strdup(who); |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
690 b->friend = g_strdup(friend); |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
691 md->fl = g_slist_append(md->fl, b); |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
692 } else if (!md->imported) { |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
693 if (bud_list_cache_exists(gc)) |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
694 do_import(NULL, gc); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
695 md->imported = TRUE; |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
696 while (md->fl) { |
1994
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
697 struct msn_buddy *mb = md->fl->data; |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
698 struct buddy *b; |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
699 md->fl = g_slist_remove(md->fl, mb); |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
700 if (!(b = find_buddy(gc, mb->user))) |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
701 add_buddy(gc, "Buddies", mb->user, mb->friend); |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
702 else if (!g_strcasecmp(b->name, b->show)) { |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
703 g_snprintf(b->show, sizeof(b->show), "%s", mb->friend); |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
704 handle_buddy_rename(b, b->name); |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
705 } |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
706 g_free(mb->user); |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
707 g_free(mb->friend); |
0c8073b877d2
[gaim-migrate @ 2004]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1993
diff
changeset
|
708 g_free(mb); |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
709 } |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
710 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
711 } else if (!g_strncasecmp(buf, "MSG", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
712 char *user, *tmp = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
713 int length; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
714 char *msg, *skiphead, *utf, *final; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
715 int len; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
716 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
717 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
718 user = tmp; |
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 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
722 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
723 length = atoi(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 msg = g_new0(char, MAX(length + 1, MSN_BUF_LEN)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
726 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
727 if (read(md->fd, msg, length) != length) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
728 g_free(msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
729 hide_login_progress(gc, "Unable to read message"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
730 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
731 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
732 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
733 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
734 if (!g_strcasecmp(user, "hotmail")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
735 handle_hotmail(gc, msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
736 g_free(msg); |
1584 | 737 return; |
738 } | |
739 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
740 skiphead = strstr(msg, "\r\n\r\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
741 if (!skiphead || !skiphead[4]) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
742 g_free(msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
743 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
744 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
745 skiphead += 4; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
746 utf = utf8_to_str(skiphead); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
747 len = MAX(strlen(utf) + 1, BUF_LEN); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
748 final = g_malloc(len); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
749 g_snprintf(final, len, "%s", utf); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
750 g_free(utf); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
751 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
752 serv_got_im(gc, user, final, 0, time(NULL)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
753 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
754 g_free(final); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
755 g_free(msg); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
756 } else if (!g_strncasecmp(buf, "NLN", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
757 char *state, *user, *tmp = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
758 int status = UC_NORMAL; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
759 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
760 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
761 state = tmp; |
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 user = 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 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
768 if (!g_strcasecmp(state, "BSY")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
769 status |= (MSN_BUSY << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
770 } else if (!g_strcasecmp(state, "IDL")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
771 status |= (MSN_IDLE << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
772 } else if (!g_strcasecmp(state, "BRB")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
773 status |= (MSN_BRB << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
774 } else if (!g_strcasecmp(state, "AWY")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
775 status = UC_UNAVAILABLE; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
776 } else if (!g_strcasecmp(state, "PHN")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
777 status |= (MSN_PHONE << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
778 } else if (!g_strcasecmp(state, "LUN")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
779 status |= (MSN_LUNCH << 5); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
780 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
781 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
782 serv_got_update(gc, user, 1, 0, 0, 0, status, 0); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
783 } else if (!g_strncasecmp(buf, "OUT", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
784 } else if (!g_strncasecmp(buf, "PRP", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
785 } else if (!g_strncasecmp(buf, "REM", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
786 } else if (!g_strncasecmp(buf, "RNG", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
787 struct msn_switchboard *ms; |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
788 char *sessid, *ssaddr, *auth, *user; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
789 int port, i = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
790 char *tmp = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
791 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
792 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
793 sessid = tmp; |
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 ssaddr = 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 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
800 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
801 auth = 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); |
1989
21c595ef11c8
[gaim-migrate @ 1999]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1988
diff
changeset
|
804 user = tmp; |
21c595ef11c8
[gaim-migrate @ 1999]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1988
diff
changeset
|
805 GET_NEXT(tmp); |
1584 | 806 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
807 while (ssaddr[i] && ssaddr[i] != ':') i++; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
808 if (ssaddr[i] == ':') { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
809 char *x = &ssaddr[i + 1]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
810 ssaddr[i] = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
811 port = atoi(x); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
812 } else |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
813 port = 1863; |
1584 | 814 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
815 ms = g_new0(struct msn_switchboard, 1); |
1989
21c595ef11c8
[gaim-migrate @ 1999]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1988
diff
changeset
|
816 ms->user = g_strdup(user); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
817 ms->sessid = g_strdup(sessid); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
818 ms->auth = g_strdup(auth); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
819 ms->gc = gc; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
820 ms->fd = proxy_connect(ssaddr, port, msn_rng_connect, ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
821 } else if (!g_strncasecmp(buf, "SYN", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
822 } else if (!g_strncasecmp(buf, "USR", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
823 } else if (!g_strncasecmp(buf, "XFR", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
824 char *host = strstr(buf, "SB"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
825 int port; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
826 int i = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
827 gboolean switchboard = TRUE; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
828 char *tmp; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
829 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
830 if (!host) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
831 host = strstr(buf, "NS"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
832 if (!host) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
833 hide_login_progress(gc, "Got invalid XFR\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
834 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
835 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
836 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
837 switchboard = FALSE; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
838 } |
1584 | 839 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
840 GET_NEXT(host); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
841 while (host[i] && host[i] != ':') i++; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
842 if (host[i] == ':') { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
843 tmp = &host[i + 1]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
844 host[i] = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
845 while (isdigit(*tmp)) tmp++; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
846 *tmp++ = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
847 port = atoi(&host[i + 1]); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
848 } else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
849 port = 1863; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
850 tmp = host; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
851 GET_NEXT(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
852 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
853 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
854 if (switchboard) { |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
855 struct msn_switchboard *ms = msn_find_writable_switch(gc); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
856 if (!ms) |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
857 return; |
1584 | 858 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
859 GET_NEXT(tmp); |
1584 | 860 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
861 ms->auth = g_strdup(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
862 ms->fd = proxy_connect(host, port, msn_ss_xfr_connect, ms); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
863 } else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
864 close(md->fd); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
865 gdk_input_remove(md->inpa); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
866 md->inpa = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
867 md->fd = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
868 md->fd = proxy_connect(host, port, msn_login_xfr_connect, gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
869 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
870 } else if (isdigit(*buf)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
871 handle_errcode(buf, TRUE); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
872 } else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
873 debug_printf("Unhandled message!\n"); |
1584 | 874 } |
875 } | |
876 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
877 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
|
878 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
879 struct gaim_connection *gc = data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
880 struct msn_data *md; |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
881 char buf[MSN_BUF_LEN]; |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
882 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
883 if (!g_slist_find(connections, gc)) |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
884 return; |
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 md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
887 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
888 if (md->fd != source) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
889 md->fd = source; |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
890 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
891 if (md->fd == -1) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
892 hide_login_progress(gc, "Unable to connect to Notification Server"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
893 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
894 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
895 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
896 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
897 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
|
898 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
899 hide_login_progress(gc, "Unable to talk to Notification Server"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
900 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
901 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
902 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
903 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
904 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
|
905 } |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
906 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
907 static void msn_login_callback(gpointer data, gint source, GdkInputCondition cond) |
1567 | 908 { |
909 struct gaim_connection *gc = data; | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
910 struct msn_data *md = gc->proto_data; |
1567 | 911 char buf[MSN_BUF_LEN]; |
912 int i = 0; | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
913 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
914 bzero(buf, sizeof(buf)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
915 while ((read(md->fd, buf + i, 1) > 0) && (buf[i++] != '\n')) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
916 if (i == sizeof(buf)) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
917 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
|
918 and it's better than possibly writing past our buffer */ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
919 if (i == 0 || buf[i - 1] != '\n') { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
920 hide_login_progress(gc, "Error reading from server"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
921 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
922 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
923 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
924 debug_printf("S: %s", buf); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
925 g_strchomp(buf); |
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 if (!g_strncasecmp(buf, "VER", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
928 /* 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
|
929 if (!strstr(buf, "MSNP2")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
930 hide_login_progress(gc, "Protocol not supported"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
931 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
932 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
933 } |
1259 | 934 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
935 g_snprintf(buf, sizeof(buf), "INF %d\n", ++md->trId); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
936 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
937 hide_login_progress(gc, "Unable to request INF\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
938 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
939 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
940 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
941 } else if (!g_strncasecmp(buf, "INF", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
942 /* check to make sure we can use md5 */ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
943 if (!strstr(buf, "MD5")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
944 hide_login_progress(gc, "Unable to login using MD5"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
945 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
946 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
947 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
948 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
949 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
|
950 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
951 hide_login_progress(gc, "Unable to send USR\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
952 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
953 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
954 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
955 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
956 set_login_progress(gc, 3, "Requesting to send password"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
957 } else if (!g_strncasecmp(buf, "USR", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
958 /* so here, we're either getting the challenge or the OK */ |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
959 if (strstr(buf, "OK")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
960 g_snprintf(buf, sizeof(buf), "SYN %d 0\n", ++md->trId); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
961 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
962 hide_login_progress(gc, "Unable to write"); |
1588 | 963 signoff(gc); |
1984
e90a0164436c
[gaim-migrate @ 1994]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1982
diff
changeset
|
964 return; |
1588 | 965 } |
966 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
967 g_snprintf(buf, sizeof(buf), "CHG %d NLN\n", ++md->trId); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
968 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
969 hide_login_progress(gc, "Unable to write"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
970 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
971 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
972 } |
1567 | 973 |
1987
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
974 g_snprintf(buf, sizeof(buf), "BLP %d AL\n", ++md->trId); |
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
975 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
976 hide_login_progress(gc, "Unable to write"); |
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
977 signoff(gc); |
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
978 return; |
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
979 } |
a47327740514
[gaim-migrate @ 1997]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1986
diff
changeset
|
980 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
981 account_online(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
982 serv_finish_login(gc); |
1569 | 983 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
984 gdk_input_remove(md->inpa); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
985 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
|
986 } else if (strstr(buf, "MD5")) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
987 char *challenge = buf; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
988 char buf2[MSN_BUF_LEN]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
989 md5_state_t st; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
990 md5_byte_t di[16]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
991 int spaces = 4; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
992 int i; |
1569 | 993 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
994 while (spaces) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
995 if (isspace(*challenge)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
996 spaces--; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
997 while (isspace(challenge[1])) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
998 challenge++; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
999 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1000 challenge++; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1001 } |
1833 | 1002 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1003 g_snprintf(buf2, sizeof(buf2), "%s%s", challenge, gc->password); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1004 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1005 md5_init(&st); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1006 md5_append(&st, (const md5_byte_t *)buf2, strlen(buf2)); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1007 md5_finish(&st, di); |
1833 | 1008 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1009 g_snprintf(buf, sizeof(buf), "USR %d MD5 S ", ++md->trId); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1010 for (i = 0; i < 16; i++) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1011 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1012 strcat(buf, buf2); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1013 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1014 strcat(buf, "\n"); |
1628 | 1015 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1016 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1017 hide_login_progress(gc, "Unable to send password"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1018 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1019 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1020 } |
1628 | 1021 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1022 set_login_progress(gc, 4, "Password sent"); |
1628 | 1023 } |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1024 } else if (!g_strncasecmp(buf, "XFR", 3)) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1025 char *host = strstr(buf, "NS"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1026 int port; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1027 int i = 0; |
1572 | 1028 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1029 if (!host) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1030 hide_login_progress(gc, "Got invalid XFR\n"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1031 signoff(gc); |
1572 | 1032 return; |
1033 } | |
1034 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1035 GET_NEXT(host); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1036 while (host[i] && host[i] != ':') i++; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1037 if (host[i] == ':') { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1038 char *x = &host[i + 1]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1039 host[i] = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1040 port = atoi(x); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1041 } else |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1042 port = 1863; |
1584 | 1043 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1044 close(md->fd); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1045 gdk_input_remove(md->inpa); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1046 md->inpa = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1047 md->fd = 0; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1048 md->fd = proxy_connect(host, port, msn_login_xfr_connect, gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1049 } else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1050 if (isdigit(*buf)) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1051 hide_login_progress(gc, handle_errcode(buf, FALSE)); |
1628 | 1052 else |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1053 hide_login_progress(gc, "Unable to parse message"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1054 signoff(gc); |
1628 | 1055 return; |
1056 } | |
1259 | 1057 } |
1058 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1059 static void msn_login_connect(gpointer data, gint source, GdkInputCondition cond) |
1282 | 1060 { |
1567 | 1061 struct gaim_connection *gc = data; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1062 struct msn_data *md; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1063 char buf[1024]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1064 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1065 if (!g_slist_find(connections, gc)) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1066 return; |
1282 | 1067 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1068 md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1069 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1070 if (md->fd != source) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1071 md->fd = source; |
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 == -1) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1074 hide_login_progress(gc, "Unable to connect"); |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1075 signoff(gc); |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1076 return; |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1077 } |
1567 | 1078 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1079 g_snprintf(buf, sizeof(buf), "VER %d MSNP2\n", ++md->trId); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1080 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1081 hide_login_progress(gc, "Unable to write to server"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1082 signoff(gc); |
1567 | 1083 return; |
1084 } | |
1085 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1086 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
|
1087 set_login_progress(gc, 2, "Synching with server"); |
1259 | 1088 } |
1089 | |
1891
1c977d995da9
[gaim-migrate @ 1901]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1881
diff
changeset
|
1090 static void msn_login(struct aim_user *user) |
1282 | 1091 { |
1567 | 1092 struct gaim_connection *gc = new_gaim_conn(user); |
1093 struct msn_data *md = gc->proto_data = g_new0(struct msn_data, 1); | |
1282 | 1094 |
1095 set_login_progress(gc, 1, "Connecting"); | |
1259 | 1096 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1097 g_snprintf(gc->username, sizeof(gc->username), "%s", msn_normalize(gc->username)); |
1567 | 1098 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1099 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
|
1100 } |
1282 | 1101 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1102 static void msn_close(struct gaim_connection *gc) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1103 { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1104 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1105 close(md->fd); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1106 if (md->inpa) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1107 gdk_input_remove(md->inpa); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1108 while (md->switches) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1109 msn_kill_switch(md->switches->data); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1110 while (md->fl) { |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
1111 struct msn_buddy *tmp = md->fl->data; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1112 md->fl = g_slist_remove(md->fl, tmp); |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
1113 g_free(tmp->user); |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
1114 g_free(tmp->friend); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1115 g_free(tmp); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1116 } |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1117 g_free(md); |
1284 | 1118 } |
1119 | |
1891
1c977d995da9
[gaim-migrate @ 1901]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1881
diff
changeset
|
1120 static void msn_send_im(struct gaim_connection *gc, char *who, char *message, int away) |
1584 | 1121 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1122 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1123 struct msn_switchboard *ms = msn_find_switch(gc, who); |
1584 | 1124 char buf[MSN_BUF_LEN]; |
1125 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1126 if (ms) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1127 g_snprintf(buf, sizeof(buf), "MSG %d N %d\r\n%s%s", ++ms->trId, |
1988
2bb74a5a574f
[gaim-migrate @ 1998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1987
diff
changeset
|
1128 strlen(MIME_HEADER) + strlen(message), |
2bb74a5a574f
[gaim-migrate @ 1998]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1987
diff
changeset
|
1129 MIME_HEADER, message); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1130 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1131 msn_kill_switch(ms); |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1132 debug_printf("\n"); |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1133 } else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1134 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
|
1135 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1136 hide_login_progress(gc, "Write error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1137 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1138 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1139 } |
1584 | 1140 |
2014
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1141 ms = g_new0(struct msn_switchboard, 1); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1142 md->switches = g_slist_append(md->switches, ms); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1143 ms->user = g_strdup(who); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1144 ms->txqueue = g_strdup(message); |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1145 ms->gc = gc; |
162f749ee5e7
[gaim-migrate @ 2024]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1994
diff
changeset
|
1146 ms->fd = -1; |
1585 | 1147 } |
1598 | 1148 } |
1149 | |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1150 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
|
1151 { |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1152 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1153 char buf[MSN_BUF_LEN]; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1154 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1155 if (!ms) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1156 return; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1157 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1158 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
|
1159 strlen(MIME_HEADER) + strlen(message), |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1160 MIME_HEADER, message); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1161 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1162 msn_kill_switch(ms); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1163 debug_printf("\n"); |
2023
3ab2082d125f
[gaim-migrate @ 2033]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2021
diff
changeset
|
1164 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
|
1165 } |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1166 |
2024
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1167 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
|
1168 { |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1169 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id); |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1170 char buf[MSN_BUF_LEN]; |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1171 |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1172 if (!ms) |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1173 return; |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1174 |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1175 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
|
1176 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1177 msn_kill_switch(ms); |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1178 } |
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1179 |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1180 static void msn_chat_leave(struct gaim_connection *gc, int id) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1181 { |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1182 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1183 char buf[MSN_BUF_LEN]; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1184 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1185 if (!ms) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1186 return; |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1187 |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1188 g_snprintf(buf, sizeof(buf), "OUT\n"); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1189 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1190 msn_kill_switch(ms); |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1191 } |
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1192 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1193 static GList *msn_away_states() |
1630 | 1194 { |
1195 GList *m = NULL; | |
1196 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1197 m = g_list_append(m, "Available"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1198 m = g_list_append(m, "Away From Computer"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1199 m = g_list_append(m, "Be Right Back"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1200 m = g_list_append(m, "Busy"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1201 m = g_list_append(m, "On The Phone"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1202 m = g_list_append(m, "Out To Lunch"); |
1630 | 1203 |
1204 return m; | |
1205 } | |
1206 | |
1600 | 1207 static void msn_set_away(struct gaim_connection *gc, char *state, char *msg) |
1208 { | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1209 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1210 char buf[MSN_BUF_LEN]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1211 char *away; |
1630 | 1212 |
1213 gc->away = NULL; | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1214 |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1215 if (msg) { |
1630 | 1216 gc->away = ""; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1217 away = "AWY"; |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1218 } else if (state) { |
1630 | 1219 gc->away = ""; |
1220 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1221 if (!strcmp(state, "Away From Computer")) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1222 away = "AWY"; |
1630 | 1223 else if (!strcmp(state, "Be Right Back")) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1224 away = "BRB"; |
1630 | 1225 else if (!strcmp(state, "Busy")) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1226 away = "BSY"; |
1630 | 1227 else if (!strcmp(state, "On The Phone")) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1228 away = "PHN"; |
1630 | 1229 else if (!strcmp(state, "Out To Lunch")) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1230 away = "LUN"; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1231 else { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1232 gc->away = NULL; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1233 away = "NLN"; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1234 } |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1235 } else if (gc->is_idle) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1236 away = "IDL"; |
1600 | 1237 else |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1238 away = "NLN"; |
1600 | 1239 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1240 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
|
1241 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1242 hide_login_progress(gc, "Write error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1243 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1244 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1245 } |
1600 | 1246 } |
1247 | |
1248 static void msn_set_idle(struct gaim_connection *gc, int idle) | |
1249 { | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1250 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1251 char buf[MSN_BUF_LEN]; |
1600 | 1252 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1253 if (gc->away) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1254 return; |
1600 | 1255 if (idle) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1256 g_snprintf(buf, sizeof(buf), "CHG %d IDL\n", ++md->trId); |
1600 | 1257 else |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1258 g_snprintf(buf, sizeof(buf), "CHG %d NLN\n", ++md->trId); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1259 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1260 hide_login_progress(gc, "Write error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1261 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1262 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1263 } |
1600 | 1264 } |
1265 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1266 static char **msn_list_icon(int uc) |
1600 | 1267 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1268 if (uc == UC_NORMAL) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1269 return msn_online_xpm; |
1600 | 1270 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1271 return msn_away_xpm; |
1600 | 1272 } |
1273 | |
1639 | 1274 static char *msn_get_away_text(int s) |
1275 { | |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1276 switch (s) { |
1639 | 1277 case MSN_BUSY : |
1278 return "Busy"; | |
1279 case MSN_BRB : | |
1280 return "Be right back"; | |
1281 case MSN_AWAY : | |
1282 return "Away from the computer"; | |
1283 case MSN_PHONE : | |
1284 return "On the phone"; | |
1285 case MSN_LUNCH : | |
1286 return "Out to lunch"; | |
1640 | 1287 case MSN_IDLE : |
1288 return "Idle"; | |
1639 | 1289 default: |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1290 return "Available"; |
1639 | 1291 } |
1292 } | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1293 |
1639 | 1294 static void msn_buddy_menu(GtkWidget *menu, struct gaim_connection *gc, char *who) |
1295 { | |
1296 struct buddy *b = find_buddy(gc, who); | |
1297 char buf[MSN_BUF_LEN]; | |
1298 GtkWidget *button; | |
1299 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1300 if (!b || !(b->uc >> 5)) |
1639 | 1301 return; |
1302 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1303 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
|
1304 |
1639 | 1305 button = gtk_menu_item_new_with_label(buf); |
1306 gtk_menu_append(GTK_MENU(menu), button); | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1307 gtk_widget_show(button); |
1639 | 1308 } |
1309 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1310 struct mod_usr_opt { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1311 struct aim_user *user; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1312 int opt; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1313 }; |
1717 | 1314 |
1315 static void mod_opt(GtkWidget *b, struct mod_usr_opt *m) | |
1316 { | |
1317 if (m->user) { | |
1318 if (m->user->proto_opt[m->opt][0] == '1') | |
1319 m->user->proto_opt[m->opt][0] = '\0'; | |
1320 else | |
1321 strcpy(m->user->proto_opt[m->opt],"1"); | |
1322 } | |
1323 } | |
1324 | |
1325 static void free_muo(GtkWidget *b, struct mod_usr_opt *m) | |
1326 { | |
1327 g_free(m); | |
1328 } | |
1329 | |
1330 static GtkWidget *msn_protoopt_button(const char *text, struct aim_user *u, int option, GtkWidget *box) | |
1331 { | |
1332 GtkWidget *button; | |
1333 struct mod_usr_opt *muo = g_new0(struct mod_usr_opt, 1); | |
1334 button = gtk_check_button_new_with_label(text); | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1335 if (u) |
1717 | 1336 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (u->proto_opt[option][0] == '1')); |
1337 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); | |
1338 muo->user = u; | |
1339 muo->opt = option; | |
1340 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(mod_opt), muo); | |
1341 gtk_signal_connect(GTK_OBJECT(button), "destroy", GTK_SIGNAL_FUNC(free_muo), muo); | |
1342 gtk_widget_show(button); | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1343 |
1717 | 1344 return button; |
1345 } | |
1346 | |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1347 static void msn_user_opts(GtkWidget* book, struct aim_user *user) |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1348 { |
1717 | 1349 GtkWidget *vbox; |
1350 | |
1351 vbox = gtk_vbox_new(FALSE, 5); | |
1352 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); | |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1353 gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox, gtk_label_new("MSN Options")); |
1717 | 1354 gtk_widget_show(vbox); |
1851
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1355 |
97a097e00139
[gaim-migrate @ 1861]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1833
diff
changeset
|
1356 msn_protoopt_button("Notify me of new HotMail",user,USEROPT_HOTMAIL,vbox); |
1717 | 1357 } |
1358 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1359 static void msn_add_buddy(struct gaim_connection *gc, char *who) |
1717 | 1360 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1361 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1362 char buf[MSN_BUF_LEN]; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1363 GSList *l = md->fl; |
1717 | 1364 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1365 while (l) { |
1991
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
1366 struct msn_buddy *b = l->data; |
308bd76c57db
[gaim-migrate @ 2001]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1990
diff
changeset
|
1367 if (!g_strcasecmp(who, b->user)) |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1368 break; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1369 l = l->next; |
1717 | 1370 } |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1371 if (l) |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1372 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1373 |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1374 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
|
1375 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1376 hide_login_progress(gc, "Write error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1377 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1378 return; |
1717 | 1379 } |
1380 } | |
1381 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1382 static void msn_rem_buddy(struct gaim_connection *gc, char *who) |
1833 | 1383 { |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1384 struct msn_data *md = gc->proto_data; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1385 char buf[MSN_BUF_LEN]; |
1833 | 1386 |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1387 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
|
1388 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1389 hide_login_progress(gc, "Write error"); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1390 signoff(gc); |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1391 return; |
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1392 } |
1572 | 1393 } |
1394 | |
1259 | 1395 static struct prpl *my_protocol = NULL; |
1396 | |
1891
1c977d995da9
[gaim-migrate @ 1901]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1881
diff
changeset
|
1397 static void msn_init(struct prpl *ret) |
1282 | 1398 { |
1259 | 1399 ret->protocol = PROTO_MSN; |
1400 ret->name = msn_name; | |
1572 | 1401 ret->list_icon = msn_list_icon; |
1639 | 1402 ret->buddy_menu = msn_buddy_menu; |
1717 | 1403 ret->user_opts = msn_user_opts; |
1259 | 1404 ret->login = msn_login; |
1600 | 1405 ret->close = msn_close; |
1584 | 1406 ret->send_im = msn_send_im; |
1630 | 1407 ret->away_states = msn_away_states; |
1600 | 1408 ret->set_away = msn_set_away; |
1409 ret->set_idle = msn_set_idle; | |
1598 | 1410 ret->add_buddy = msn_add_buddy; |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1411 ret->remove_buddy = msn_rem_buddy; |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1412 ret->chat_send = msn_chat_send; |
2024
b86f639ff99f
[gaim-migrate @ 2034]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2023
diff
changeset
|
1413 ret->chat_invite = msn_chat_invite; |
2021
d94c82b32b06
[gaim-migrate @ 2031]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2015
diff
changeset
|
1414 ret->chat_leave = msn_chat_leave; |
1756 | 1415 ret->normalize = msn_normalize; |
1259 | 1416 |
1417 my_protocol = ret; | |
1418 } | |
1419 | |
1985
008a4cc4a82c
[gaim-migrate @ 1995]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1984
diff
changeset
|
1420 char *gaim_plugin_init(GModule *handle) |
1282 | 1421 { |
1443
336fc98b7f90
[gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1327
diff
changeset
|
1422 load_protocol(msn_init, sizeof(struct prpl)); |
1259 | 1423 return NULL; |
1424 } | |
1425 | |
1282 | 1426 void gaim_plugin_remove() |
1427 { | |
1259 | 1428 struct prpl *p = find_prpl(PROTO_MSN); |
1429 if (p == my_protocol) | |
1430 unload_protocol(p); | |
1431 } |