annotate plugins/msn/msn.c @ 1276:3e19d163fc45

[gaim-migrate @ 1286] lala committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Thu, 14 Dec 2000 18:55:30 +0000
parents de3339e2a0c4
children ba196bf5c4cd
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
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41 #define MSN_BUF_LEN 4096
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
43 #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
44
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45 #define MSN_ONLINE 1
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
46 #define MSN_BUSY 2
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47 #define MSN_IDLE 3
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
48 #define MSN_BRB 4
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 #define MSN_AWAY 5
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50 #define MSN_PHONE 6
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
51 #define MSN_LUNCH 7
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
52 #define MSN_OFFLINE 8
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
53 #define MSN_HIDDEN 9
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
54
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
55
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
56 struct msn_ask_add_permit {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
57 struct gaim_connection *gc;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
58 char *user;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
59 char *friendly;
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_data {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
63 int fd;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
64
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
65 char protocol[6];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
66 char *friendly;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
67 gchar *policy;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
68 };
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
69
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
70 struct msn_conn {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
71 gchar *user;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
72 int inpa;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
73 int fd;
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 void msn_handler(gpointer data, gint source, GdkInputCondition condition);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
77
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
78 GSList * msn_connections = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
79
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
80 static char *msn_name() {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
81 return "MSN";
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
82 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
83
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
84 char *name() {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
85 return "MSN";
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
86 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
87
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
88 char *description() {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
89 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
90 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
91
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
92 struct msn_conn *find_msn_conn_by_user(gchar *user) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
93 struct msn_conn *mc;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
94 GSList *conns = msn_connections;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
95
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
96 while (conns) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
97 mc = (struct msn_conn *)conns->data;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
98
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
99 if (mc != NULL) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
100 if (strcasecmp(mc->user, user) == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
101 return mc;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
102 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
103 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
104
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
105 conns = g_slist_next(conns);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
106 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
107
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
108 return NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
109 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
110
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
111 void msn_read_line(char *buf, int fd) {
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 int status;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
114 char c;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
115 int i = 0;
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 do {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
118 status = recv(fd, &c, 1, 0);
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 if (!status)
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
121 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
122
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
123 buf[i] = c;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
124 i++;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
125 } while (c != '\n');
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
126
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
127 buf[i] = '\0';
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
128 g_strchomp(buf);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
129
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
130 /* I'm a bastard again :-) */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
131 printf("MSN: %s\n", buf);
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
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
134 int msn_connect(char *server, int port) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
135 int fd;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
136 struct hostent *host;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
137 struct sockaddr_in site;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
138
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
139 printf("Connecting to '%s' on '%d'\n", server, port);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
140 host = gethostbyname(server);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
141 if (!host) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
142 return -1;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
143 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
144
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
145 site.sin_family = AF_INET;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
146 site.sin_addr.s_addr = *(long *)(host->h_addr);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
147 site.sin_port = htons(port);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
148
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
149 fd = socket(AF_INET, SOCK_STREAM, 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
150 if (fd < 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
151 return -1;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
152 }
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 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
155 return -1;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
156 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
157
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
158 return fd;
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
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
161 static void msn_add_buddy(struct gaim_connection *gc, char *who) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
162 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
163 time_t trId = time((time_t *)NULL);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
164 gchar buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
165
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
166 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
167 write(mdata->fd, buf, strlen(buf));
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
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
170 static void msn_rem_permit(struct gaim_connection *gc, char *who) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
171 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
172 time_t trId = time((time_t *)NULL);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
173 gchar buf[4096];
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 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
176 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
177 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
178
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
179 static void msn_add_permit(struct gaim_connection *gc, char *who) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
180 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
181 time_t trId = time((time_t *)NULL);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
182 gchar buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
183
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
184 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
185 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
186 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
187
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
188 static void msn_remove_buddy(struct gaim_connection *gc, char *who) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
189 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
190 time_t trId = time((time_t *)NULL);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
191 gchar buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
192
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
193 g_snprintf(buf, 4096, "REM %d FL %s\n", trId, who);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
194 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
195 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
196
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
197 void msn_accept_add_permit (gpointer w, struct msn_ask_add_permit *ap ) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
198 gchar buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
199
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
200 msn_add_permit(ap->gc, ap->user);
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
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
203 void msn_cancel_add_permit (gpointer w, struct msn_ask_add_permit *ap ) {
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 g_free(ap->user);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
206 g_free(ap->friendly);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
207 g_free(ap);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
208 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
209
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
210 void msn_callback (struct gaim_connection * gc, gint fd) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
211 struct msn_data *mdata;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
212 char c;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
213 int i = 0;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
214 int status;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
215 gchar buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
216 gchar **resps;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
217
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
218 mdata = (struct msn_data *)gc->proto_data;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
219
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
220 do {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
221 /* Read data from whatever connection our inpa
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
222 * refered us from */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
223 status = recv(fd, &c, 1,0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
224
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
225 if (!status)
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
226 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
227
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
228 buf[i] = c;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
229 i++;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
230 } while (c != '\n');
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 buf[i] = '\0';
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
233
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
234 g_strchomp(buf);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
235
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
236 printf("MSN: %s\n", buf);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
237
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
238 if (strlen(buf) == 0) { return; }
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 resps = g_strsplit(buf, " ", 0);
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 /* See if someone is bumping us */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
243 if (strcasecmp(resps[0], "BYE") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
244 struct msn_conn *mc;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
245 GSList * conns = msn_connections;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
246
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
247 /* Yup. Let's find their convo and kill it */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
248
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
249 mc = find_msn_conn_by_user(resps[1]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
250
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
251 /* If we have the convo, remove it */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
252 if (mc != NULL) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
253 /* and remove it */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
254 conns = g_slist_remove(conns, mc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
255
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
256 g_free(mc->user);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
257 gdk_input_remove(mc->inpa);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
258 close(mc->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
260
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
261 g_free(mc);
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
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
264 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
265 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
266 }
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 (strcasecmp(resps[0], "ADD") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
269
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
270 if (strcasecmp(resps[2], "RL") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
271 gchar buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
272 struct msn_ask_add_permit *ap = g_new0(struct msn_ask_add_permit, 1);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
273
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
274 g_snprintf(buf, 4096, "The user %s (%s) wants to add you to their buddylist.", resps[4], resps[5]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
275
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
276 ap->user = g_strdup(resps[4]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
277 ap->friendly = g_strdup(resps[5]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
278 ap->gc = gc;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
279
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
280 do_ask_dialog(buf, ap, (GtkFunction)msn_accept_add_permit, (GtkFunction)msn_cancel_add_permit);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
281 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
282
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
283 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
284 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
285 }
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 if (strcasecmp(resps[0], "REM") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
288
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
289 if (strcasecmp(resps[2], "RL") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
290 msn_rem_permit(gc, resps[4]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
291 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
292
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
293 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
294 return;
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
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
297 if (strcasecmp(resps[0], "FLN") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
298 serv_got_update(gc, resps[1], 0, 0, 0, 0, MSN_OFFLINE, 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
299 }
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 if (strcasecmp(resps[0], "ILN") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
302 int status;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
303
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
304 if (!strcasecmp(resps[2], "NLN"))
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
305 status = MSN_ONLINE;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
306 else if (!strcasecmp(resps[2], "BSY"))
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
307 status = MSN_BUSY;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
308 else if (!strcasecmp(resps[2], "IDL"))
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
309 status = MSN_IDLE;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
310 else if (!strcasecmp(resps[2], "BRB"))
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
311 status = MSN_BRB;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
312 else if (!strcasecmp(resps[2], "AWY"))
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
313 status = MSN_AWAY;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
314 else if (!strcasecmp(resps[2], "PHN"))
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
315 status = MSN_PHONE;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
316 else if (!strcasecmp(resps[2], "LUN"))
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
317 status = MSN_LUNCH;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
318 else
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
319 status = MSN_ONLINE;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
320
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
321 serv_got_update(gc, resps[3], 1, 0, 0, 0, status, 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
322
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
323 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
324 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
325
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
326 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
327
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
328 /* Check buddy update status */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
329 if (strcasecmp(resps[0], "NLN") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
330 /* FIXME: We currently dont care if they are busy,
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
331 * idle, brb, away, phone, our out to lunch. This will
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
332 * be supported eventually (BSY,IDL,BRB,AWY,PHN,LUN)
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
333 * respectively */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
334
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
335 serv_got_update(gc, resps[2], 1, 0, 0, 0, MSN_ONLINE, 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
336 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
337
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
338 /* Check to see if we have an incoming buddylist */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
339 if (strcasecmp(resps[0], "LST") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
340 /* Check to see if there are any buddies in the list */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
341 if (atoi(resps[5]) == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
342 /* No buddies */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
343 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
344 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
345 }
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 /* FIXME: We should support the permit and deny
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
348 * lists as well */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
349
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
350 if (strcasecmp(resps[2], "FL") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
351 struct buddy *b;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
352
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
353 b = find_buddy(gc, resps[6]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
354
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
355 if (!b)
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
356 add_buddy(gc, "Buddies", resps[6], resps[6]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
357 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
358
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
359 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
360 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
361 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
362
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
363 /* Check to see if we got a message request */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
364 if (strcasecmp(resps[0], "MSG") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
365 gchar *message;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
366 gchar *buf2;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
367 int size;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
368 int status;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
369
1275
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
370 if (strcasecmp("hotmail", resps[1]) == 0) {
1276
3e19d163fc45 [gaim-migrate @ 1286]
Rob Flynn <gaim@robflynn.com>
parents: 1275
diff changeset
371 /* We want to ignore these. We can parse them
3e19d163fc45 [gaim-migrate @ 1286]
Rob Flynn <gaim@robflynn.com>
parents: 1275
diff changeset
372 * eventually if we ever plan on doing anything
3e19d163fc45 [gaim-migrate @ 1286]
Rob Flynn <gaim@robflynn.com>
parents: 1275
diff changeset
373 * with them */
1275
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
374 g_strfreev(resps);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
375 return;
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
376 }
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
377
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
378 /* Determine our message size */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
379 size = atoi(resps[3]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
380
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
381 buf2 = (gchar *)g_malloc(sizeof(gchar) * (size+1));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
382 status = recv(fd, buf2, size, 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
383 buf2[size] = 0;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
384
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
385 /* Looks like we got the message. If it's blank, let's bail */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
386 if (strcasecmp(strstr(buf2, "\r\n\r\n")+4, "\r\n") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
387 g_free(buf2);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
388 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
389 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
390 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
391
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
392 serv_got_im(gc, resps[1], strstr(buf2, "\r\n\r\n")+4, 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
393
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
394 g_free(buf2);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
395 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
396 return;
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
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
399
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
400 /* Check to see if we got a ring request */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
401 if (strcasecmp(resps[0], "RNG") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
402 gchar **address;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
403 struct msn_conn *mc = g_new0(struct msn_conn, 1);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
404
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
405 address = g_strsplit(resps[2], ":", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
406
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
407 if (!(mc->fd = msn_connect(address[0], atoi(address[1])))) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
408 do_error_dialog(resps[5], "Msg Err from");
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
409 g_strfreev(address);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
410 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
411 g_free(mc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
412 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
413 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
414
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
415 mc->user = g_strdup(resps[5]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
416
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
417 mc->inpa = gdk_input_add(mc->fd, GDK_INPUT_READ, msn_handler, gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
418
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
419 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
420 write(mc->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
421
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
422 msn_connections = g_slist_append(msn_connections, mc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
423
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
424 g_strfreev(address);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
425 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
426 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
427 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
428
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
429 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
430
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
431 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
432
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
433
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
434 void msn_handler(gpointer data, gint source, GdkInputCondition condition) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
435 msn_callback(data, source);
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
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
438 void msn_login(struct aim_user *user) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
439 time_t trId = time((time_t *)NULL);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
440 char buf[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
441 char buf2[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
442
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
443 struct gaim_connection *gc = new_gaim_conn(user);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
444 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
445 char c;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
446 int i;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
447 int status;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
448
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
449 md5_state_t st;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
450 md5_byte_t di[16];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
451 int x;
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 gchar **results;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
454
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
455 g_snprintf(mdata->protocol, strlen("MSNP2")+1, "MSNP2");
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
456
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
457 set_login_progress(gc, 1,"Connecting");
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
458
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
459 while (gtk_events_pending())
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
460 gtk_main_iteration();
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
461 if (!g_slist_find(connections, gc))
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
462 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
463
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
464 if (!(mdata->fd = msn_connect("messenger.hotmail.com", 1863))) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
465 hide_login_progress(gc, "Error connection to server");
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
466 signoff(gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
467 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
468 }
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_snprintf(buf, sizeof(buf), "Signon: %s", gc->username);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
471 set_login_progress(gc, 2, buf);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
472
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
473 /* This is where we will attempt to sign on */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
474 g_snprintf(buf, 4096, "VER %d %s\n", trId, mdata->protocol);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
475 write(mdata->fd, buf, strlen(buf));
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 msn_read_line(&buf2, mdata->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
478
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
479 buf[strlen(buf)-1] = '\0';
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
480 if (strcmp(buf, buf2) != 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
481 hide_login_progress(gc, buf2);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
482 signoff(gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
483 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
484 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
485
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
486 /* Looks like our versions matched up. Let's find out
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
487 * which policy we should use */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
488
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
489 g_snprintf(buf, 4096, "INF %d\n", trId);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
490 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
491
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
492 msn_read_line(&buf2, mdata->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
493 results = g_strsplit(buf2, " ", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
494 mdata->policy = g_strdup(results[2]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
495 g_strfreev(results);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
496
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
497 /* We've set our policy. Now, lets attempt a sign on */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
498 g_snprintf(buf, 4096, "USR %d %s I %s\n", trId, mdata->policy, gc->username);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
499 write(mdata->fd, buf, strlen(buf));
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 msn_read_line(&buf2, mdata->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
502
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
503 /* This is where things get kinky */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
504 results = g_strsplit(buf2, " ", 0);
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 /* Are we being transfered to another server ? */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
507 if (strcasecmp(results[0], "XFR") == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
508 /* Yup. We should connect to the _new_ server */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
509 strcpy(buf, results[3]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
510 g_strfreev(results);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
511
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
512 results = g_strsplit(buf, ":", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
513
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
514 /* Connect to the new server */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
515 if (!(mdata->fd = msn_connect(results[0], atoi(results[1])))) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
516 hide_login_progress(gc, "Error connecting to server");
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
517 signoff(gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
518 g_strfreev(results);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
519 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
520 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
521
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
522
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
523 g_strfreev(results);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
524
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
525 /* We're now connected to the new server. Send signon
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
526 * information again */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
527 g_snprintf(buf, 4096, "USR %d %s I %s\n", trId, mdata->policy, gc->username);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
528 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
529
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
530 msn_read_line(&buf, mdata->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
531 results = g_strsplit(buf, " ", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
532
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
533 }
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 /* Otherwise, if we have a USR response, let's handle it */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
536 if (strcasecmp("USR", results[0]) == 0) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
537 /* Looks like we got a response. Let's get our challenge
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
538 * string */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
539 strcpy(buf, results[4]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
540
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
541 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
542 else {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
543 g_strfreev(results);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
544 hide_login_progress(gc, "Error signing on");
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
545 signoff(gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
546 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
547 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
548 g_strfreev(results);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
549
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
550 /* Build our response string */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
551 snprintf(buf2, 4096, "%s%s", buf, gc->password);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
552
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
553 /* Use the MD5 Hashing */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
554 md5_init(&st);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
555 md5_append(&st, (const md5_byte_t *)buf2, strlen(buf2));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
556 md5_finish(&st, di);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
557
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
558 /* And now encode it in hex */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
559 sprintf(buf, "%02x", di[0]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
560 for (x = 1; x < 16; x++) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
561 sprintf(buf, "%s%02x", buf, di[x]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
562 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
563
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
564 /* And now we should fire back a response */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
565 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
566 write(mdata->fd, buf2, strlen(buf2));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
567
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 msn_read_line(&buf, mdata->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
570
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
571 results = g_strsplit(buf, " ", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
572
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
573 if ((strcasecmp("USR", results[0]) == 0) && (strcasecmp("OK", results[2]) == 0)) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
574 mdata->friendly = g_strdup(results[4]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
575 g_strfreev(results);
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 else {
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 hide_login_progress(gc, "Error signing on!");
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
580 signoff(gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
581 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
582
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
583 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
584 set_login_progress(gc, 3, "Getting Config");
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
585 g_snprintf(buf, 4096, "SYN %d 0\n", trId);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
586 write(mdata->fd, buf, strlen(buf));
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 /* Go online */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
589 g_snprintf(buf, 4096, "CHG %d NLN\n", trId);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
590 write(mdata->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
591
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
592 account_online(gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
593 serv_finish_login(gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
594
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
595 if (bud_list_cache_exists(gc))
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
596 do_import(NULL, gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
597
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
598 /* We want to do this so that we can read what's going on */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
599 gc->inpa = gdk_input_add(mdata->fd, GDK_INPUT_READ, msn_handler, gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
600 }
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 void msn_send_im(struct gaim_connection *gc, char *who, char *message, int away) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
603 struct msn_conn *mc;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
604 struct msn_data *mdata;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
605 time_t trId = time((time_t *)NULL);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
606 char *buf;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
607
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
608 mdata = (struct msn_data *)gc->proto_data;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
609 mc = find_msn_conn_by_user(who);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
610
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
611 if (mc == NULL)
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
612 {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
613 gchar buf2[4096];
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
614 gchar *address;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
615 gchar *auth;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
616 gchar **resps;
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 /* Request a new switchboard connection */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
619 g_snprintf(buf2, 4096, "XFR %d SB\n", trId);
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 /* Read the results */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
623 msn_read_line(&buf2, 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 resps = g_strsplit(buf2, " ", 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 address = g_strdup(resps[3]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
628 auth = g_strdup(resps[5]);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
629 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
630
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
631 resps = g_strsplit(address, ":", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
632
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
633 mc = g_new0(struct msn_conn, 1);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
634
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
635 if (!(mc->fd = msn_connect(resps[0], atoi(resps[1])))) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
636 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
637 g_free(address);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
638 g_free(auth);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
639 g_free(mc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
640 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
641 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
642
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
643 /* Looks like we got connected ok. Now, let's verify */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
644 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
645 write(mc->fd, buf2, strlen(buf2));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
646
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
647 /* Read the results */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
648 msn_read_line(&buf2, mc->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
649 g_strfreev(resps);
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 resps = g_strsplit(buf2, " ", 0);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
652
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
653 if (!(strcasecmp("OK", resps[2]) == 0)) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
654 g_free(auth);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
655 g_free(address);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
656 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
657 g_free(mc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
658 return;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
659 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
660
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
661 mc->user = g_strdup(who);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
662 mc->inpa = gdk_input_add(mc->fd, GDK_INPUT_READ, msn_handler, gc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
663
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
664 msn_connections = g_slist_append(msn_connections, mc);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
665
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
666 /* Now we must invite our new user to the switchboard session */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
667 g_snprintf(buf2, 4096, "CAL %d %s\n", trId, who);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
668 write(mc->fd, buf2, strlen(buf2));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
669
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
670 /* 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
671 * this from being needed */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
672
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
673 while (!strstr(buf2, "JOI")) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
674 msn_read_line(&buf2, mc->fd);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
675 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
676
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
677 g_free(auth);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
678 g_free(address);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
679 g_strfreev(resps);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
680
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
681 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
682
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
683 /* Always practice safe sets :-) */
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
684 buf = (gchar *)g_malloc(sizeof(gchar) * (strlen(message) + strlen(MIME_HEADER) + 64));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
685
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
686 g_snprintf(buf, strlen(message) + strlen(MIME_HEADER) + 64, "MSG %d N %d\r\n%s%s", trId, strlen(message)+strlen(MIME_HEADER), MIME_HEADER, message);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
687
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
688 write(mc->fd, buf, strlen(buf));
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
689
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
690 g_free(buf);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
691 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
692
1275
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
693 void msn_close (struct gaim_connection *gc) {
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
694 struct msn_data *mdata = (struct msn_data *)gc->proto_data;
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
695 GSList *conns = msn_connections;
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
696 struct msn_conn *mc = NULL;
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
697 char buf[4096];
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
698
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
699 while (conns) {
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
700 mc = (struct msn_conn *)conns->data;
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
701
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
702 if (mc->inpa > 0)
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
703 gdk_input_remove(mc->inpa);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
704
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
705 if (mc->fd > 0)
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
706 close(mc->fd);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
707
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
708 if (mc->user != NULL)
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
709 g_free(mc->user);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
710
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
711 conns = g_slist_remove(conns, mc);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
712 g_free(mc);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
713 }
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
714
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
715
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
716 g_snprintf(buf, 4096, "OUT\n");
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
717 write(mdata->fd, buf, strlen(buf));
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
718
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
719 if (gc->inpa > 0)
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
720 gdk_input_remove(gc->inpa);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
721
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
722 close(mdata->fd);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
723
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
724 if (mdata->friendly != NULL)
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
725 g_free(mdata->friendly);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
726
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
727 g_free(gc->proto_data);
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
728
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
729 debug_printf(_("Signed off.\n"));
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
730
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
731 }
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
732
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
733 static struct prpl *my_protocol = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
734
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
735 void msn_init(struct prpl *ret) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
736 ret->protocol = PROTO_MSN;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
737 ret->name = msn_name;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
738 ret->list_icon = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
739 ret->action_menu = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
740 ret->user_opts = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
741 ret->login = msn_login;
1275
de3339e2a0c4 [gaim-migrate @ 1285]
Rob Flynn <gaim@robflynn.com>
parents: 1262
diff changeset
742 ret->close = msn_close;
1259
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
743 ret->send_im = msn_send_im;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
744 ret->set_info = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
745 ret->get_info = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
746 ret->set_away = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
747 ret->get_away_msg = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
748 ret->set_dir = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
749 ret->get_dir = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
750 ret->dir_search = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
751 ret->set_idle = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
752 ret->change_passwd = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
753 ret->add_buddy = msn_add_buddy;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
754 ret->add_buddies = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
755 ret->remove_buddy = msn_remove_buddy;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
756 ret->add_permit = msn_add_permit;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
757 ret->rem_permit = msn_rem_permit;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
758 ret->add_deny = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
759 ret->warn = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
760 ret->accept_chat = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
761 ret->join_chat = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
762 ret->chat_invite = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
763 ret->chat_leave = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
764 ret->chat_whisper = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
765 ret->chat_send = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
766 ret->keepalive = NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
767
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
768 my_protocol = ret;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
769 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
770
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
771 char *gaim_plugin_init(GModule *handle) {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
772 load_protocol(msn_init);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
773 return NULL;
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
774 }
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
775
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
776 void gaim_plugin_remove() {
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
777 struct prpl *p = find_prpl(PROTO_MSN);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
778 if (p == my_protocol)
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
779 unload_protocol(p);
7db9121aac80 [gaim-migrate @ 1269]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
780 }