annotate plugins/msn/msn.c @ 1321:413121dcf7e9

[gaim-migrate @ 1331] Heheh committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Wed, 20 Dec 2000 04:03:47 +0000
parents 4741b5a75b9f
children 113a3d16f1ce
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * gaim - MSN Protocol Plugin
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 * Copyright (C) 2000, Rob Flynn <rob@tgflinux.com>
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 *
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * (at your option) any later version.
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 *
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * GNU General Public License for more details.
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 *
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 *
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22 #include "../config.h"
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
23
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
24 #include <netdb.h>
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
25 #include <gtk/gtk.h>
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 #include <unistd.h>
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27 #include <errno.h>
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 #include <netinet/in.h>
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 #include <arpa/inet.h>
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 #include <string.h>
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31 #include <stdlib.h>
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 #include <stdio.h>
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
33 #include <time.h>
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
34 #include <sys/socket.h>
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35 #include <sys/stat.h>
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
36 #include "multi.h"
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
37 #include "prpl.h"
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
38 #include "gaim.h"
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
39 #include "md5.h"
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40
1284
ea91dbf089db [gaim-migrate @ 1294]
Rob Flynn <gaim@robflynn.com>
parents: 1283
diff changeset
41 #include "pixmaps/msn_online.xpm"
1285
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
42 #include "pixmaps/msn_away.xpm"
1284
ea91dbf089db [gaim-migrate @ 1294]
Rob Flynn <gaim@robflynn.com>
parents: 1283
diff changeset
43
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
44 #define MSN_BUF_LEN 4096
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45
1277
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
46 #define MSN_OPT_SERVER 0
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
47 #define MSN_OPT_PORT 1
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
48
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 #define MIME_HEADER "MIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\nX-MMS-IM-Format: FN=MS%20Sans%20Serif; EF=; CO=0; CS=0; PF=0\r\n\r\n"
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
51 #define MSN_ONLINE 1
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
52 #define MSN_BUSY 2
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
53 #define MSN_IDLE 3
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
54 #define MSN_BRB 4
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
55 #define MSN_AWAY 5
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
56 #define MSN_PHONE 6
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
57 #define MSN_LUNCH 7
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
58 #define MSN_OFFLINE 8
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
59 #define MSN_HIDDEN 9
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
60
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
61
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
62 struct msn_ask_add_permit {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
63 struct gaim_connection *gc;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
64 char *user;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
65 char *friendly;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
66 };
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
67
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
68 struct msn_data {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
69 int fd;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
70
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
71 char protocol[6];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
72 char *friendly;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
73 gchar *policy;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
74 };
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
75
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
76 struct msn_conn {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
77 gchar *user;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
78 int inpa;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
79 int fd;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
80 };
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
81
1283
87ad345a6d4f [gaim-migrate @ 1293]
Rob Flynn <gaim@robflynn.com>
parents: 1282
diff changeset
82 void msn_callback(gpointer data, gint fd, GdkInputCondition condition);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
83
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
84 GSList *msn_connections = NULL;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
85
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
86 static char *msn_name()
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
87 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
88 return "MSN";
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
89 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
90
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
91 char *name()
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
92 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
93 return "MSN";
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
94 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
95
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
96 char *description()
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
97 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
98 return "Allows gaim to use the MSN protocol. For some reason, this frightens me.";
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
99 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
100
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
101 struct msn_conn *find_msn_conn_by_user(gchar * user)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
102 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
103 struct msn_conn *mc;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
104 GSList *conns = msn_connections;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
105
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
106 while (conns) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
107 mc = (struct msn_conn *)conns->data;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
108
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
109 if (mc != NULL) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
110 if (strcasecmp(mc->user, user) == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
111 return mc;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
112 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
113 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
114
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
115 conns = g_slist_next(conns);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
116 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
117
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
118 return NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
119 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
120
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
121 void msn_read_line(char *buf, int fd)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
122 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
123
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
124 int status;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
125 char c;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
126 int i = 0;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
127
1307
751937b4f109 [gaim-migrate @ 1317]
Rob Flynn <gaim@robflynn.com>
parents: 1285
diff changeset
128 printf("%s (%d)\n", strerror(errno), errno);
751937b4f109 [gaim-migrate @ 1317]
Rob Flynn <gaim@robflynn.com>
parents: 1285
diff changeset
129
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
130 do {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
131 status = recv(fd, &c, 1, 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
132
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
133 if (!status)
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
134 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
135
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
136 buf[i] = c;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
137 i++;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
138 } while (c != '\n');
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
139
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
140 buf[i] = '\0';
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
141 g_strchomp(buf);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
142
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
143 /* I'm a bastard again :-) */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
144 printf("MSN: %s\n", buf);
1307
751937b4f109 [gaim-migrate @ 1317]
Rob Flynn <gaim@robflynn.com>
parents: 1285
diff changeset
145 printf("%s (%d)\n", strerror(errno), errno);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
146 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
147
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
148 int msn_connect(char *server, int port)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
149 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
150 int fd;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
151 struct hostent *host;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
152 struct sockaddr_in site;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
153
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
154 printf("Connecting to '%s' on '%d'\n", server, port);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
155 host = gethostbyname(server);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
156 if (!host) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
157 return -1;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
158 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
159
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
160 site.sin_family = AF_INET;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
161 site.sin_addr.s_addr = *(long *)(host->h_addr);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
162 site.sin_port = htons(port);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
163
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
164 fd = socket(AF_INET, SOCK_STREAM, 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
165 if (fd < 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
166 return -1;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
167 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
168
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
169 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
170 return -1;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
171 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
172
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
173 return fd;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
174 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
175
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
176 static void msn_add_buddy(struct gaim_connection *gc, char *who)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
177 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
178 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
179 time_t trId = time((time_t *) NULL);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
180 gchar buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
181
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
182 g_snprintf(buf, 4096, "ADD %d FL %s %s\n", trId, who, who);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
183 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
184 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
185
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
186 static void msn_rem_permit(struct gaim_connection *gc, char *who)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
187 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
188 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
189 time_t trId = time((time_t *) NULL);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
190 gchar buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
191
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
192 g_snprintf(buf, 4096, "REM %d AL %s %s\n", trId, who, who);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
193 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
194 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
195
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
196 static void msn_add_permit(struct gaim_connection *gc, char *who)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
197 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
198 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
199 time_t trId = time((time_t *) NULL);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
200 gchar buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
201
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
202 g_snprintf(buf, 4096, "ADD %d AL %s %s\n", trId, who, who);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
203 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
204 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
205
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
206 static void msn_rem_deny(struct gaim_connection *gc, char *who)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
207 {
1277
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
208 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
209 time_t trId = time((time_t *) NULL);
1277
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
210 gchar buf[4096];
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
211
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
212 g_snprintf(buf, 4096, "REM %d BL %s %s\n", trId, who, who);
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
213 write(mdata->fd, buf, strlen(buf));
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
214 }
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
215
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
216 static void msn_add_deny(struct gaim_connection *gc, char *who)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
217 {
1277
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
218 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
219 time_t trId = time((time_t *) NULL);
1277
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
220 gchar buf[4096];
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
221
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
222 g_snprintf(buf, 4096, "ADD %d BL %s %s\n", trId, who, who);
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
223 write(mdata->fd, buf, strlen(buf));
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
224 }
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
225
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
226 static void msn_remove_buddy(struct gaim_connection *gc, char *who)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
227 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
228 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
229 time_t trId = time((time_t *) NULL);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
230 gchar buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
231
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
232 g_snprintf(buf, 4096, "REM %d FL %s\n", trId, who);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
233 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
234 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
235
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
236 void msn_accept_add_permit(gpointer w, struct msn_ask_add_permit *ap)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
237 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
238 gchar buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
239
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
240 msn_add_permit(ap->gc, ap->user);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
241 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
242
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
243 void msn_cancel_add_permit(gpointer w, struct msn_ask_add_permit *ap)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
244 {
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
245
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
246 g_free(ap->user);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
247 g_free(ap->friendly);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
248 g_free(ap);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
249 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
250
1283
87ad345a6d4f [gaim-migrate @ 1293]
Rob Flynn <gaim@robflynn.com>
parents: 1282
diff changeset
251 void msn_callback(gpointer data, gint fd, GdkInputCondition condition)
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
252 {
1283
87ad345a6d4f [gaim-migrate @ 1293]
Rob Flynn <gaim@robflynn.com>
parents: 1282
diff changeset
253 struct gaim_connection *gc = data;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
254 struct msn_data *mdata;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
255 char c;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
256 int i = 0;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
257 int status;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
258 gchar buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
259 gchar **resps;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
260
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
261 mdata = (struct msn_data *)gc->proto_data;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
262
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
263 do {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
264 /* Read data from whatever connection our inpa
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
265 * refered us from */
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
266 status = recv(fd, &c, 1, 0);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
267
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
268 if (!status)
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
269 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
270
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
271 buf[i] = c;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
272 i++;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
273 } while (c != '\n');
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
274
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
275 buf[i] = '\0';
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
276
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
277 g_strchomp(buf);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
278
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
279 printf("MSN: %s\n", buf);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
280
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
281 if (strlen(buf) == 0) {
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
282 return;
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
283 }
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
284
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
285 resps = g_strsplit(buf, " ", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
286
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
287 /* See if someone is bumping us */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
288 if (strcasecmp(resps[0], "BYE") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
289 struct msn_conn *mc;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
290 GSList *conns = msn_connections;
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
291
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
292 /* Yup. Let's find their convo and kill it */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
293
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
294 mc = find_msn_conn_by_user(resps[1]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
295
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
296 /* If we have the convo, remove it */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
297 if (mc != NULL) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
298 /* and remove it */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
299 conns = g_slist_remove(conns, mc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
300
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
301 g_free(mc->user);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
302 gdk_input_remove(mc->inpa);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
303 close(mc->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
304
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
305
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
306 g_free(mc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
307 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
308
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
309 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
310 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
311 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
312
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
313 if (strcasecmp(resps[0], "ADD") == 0) {
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
314
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
315 if (strcasecmp(resps[2], "RL") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
316 gchar buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
317 struct msn_ask_add_permit *ap = g_new0(struct msn_ask_add_permit, 1);
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
318
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
319 g_snprintf(buf, 4096, "The user %s (%s) wants to add you to their buddylist.",
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
320 resps[4], resps[5]);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
321
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
322 ap->user = g_strdup(resps[4]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
323 ap->friendly = g_strdup(resps[5]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
324 ap->gc = gc;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
325
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
326 do_ask_dialog(buf, ap, (GtkFunction) msn_accept_add_permit,
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
327 (GtkFunction) msn_cancel_add_permit);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
328 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
329
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
330 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
331 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
332 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
333
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
334 if (strcasecmp(resps[0], "REM") == 0) {
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
335
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
336 if (strcasecmp(resps[2], "RL") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
337 msn_rem_permit(gc, resps[4]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
338 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
339
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
340 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
341 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
342 }
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
343
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
344 if (strcasecmp(resps[0], "FLN") == 0) {
1285
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
345 serv_got_update(gc, resps[1], 0, 0, 0, 0, 0, 0);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
346 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
347
1285
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
348 /* Check buddy update status */
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
349 if ( (strcasecmp(resps[0], "NLN") == 0) || (strcasecmp(resps[0], "ILN") == 0)) {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
350 int status;
1285
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
351 int query;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
352
1285
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
353 if (strcasecmp(resps[0], "NLN") == 0)
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
354 query = 1;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
355 else
1285
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
356 query = 2;
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
357
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
358 if (!strcasecmp(resps[query], "NLN"))
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
359 status = UC_NORMAL;
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
360 else if (!strcasecmp(resps[query], "BSY"))
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
361 status = UC_NORMAL | (MSN_BUSY << 5);
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
362 else if (!strcasecmp(resps[query], "IDL"))
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
363 status = UC_NORMAL | (MSN_IDLE << 5);
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
364 else if (!strcasecmp(resps[query], "BRB"))
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
365 status = UC_NORMAL | (MSN_BRB << 5);
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
366 else if (!strcasecmp(resps[query], "AWY"))
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
367 status = UC_UNAVAILABLE;
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
368 else if (!strcasecmp(resps[query], "PHN"))
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
369 status = UC_NORMAL | (MSN_PHONE << 5);
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
370 else if (!strcasecmp(resps[query], "LUN"))
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
371 status = UC_NORMAL | (MSN_LUNCH << 5);
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
372 else
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
373 status = UC_NORMAL;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
374
1285
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
375 serv_got_update(gc, resps[query+1], 1, 0, 0, 0, status, 0);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
376
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
377 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
378 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
379 }
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
380
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
381 /* Check to see if we have an incoming buddylist */
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
382 if (strcasecmp(resps[0], "LST") == 0) {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
383 /* Check to see if there are any buddies in the list */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
384 if (atoi(resps[5]) == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
385 /* No buddies */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
386 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
387 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
388 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
389
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
390 /* FIXME: We should support the permit and deny
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
391 * lists as well */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
392
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
393 if (strcasecmp(resps[2], "FL") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
394 struct buddy *b;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
395
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
396 b = find_buddy(gc, resps[6]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
397
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
398 if (!b)
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
399 add_buddy(gc, "Buddies", resps[6], resps[6]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
400 }
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
401
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
402 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
403 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
404 }
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
405
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
406 /* Check to see if we got a message request */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
407 if (strcasecmp(resps[0], "MSG") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
408 gchar *message;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
409 gchar *buf2;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
410 int size;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
411 int status;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
412
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
413 /* Determine our message size */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
414 size = atoi(resps[3]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
415
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
416 buf2 = (gchar *) g_malloc(sizeof(gchar) * (size + 1));
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
417 status = recv(fd, buf2, size, 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
418 buf2[size] = 0;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
419
1308
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
420 if (strcasecmp("hotmail", resps[1]) == 0) {
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
421
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
422 if (strstr(buf2, "Content-Type: text/x-msmsgsemailnotification")) {
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
423 g_snprintf(buf, sizeof(buf), "%s has new hotmail", gc->username);
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
424 do_error_dialog(buf, "Gaim: MSN New Mail");
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
425 }
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
426
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
427 g_strfreev(resps);
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
428 return;
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
429 }
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
430
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
431 /* Looks like we got the message. If it's blank, let's bail */
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
432 if (strcasecmp(strstr(buf2, "\r\n\r\n") + 4, "\r\n") == 0) {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
433 g_free(buf2);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
434 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
435 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
436 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
437
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
438 serv_got_im(gc, resps[1], strstr(buf2, "\r\n\r\n") + 4, 0);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
439
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
440 g_free(buf2);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
441 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
442 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
443 }
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
444
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
445
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
446 /* Check to see if we got a ring request */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
447 if (strcasecmp(resps[0], "RNG") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
448 gchar **address;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
449 struct msn_conn *mc = g_new0(struct msn_conn, 1);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
450
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
451 address = g_strsplit(resps[2], ":", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
452
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
453 if (!(mc->fd = msn_connect(address[0], atoi(address[1])))) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
454 do_error_dialog(resps[5], "Msg Err from");
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
455 g_strfreev(address);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
456 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
457 g_free(mc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
458 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
459 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
460
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
461 mc->user = g_strdup(resps[5]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
462
1283
87ad345a6d4f [gaim-migrate @ 1293]
Rob Flynn <gaim@robflynn.com>
parents: 1282
diff changeset
463 mc->inpa = gdk_input_add(mc->fd, GDK_INPUT_READ, msn_callback, gc);
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
464
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
465 g_snprintf(buf, 4096, "ANS 1 %s %s %s\n", gc->username, resps[4], resps[1]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
466 write(mc->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
467
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
468 msn_connections = g_slist_append(msn_connections, mc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
469
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
470 g_strfreev(address);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
471 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
472 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
473 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
474
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
475 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
476
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
477 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
478
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
479 void msn_login(struct aim_user *user)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
480 {
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
481 time_t trId = time((time_t *) NULL);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
482 char buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
483 char buf2[4096];
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
484
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
485 struct gaim_connection *gc = new_gaim_conn(user);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
486 struct msn_data *mdata = gc->proto_data = g_new0(struct msn_data, 1);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
487 char c;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
488 int i;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
489 int status;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
490
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
491 md5_state_t st;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
492 md5_byte_t di[16];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
493 int x;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
494
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
495 gchar **results;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
496
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
497 g_snprintf(mdata->protocol, strlen("MSNP2") + 1, "MSNP2");
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
498
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
499 set_login_progress(gc, 1, "Connecting");
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
500
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
501 while (gtk_events_pending())
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
502 gtk_main_iteration();
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
503 if (!g_slist_find(connections, gc))
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
504 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
505
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
506 if (!(mdata->fd = msn_connect("messenger.hotmail.com", 1863))) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
507 hide_login_progress(gc, "Error connection to server");
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
508 signoff(gc);
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
509 return;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
510 }
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
511
1308
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
512 printf("AAA: %s (%d)\n", strerror(errno), errno);
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
513
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
514 g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
515 set_login_progress(gc, 2, buf);
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
516
1279
8947583de4a1 [gaim-migrate @ 1289]
Rob Flynn <gaim@robflynn.com>
parents: 1278
diff changeset
517 while (gtk_events_pending())
8947583de4a1 [gaim-migrate @ 1289]
Rob Flynn <gaim@robflynn.com>
parents: 1278
diff changeset
518 gtk_main_iteration();
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
519
1308
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
520 printf("AAA: %s (%d)\n", strerror(errno), errno);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
521 /* This is where we will attempt to sign on */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
522 g_snprintf(buf, 4096, "VER %d %s\n", trId, mdata->protocol);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
523 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
524
1308
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
525 printf("AAA: %s (%d)\n", strerror(errno), errno);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
526 msn_read_line(&buf2, mdata->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
527
1308
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
528 printf("AAA: %s (%d)\n", strerror(errno), errno);
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
529 buf[strlen(buf) - 1] = '\0';
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
530 if (strcmp(buf, buf2) != 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
531 hide_login_progress(gc, buf2);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
532 signoff(gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
533 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
534 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
535
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
536 /* Looks like our versions matched up. Let's find out
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
537 * which policy we should use */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
538
1308
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
539 printf("AAA: %s (%d)\n", strerror(errno), errno);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
540 g_snprintf(buf, 4096, "INF %d\n", trId);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
541 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
542
1308
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
543 printf("AAA: %s (%d)\n", strerror(errno), errno);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
544 msn_read_line(&buf2, mdata->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
545 results = g_strsplit(buf2, " ", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
546 mdata->policy = g_strdup(results[2]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
547 g_strfreev(results);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
548
1308
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
549 printf("AAA: %s (%d)\n", strerror(errno), errno);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
550 /* We've set our policy. Now, lets attempt a sign on */
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
551 g_snprintf(buf, 4096, "USR %d %s I %s\n", trId, mdata->policy, gc->username);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
552 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
553
1308
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
554 printf("AAA: %s (%d)\n", strerror(errno), errno);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
555 msn_read_line(&buf2, mdata->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
556
1308
4741b5a75b9f [gaim-migrate @ 1318]
Rob Flynn <gaim@robflynn.com>
parents: 1307
diff changeset
557 printf("AAA: %s (%d)\n", strerror(errno), errno);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
558 /* This is where things get kinky */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
559 results = g_strsplit(buf2, " ", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
560
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
561 /* Are we being transfered to another server ? */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
562 if (strcasecmp(results[0], "XFR") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
563 /* Yup. We should connect to the _new_ server */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
564 strcpy(buf, results[3]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
565 g_strfreev(results);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
566
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
567 results = g_strsplit(buf, ":", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
568
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
569 /* Connect to the new server */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
570 if (!(mdata->fd = msn_connect(results[0], atoi(results[1])))) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
571 hide_login_progress(gc, "Error connecting to server");
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
572 signoff(gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
573 g_strfreev(results);
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
574 return;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
575 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
576
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
577
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
578 g_strfreev(results);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
579
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
580 /* We're now connected to the new server. Send signon
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
581 * information again */
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
582 g_snprintf(buf, 4096, "USR %d %s I %s\n", trId, mdata->policy, gc->username);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
583 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
584
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
585 msn_read_line(&buf, mdata->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
586 results = g_strsplit(buf, " ", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
587
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
588 }
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
589
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
590 /* Otherwise, if we have a USR response, let's handle it */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
591 if (strcasecmp("USR", results[0]) == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
592 /* Looks like we got a response. Let's get our challenge
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
593 * string */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
594 strcpy(buf, results[4]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
595
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
596 } else {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
597 g_strfreev(results);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
598 hide_login_progress(gc, "Error signing on");
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
599 signoff(gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
600 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
601 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
602 g_strfreev(results);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
603
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
604 /* Build our response string */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
605 snprintf(buf2, 4096, "%s%s", buf, gc->password);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
606
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
607 /* Use the MD5 Hashing */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
608 md5_init(&st);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
609 md5_append(&st, (const md5_byte_t *)buf2, strlen(buf2));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
610 md5_finish(&st, di);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
611
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
612 /* And now encode it in hex */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
613 sprintf(buf, "%02x", di[0]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
614 for (x = 1; x < 16; x++) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
615 sprintf(buf, "%s%02x", buf, di[x]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
616 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
617
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
618 /* And now we should fire back a response */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
619 g_snprintf(buf2, 4096, "USR %d %s S %s\n", trId, mdata->policy, buf);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
620 write(mdata->fd, buf2, strlen(buf2));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
621
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
622
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
623 msn_read_line(&buf, mdata->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
624
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
625 results = g_strsplit(buf, " ", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
626
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
627 if ((strcasecmp("USR", results[0]) == 0) && (strcasecmp("OK", results[2]) == 0)) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
628 mdata->friendly = g_strdup(results[4]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
629 g_strfreev(results);
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
630 } else {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
631 g_strfreev(results);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
632 hide_login_progress(gc, "Error signing on!");
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
633 signoff(gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
634 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
635
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
636 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
637 set_login_progress(gc, 3, "Getting Config");
1279
8947583de4a1 [gaim-migrate @ 1289]
Rob Flynn <gaim@robflynn.com>
parents: 1278
diff changeset
638 while (gtk_events_pending())
8947583de4a1 [gaim-migrate @ 1289]
Rob Flynn <gaim@robflynn.com>
parents: 1278
diff changeset
639 gtk_main_iteration();
8947583de4a1 [gaim-migrate @ 1289]
Rob Flynn <gaim@robflynn.com>
parents: 1278
diff changeset
640
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
641 g_snprintf(buf, 4096, "SYN %d 0\n", trId);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
642 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
643
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
644 /* Go online */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
645 g_snprintf(buf, 4096, "CHG %d NLN\n", trId);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
646 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
647
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
648 account_online(gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
649 serv_finish_login(gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
650
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
651 if (bud_list_cache_exists(gc))
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
652 do_import(NULL, gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
653
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
654 /* We want to do this so that we can read what's going on */
1283
87ad345a6d4f [gaim-migrate @ 1293]
Rob Flynn <gaim@robflynn.com>
parents: 1282
diff changeset
655 gc->inpa = gdk_input_add(mdata->fd, GDK_INPUT_READ, msn_callback, gc);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
656 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
657
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
658 void msn_send_im(struct gaim_connection *gc, char *who, char *message, int away)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
659 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
660 struct msn_conn *mc;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
661 struct msn_data *mdata;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
662 time_t trId = time((time_t *) NULL);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
663 char *buf;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
664
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
665 mdata = (struct msn_data *)gc->proto_data;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
666 mc = find_msn_conn_by_user(who);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
667
1307
751937b4f109 [gaim-migrate @ 1317]
Rob Flynn <gaim@robflynn.com>
parents: 1285
diff changeset
668 /* Are we trying to send a message to ourselves? Naughty us! */
751937b4f109 [gaim-migrate @ 1317]
Rob Flynn <gaim@robflynn.com>
parents: 1285
diff changeset
669 if (!g_strcasecmp(who, gc->username)) {
751937b4f109 [gaim-migrate @ 1317]
Rob Flynn <gaim@robflynn.com>
parents: 1285
diff changeset
670 do_error_dialog("You cannot send a message to yourself!!", "GAIM: Msn Error");
751937b4f109 [gaim-migrate @ 1317]
Rob Flynn <gaim@robflynn.com>
parents: 1285
diff changeset
671 return;
751937b4f109 [gaim-migrate @ 1317]
Rob Flynn <gaim@robflynn.com>
parents: 1285
diff changeset
672 }
751937b4f109 [gaim-migrate @ 1317]
Rob Flynn <gaim@robflynn.com>
parents: 1285
diff changeset
673
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
674 if (mc == NULL) {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
675 gchar buf2[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
676 gchar *address;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
677 gchar *auth;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
678 gchar **resps;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
679
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
680 /* Request a new switchboard connection */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
681 g_snprintf(buf2, 4096, "XFR %d SB\n", trId);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
682 write(mdata->fd, buf2, strlen(buf2));
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
683
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
684 /* Read the results */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
685 msn_read_line(&buf2, mdata->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
686
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
687 resps = g_strsplit(buf2, " ", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
688
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
689 address = g_strdup(resps[3]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
690 auth = g_strdup(resps[5]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
691 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
692
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
693 resps = g_strsplit(address, ":", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
694
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
695 mc = g_new0(struct msn_conn, 1);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
696
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
697 if (!(mc->fd = msn_connect(resps[0], atoi(resps[1])))) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
698 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
699 g_free(address);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
700 g_free(auth);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
701 g_free(mc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
702 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
703 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
704
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
705 /* Looks like we got connected ok. Now, let's verify */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
706 g_snprintf(buf2, 4096, "USR %d %s %s\n", trId, gc->username, auth);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
707 write(mc->fd, buf2, strlen(buf2));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
708
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
709 /* Read the results */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
710 msn_read_line(&buf2, mc->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
711 g_strfreev(resps);
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
712
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
713 resps = g_strsplit(buf2, " ", 0);
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
714
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
715 if (!(strcasecmp("OK", resps[2]) == 0)) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
716 g_free(auth);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
717 g_free(address);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
718 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
719 g_free(mc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
720 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
721 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
722
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
723 mc->user = g_strdup(who);
1283
87ad345a6d4f [gaim-migrate @ 1293]
Rob Flynn <gaim@robflynn.com>
parents: 1282
diff changeset
724 mc->inpa = gdk_input_add(mc->fd, GDK_INPUT_READ, msn_callback, gc);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
725
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
726 msn_connections = g_slist_append(msn_connections, mc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
727
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
728 /* Now we must invite our new user to the switchboard session */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
729 g_snprintf(buf2, 4096, "CAL %d %s\n", trId, who);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
730 write(mc->fd, buf2, strlen(buf2));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
731
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
732 /* FIXME: This causes a delay. I will make some sort of queing feature to prevent
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
733 * this from being needed */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
734
1307
751937b4f109 [gaim-migrate @ 1317]
Rob Flynn <gaim@robflynn.com>
parents: 1285
diff changeset
735 while ((!strstr(buf2, "JOI")) && (!g_strncasecmp(buf2, "215", 3))) {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
736 msn_read_line(&buf2, mc->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
737 }
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
738
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
739 g_free(auth);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
740 g_free(address);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
741 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
742
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
743 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
744
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
745 /* Always practice safe sets :-) */
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
746 buf = (gchar *) g_malloc(sizeof(gchar) * (strlen(message) + strlen(MIME_HEADER) + 64));
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
747
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
748 g_snprintf(buf, strlen(message) + strlen(MIME_HEADER) + 64, "MSG %d N %d\r\n%s%s", trId,
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
749 strlen(message) + strlen(MIME_HEADER), MIME_HEADER, message);
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
750
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
751 write(mc->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
752
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
753 g_free(buf);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
754 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
755
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
756 static void msn_close(struct gaim_connection *gc)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
757 {
1275
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
758 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
759 GSList *conns = msn_connections;
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
760 struct msn_conn *mc = NULL;
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
761 char buf[4096];
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
762
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
763 while (conns) {
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
764 mc = (struct msn_conn *)conns->data;
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
765
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
766 if (mc->inpa > 0)
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
767 gdk_input_remove(mc->inpa);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
768
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
769 if (mc->fd > 0)
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
770 close(mc->fd);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
771
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
772 if (mc->user != NULL)
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
773 g_free(mc->user);
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
774
1275
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
775 conns = g_slist_remove(conns, mc);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
776 g_free(mc);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
777 }
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
778
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
779
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
780 g_snprintf(buf, 4096, "OUT\n");
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
781 write(mdata->fd, buf, strlen(buf));
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
782
1275
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
783 if (gc->inpa > 0)
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
784 gdk_input_remove(gc->inpa);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
785
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
786 close(mdata->fd);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
787
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
788 if (mdata->friendly != NULL)
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
789 g_free(mdata->friendly);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
790
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
791 g_free(gc->proto_data);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
792
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
793 debug_printf(_("Signed off.\n"));
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
794
1275
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
795 }
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
796
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
797 static void msn_set_away(struct gaim_connection *gc, char *msg)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
798 {
1278
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
799 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
800 time_t trId = time((time_t *) NULL);
1278
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
801 gchar buf[4096];
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
802
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
803 if (msg) {
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
804 g_snprintf(buf, 4096, "CHG %d AWY\n", trId);
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
805 } else if (gc->is_idle) {
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
806 g_snprintf(buf, 4096, "CHG %d IDL\n", trId);
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
807 } else {
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
808 g_snprintf(buf, 4096, "CHG %d NLN\n", trId);
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
809 }
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
810
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
811 write(mdata->fd, buf, strlen(buf));
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
812
1278
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
813 }
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
814
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
815 static void msn_set_idle(struct gaim_connection *gc, int idle)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
816 {
1278
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
817 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
818 time_t trId = time((time_t *) NULL);
1278
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
819 gchar buf[4096];
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
820
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
821 if (idle) {
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
822 g_snprintf(buf, 4096, "CHG %d IDL\n", trId);
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
823 } else {
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
824 g_snprintf(buf, 4096, "CHG %d NLN\n", trId);
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
825 }
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
826
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
827 write(mdata->fd, buf, strlen(buf));
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
828
1278
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
829 }
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
830
1285
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
831 static char **msn_list_icon(int uc)
1284
ea91dbf089db [gaim-migrate @ 1294]
Rob Flynn <gaim@robflynn.com>
parents: 1283
diff changeset
832 {
1285
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
833 if (uc == UC_UNAVAILABLE)
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
834 return msn_away_xpm;
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
835 else if (uc == UC_NORMAL)
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
836 return msn_online_xpm;
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
837
f8557a227369 [gaim-migrate @ 1295]
Rob Flynn <gaim@robflynn.com>
parents: 1284
diff changeset
838 /* Our default online icon */
1284
ea91dbf089db [gaim-migrate @ 1294]
Rob Flynn <gaim@robflynn.com>
parents: 1283
diff changeset
839 return msn_online_xpm;
ea91dbf089db [gaim-migrate @ 1294]
Rob Flynn <gaim@robflynn.com>
parents: 1283
diff changeset
840 }
ea91dbf089db [gaim-migrate @ 1294]
Rob Flynn <gaim@robflynn.com>
parents: 1283
diff changeset
841
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
842 static struct prpl *my_protocol = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
843
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
844 void msn_init(struct prpl *ret)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
845 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
846 ret->protocol = PROTO_MSN;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
847 ret->name = msn_name;
1284
ea91dbf089db [gaim-migrate @ 1294]
Rob Flynn <gaim@robflynn.com>
parents: 1283
diff changeset
848 ret->list_icon = msn_list_icon;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
849 ret->action_menu = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
850 ret->user_opts = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
851 ret->login = msn_login;
1275
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
852 ret->close = msn_close;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
853 ret->send_im = msn_send_im;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
854 ret->set_info = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
855 ret->get_info = NULL;
1278
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
856 ret->set_away = msn_set_away;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
857 ret->get_away_msg = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
858 ret->set_dir = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
859 ret->get_dir = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
860 ret->dir_search = NULL;
1278
b319e507a36a [gaim-migrate @ 1288]
Rob Flynn <gaim@robflynn.com>
parents: 1277
diff changeset
861 ret->set_idle = msn_set_idle;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
862 ret->change_passwd = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
863 ret->add_buddy = msn_add_buddy;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
864 ret->add_buddies = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
865 ret->remove_buddy = msn_remove_buddy;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
866 ret->add_permit = msn_add_permit;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
867 ret->rem_permit = msn_rem_permit;
1277
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
868 ret->add_deny = msn_add_deny;
ba196bf5c4cd [gaim-migrate @ 1287]
Rob Flynn <gaim@robflynn.com>
parents: 1276
diff changeset
869 ret->rem_deny = msn_rem_deny;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
870 ret->warn = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
871 ret->accept_chat = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
872 ret->join_chat = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
873 ret->chat_invite = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
874 ret->chat_leave = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
875 ret->chat_whisper = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
876 ret->chat_send = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
877 ret->keepalive = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
878
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
879 my_protocol = ret;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
880 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
881
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
882 char *gaim_plugin_init(GModule * handle)
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
883 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
884 load_protocol(msn_init);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
885 return NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
886 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
887
1282
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
888 void gaim_plugin_remove()
577b71ae4e2a [gaim-migrate @ 1292]
Rob Flynn <gaim@robflynn.com>
parents: 1279
diff changeset
889 {
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
890 struct prpl *p = find_prpl(PROTO_MSN);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
891 if (p == my_protocol)
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
892 unload_protocol(p);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
893 }