Mercurial > pidgin.yaz
annotate plugins/msn/msn.c @ 1684:89c19002e73d
[gaim-migrate @ 1694]
stop getting booted by gabber people
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Thu, 05 Apr 2001 01:04:10 +0000 |
| parents | 5f3027fbce4c |
| children | 1c8e109f8934 |
| rev | line source |
|---|---|
| 1259 | 1 /* |
| 2 * gaim - MSN Protocol Plugin | |
| 3 * | |
| 4 * Copyright (C) 2000, Rob Flynn <rob@tgflinux.com> | |
| 5 * | |
| 6 * This program is free software; you can redistribute it and/or modify | |
| 7 * it under the terms of the GNU General Public License as published by | |
| 8 * the Free Software Foundation; either version 2 of the License, or | |
| 9 * (at your option) any later version. | |
| 10 * | |
| 11 * This program is distributed in the hope that it will be useful, | |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 * GNU General Public License for more details. | |
| 15 * | |
| 16 * You should have received a copy of the GNU General Public License | |
| 17 * along with this program; if not, write to the Free Software | |
| 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 * | |
| 20 */ | |
| 21 | |
|
1514
0dd012166152
[gaim-migrate @ 1524]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1499
diff
changeset
|
22 #include "config.h" |
| 1259 | 23 |
| 24 #include <netdb.h> | |
| 25 #include <gtk/gtk.h> | |
| 26 #include <unistd.h> | |
| 27 #include <errno.h> | |
| 28 #include <netinet/in.h> | |
| 29 #include <arpa/inet.h> | |
| 30 #include <string.h> | |
| 31 #include <stdlib.h> | |
| 32 #include <stdio.h> | |
| 33 #include <time.h> | |
| 1567 | 34 #include <fcntl.h> |
| 1259 | 35 #include <sys/socket.h> |
| 36 #include <sys/stat.h> | |
| 1567 | 37 #include <sys/types.h> |
| 1259 | 38 #include "multi.h" |
| 39 #include "prpl.h" | |
| 40 #include "gaim.h" | |
| 41 #include "md5.h" | |
| 42 | |
| 1284 | 43 #include "pixmaps/msn_online.xpm" |
| 1285 | 44 #include "pixmaps/msn_away.xpm" |
| 1284 | 45 |
| 1567 | 46 #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" |
| 1259 | 47 |
| 1567 | 48 #define MSN_BUF_LEN 8192 |
| 1259 | 49 |
| 50 #define MSN_ONLINE 1 | |
| 51 #define MSN_BUSY 2 | |
| 52 #define MSN_IDLE 3 | |
| 53 #define MSN_BRB 4 | |
| 54 #define MSN_AWAY 5 | |
| 55 #define MSN_PHONE 6 | |
| 56 #define MSN_LUNCH 7 | |
| 57 #define MSN_OFFLINE 8 | |
| 58 #define MSN_HIDDEN 9 | |
| 59 | |
| 1567 | 60 #define MSN_SIGNON_GOT_XFR 0x0001 |
| 61 #define MSN_SIGNON_SENT_USR 0x0002 | |
| 1259 | 62 |
| 1598 | 63 struct msn_ask_add_permit { |
| 64 struct gaim_connection *gc; | |
| 65 char *user; | |
| 66 char *friendly; | |
| 67 }; | |
| 68 | |
| 1259 | 69 struct msn_data { |
| 70 int fd; | |
| 71 | |
| 72 char protocol[6]; | |
| 73 char *friendly; | |
| 74 gchar *policy; | |
| 1567 | 75 int inpa; |
| 76 int status; | |
| 1631 | 77 int away; |
| 1567 | 78 time_t last_trid; |
| 1259 | 79 }; |
| 80 | |
| 81 struct msn_conn { | |
| 82 gchar *user; | |
| 83 int inpa; | |
| 84 int fd; | |
| 1572 | 85 struct gaim_connection *gc; |
| 86 char *secret; | |
| 87 char *session; | |
| 1584 | 88 time_t last_trid; |
| 89 char *txqueue; | |
| 1259 | 90 }; |
| 91 | |
| 1567 | 92 GSList *msn_connections = NULL; |
| 1259 | 93 |
| 1567 | 94 unsigned long long globalc = 0; |
| 1572 | 95 static void msn_callback(gpointer data, gint source, GdkInputCondition condition); |
| 1598 | 96 static void msn_add_permit(struct gaim_connection *gc, char *who); |
| 97 | |
| 98 void msn_accept_add_permit(gpointer w, struct msn_ask_add_permit *ap) | |
| 99 { | |
| 100 msn_add_permit(ap->gc, ap->user); | |
| 101 } | |
| 102 | |
| 103 void msn_cancel_add_permit(gpointer w, struct msn_ask_add_permit *ap) | |
| 104 { | |
| 105 g_free(ap->user); | |
| 106 g_free(ap->friendly); | |
| 107 g_free(ap); | |
| 108 } | |
| 1259 | 109 |
| 1588 | 110 void free_msn_conn(struct msn_conn *mc) |
| 111 { | |
| 112 if (mc->user) | |
| 113 free(mc->user); | |
| 114 | |
| 115 if (mc->secret) | |
| 116 free(mc->secret); | |
| 117 | |
| 118 if (mc->session) | |
| 119 free(mc->session); | |
| 120 | |
| 121 if (mc->txqueue) | |
| 122 free(mc->txqueue); | |
| 123 | |
| 124 gdk_input_remove(mc->inpa); | |
| 125 close(mc->fd); | |
| 126 | |
| 127 msn_connections = g_slist_remove(msn_connections, mc); | |
| 128 | |
| 129 g_free(mc); | |
| 130 } | |
| 131 | |
| 132 | |
| 1584 | 133 struct msn_conn *find_msn_conn_by_user(gchar * user) |
| 134 { | |
| 135 struct msn_conn *mc; | |
| 136 GSList *conns = msn_connections; | |
| 137 | |
| 138 while (conns) { | |
| 139 mc = (struct msn_conn *)conns->data; | |
| 140 | |
| 141 if (mc != NULL) { | |
| 142 if (strcasecmp(mc->user, user) == 0) { | |
| 143 return mc; | |
| 144 } | |
| 145 } | |
| 146 | |
| 147 conns = g_slist_next(conns); | |
| 148 } | |
| 149 | |
| 150 return NULL; | |
| 151 } | |
| 152 | |
| 153 struct msn_conn *find_msn_conn_by_trid(time_t trid) | |
| 154 { | |
| 155 struct msn_conn *mc; | |
| 156 GSList *conns = msn_connections; | |
| 157 | |
| 158 while (conns) { | |
| 159 mc = (struct msn_conn *)conns->data; | |
| 160 | |
| 161 if (mc != NULL) { | |
| 162 | |
| 163 printf("Comparing: %d <==> %d\n", mc->last_trid, trid); | |
| 164 if (mc->last_trid == trid) { | |
| 165 return mc; | |
| 166 } | |
| 167 } | |
| 168 | |
| 169 conns = g_slist_next(conns); | |
| 170 } | |
| 171 | |
| 172 return NULL; | |
| 173 } | |
| 174 | |
| 1282 | 175 static char *msn_name() |
| 176 { | |
| 1259 | 177 return "MSN"; |
| 178 } | |
| 179 | |
| 1282 | 180 char *name() |
| 181 { | |
| 1259 | 182 return "MSN"; |
| 183 } | |
| 184 | |
| 1282 | 185 char *description() |
| 186 { | |
| 1259 | 187 return "Allows gaim to use the MSN protocol. For some reason, this frightens me."; |
| 188 } | |
| 189 | |
| 1567 | 190 time_t trId(struct msn_data *md) |
| 1282 | 191 { |
| 1567 | 192 md->last_trid = time((time_t *)NULL) + globalc++; |
| 193 return md->last_trid; | |
| 194 } | |
| 195 | |
| 196 void msn_write(int fd, char *buf) | |
| 197 { | |
| 198 write(fd, buf, strlen(buf)); | |
| 1585 | 199 printf("MSN(%d) <== %s", fd, buf); |
| 1567 | 200 } |
| 1259 | 201 |
| 1572 | 202 static void msn_answer_callback(gpointer data, gint source, GdkInputCondition condition) |
| 203 { | |
| 204 struct msn_conn *mc = data; | |
| 205 char buf[MSN_BUF_LEN]; | |
| 206 | |
| 207 fcntl(source, F_SETFL, 0); | |
| 208 | |
| 209 g_snprintf(buf, MSN_BUF_LEN, "ANS 1 %s %s %s\n", mc->gc->username, mc->secret, mc->session); | |
| 210 msn_write(mc->fd, buf); | |
| 211 | |
| 212 gdk_input_remove(mc->inpa); | |
| 213 mc->inpa = gdk_input_add(mc->fd, GDK_INPUT_READ, msn_callback, mc->gc); | |
| 214 | |
| 215 /* Append our connection */ | |
| 216 msn_connections = g_slist_append(msn_connections, mc); | |
| 217 } | |
| 218 | |
| 1584 | 219 static void msn_invite_callback(gpointer data, gint source, GdkInputCondition condition) |
| 220 { | |
| 221 struct msn_conn *mc = data; | |
| 222 struct msn_data *md = (struct msn_data *)mc->gc->proto_data; | |
| 223 char buf[MSN_BUF_LEN]; | |
| 224 struct gaim_connection *gc = mc->gc; | |
| 225 int i = 0; | |
| 1585 | 226 |
| 227 fcntl(source, F_SETFL, 0); | |
| 1584 | 228 |
| 229 if (condition == GDK_INPUT_WRITE) | |
| 230 { | |
| 231 /* We just got in here */ | |
| 232 gdk_input_remove(mc->inpa); | |
| 233 mc->inpa = gdk_input_add(mc->fd, GDK_INPUT_READ, msn_invite_callback, mc); | |
| 234 | |
| 235 /* Write our signon request */ | |
| 236 g_snprintf(buf, MSN_BUF_LEN, "USR %d %s %s\n", mc->last_trid, mc->gc->username, mc->secret); | |
| 1585 | 237 msn_write(mc->fd, buf); |
| 1584 | 238 return; |
| 239 } | |
| 240 | |
| 241 bzero(buf, MSN_BUF_LEN); | |
| 242 do | |
| 243 { | |
| 1588 | 244 if (!read(source, buf + i, 1)) |
| 1584 | 245 { |
| 1588 | 246 free_msn_conn(mc); |
| 1584 | 247 return; |
| 248 } | |
| 249 | |
| 250 } while (buf[i++] != '\n'); | |
| 251 | |
| 252 g_strchomp(buf); | |
| 253 | |
| 1628 | 254 printf("MSN(%d) ==> %s\n", source, buf); |
| 1584 | 255 |
| 256 if (!strncmp("USR ", buf, 4)) | |
| 257 { | |
| 258 char **res; | |
| 259 | |
| 260 res = g_strsplit(buf, " ", 0); | |
| 1585 | 261 printf("%s\n",res[2]); |
| 1584 | 262 if (strcasecmp("OK", res[2])) |
| 263 { | |
| 264 g_strfreev(res); | |
| 265 close(mc->fd); | |
| 266 return; | |
| 267 } | |
| 268 | |
| 269 /* We've authorized. Let's send an invite request */ | |
| 270 g_snprintf(buf, MSN_BUF_LEN, "CAL %d %s\n", trId(md), mc->user); | |
| 271 msn_write(source, buf); | |
| 272 return; | |
| 273 } | |
| 274 | |
| 275 else if (!strncmp("JOI ", buf, 4)) | |
| 276 { | |
| 277 /* Looks like they just joined! Write their queued message */ | |
| 278 g_snprintf(buf, MSN_BUF_LEN, "MSG %d N %d\r\n%s%s", trId(md), strlen(mc->txqueue) + strlen(MIME_HEADER), MIME_HEADER, mc->txqueue); | |
| 279 | |
| 280 msn_write(source, buf); | |
| 281 | |
| 282 gdk_input_remove(mc->inpa); | |
| 283 mc->inpa = gdk_input_add(mc->fd, GDK_INPUT_READ, msn_callback, mc->gc); | |
| 284 | |
| 285 return; | |
| 286 | |
| 287 } | |
| 288 } | |
| 289 | |
| 1567 | 290 static void msn_callback(gpointer data, gint source, GdkInputCondition condition) |
| 291 { | |
| 292 struct gaim_connection *gc = data; | |
| 293 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 294 char buf[MSN_BUF_LEN]; | |
| 295 int i = 0; | |
| 1572 | 296 int num; |
| 1259 | 297 |
| 1567 | 298 bzero(buf, MSN_BUF_LEN); |
| 299 | |
| 300 do | |
| 301 { | |
| 1588 | 302 if (!read(source, buf + i, 1)) |
| 1567 | 303 { |
| 1588 | 304 if (md->fd == source) |
| 305 { | |
| 306 hide_login_progress(gc, "Read error"); | |
| 307 signoff(gc); | |
| 308 } | |
| 309 | |
| 310 close(source); | |
| 311 | |
| 1567 | 312 return; |
| 1259 | 313 } |
| 314 | |
| 1567 | 315 } while (buf[i++] != '\n'); |
| 316 | |
| 317 g_strchomp(buf); | |
| 318 | |
| 1572 | 319 printf("MSN(%d) ==> %s\n", source, buf); |
| 1567 | 320 |
| 1569 | 321 if (!strncmp("NLN ", buf, 4) || !strncmp("ILN ", buf, 4)) |
| 322 { | |
| 323 int status; | |
| 324 int query; | |
| 325 char **res; | |
| 326 | |
| 327 res = g_strsplit(buf, " ", 0); | |
| 328 | |
| 329 if (!strcmp(res[0], "NLN")) | |
| 330 query = 1; | |
| 331 else | |
| 332 query = 2; | |
| 333 | |
| 334 if (!strcasecmp(res[query], "NLN")) | |
| 335 status = UC_NORMAL; | |
| 336 else if (!strcasecmp(res[query], "BSY")) | |
| 337 status = UC_NORMAL | (MSN_BUSY << 5); | |
| 338 else if (!strcasecmp(res[query], "IDL")) | |
| 339 status = UC_NORMAL | (MSN_IDLE << 5); | |
| 340 else if (!strcasecmp(res[query], "BRB")) | |
| 341 status = UC_NORMAL | (MSN_BRB << 5); | |
| 342 else if (!strcasecmp(res[query], "AWY")) | |
| 343 status = UC_UNAVAILABLE; | |
| 344 else if (!strcasecmp(res[query], "PHN")) | |
| 345 status = UC_NORMAL | (MSN_PHONE << 5); | |
| 346 else if (!strcasecmp(res[query], "LUN")) | |
| 347 status = UC_NORMAL | (MSN_LUNCH << 5); | |
| 348 else | |
| 349 status = UC_NORMAL; | |
| 350 | |
| 351 serv_got_update(gc, res[query+1], 1, 0, 0, 0, status, 0); | |
| 352 | |
| 353 g_strfreev(res); | |
| 354 | |
| 355 return; | |
| 356 | |
| 357 } | |
| 1628 | 358 else if (!strncmp("BYE ", buf, 4)) |
| 359 { | |
| 360 char **res; | |
| 361 struct msn_conn *mc; | |
| 362 | |
| 363 res = g_strsplit(buf, " ", 0); | |
| 364 | |
| 365 mc = find_msn_conn_by_user(res[1]); | |
| 366 | |
| 367 if (mc) | |
| 368 { | |
| 369 /* Looks like we need to close up some stuff :-) */ | |
| 370 free_msn_conn(mc); | |
| 371 } | |
| 372 | |
| 373 g_strfreev(res); | |
| 374 return; | |
| 375 } | |
| 1572 | 376 else if (!strncmp("MSG ", buf, 4)) |
| 377 { | |
| 378 /* We are receiving an incoming message */ | |
| 379 gchar **res; | |
| 380 gchar *user; | |
| 381 gchar *msgdata; | |
| 382 int size; | |
| 383 | |
| 384 res = g_strsplit(buf, " ", 0); | |
| 385 | |
| 386 user = g_strdup(res[1]); | |
| 387 size = atoi(res[3]); | |
| 388 | |
| 389 /* Ok, we know who we're receiving a message from as well as | |
| 390 * how big the message is */ | |
| 391 | |
| 392 msgdata = (gchar *)g_malloc(sizeof(gchar) *(size + 1)); | |
| 393 num = recv(source, msgdata, size, 0); | |
| 394 msgdata[size] = 0; | |
| 395 | |
| 396 if (num < size) | |
| 397 printf("MSN: Uhh .. we gots a problem!. Expected %d but got %d.\n", size, num); | |
| 398 | |
| 399 /* We should ignore messages from the user Hotmail */ | |
| 400 if (!strcasecmp("hotmail", res[1])) | |
| 401 { | |
| 402 g_strfreev(res); | |
| 403 g_free(msgdata); | |
| 404 return; | |
| 405 } | |
| 406 | |
| 407 /* Check to see if any body is in the message */ | |
| 408 if (!strcmp(strstr(msgdata, "\r\n\r\n") + 4, "\r\n")) | |
| 409 { | |
| 410 g_strfreev(res); | |
| 411 g_free(msgdata); | |
| 412 return; | |
| 413 } | |
| 414 | |
| 415 /* Otherwise, everything is ok. Let's show the message. Skipping, | |
| 416 * of course, the header. */ | |
| 417 | |
| 418 serv_got_im(gc, res[1], strstr(msgdata, "\r\n\r\n") + 4, 0); | |
| 419 | |
| 420 g_strfreev(res); | |
| 421 g_free(msgdata); | |
| 422 | |
| 423 return; | |
| 424 } | |
| 425 else if (!strncmp("RNG ", buf, 4)) | |
| 426 { | |
| 427 /* Ok, someone wants to talk to us. Ring ring? Hi!!! */ | |
| 428 gchar **address; | |
| 429 gchar **res; | |
| 430 struct msn_conn *mc = g_new0(struct msn_conn, 1); | |
| 431 | |
| 432 res = g_strsplit(buf, " ", 0); | |
| 433 address = g_strsplit(res[2], ":", 0); | |
| 434 | |
| 435 if (!(mc->fd = msn_connect(address[0], atoi(address[1])))) | |
| 436 { | |
| 437 /* Looks like we had an error connecting. */ | |
| 438 g_strfreev(address); | |
| 439 g_strfreev(res); | |
| 440 g_free(mc); | |
| 441 return; | |
| 442 } | |
| 443 | |
| 444 /* Set up our struct with user and input watcher */ | |
| 445 mc->user = g_strdup(res[5]); | |
| 446 mc->secret = g_strdup(res[4]); | |
| 447 mc->session = g_strdup(res[1]); | |
| 448 mc->gc = gc; | |
| 449 | |
| 450 mc->inpa = gdk_input_add(mc->fd, GDK_INPUT_WRITE, msn_answer_callback, mc); | |
| 451 | |
| 452 g_strfreev(address); | |
| 453 g_strfreev(res); | |
| 454 | |
| 455 return; | |
| 456 } | |
| 1584 | 457 else if (!strncmp("XFR ", buf, 4)) |
| 458 { | |
| 459 char **res; | |
| 460 char *host; | |
| 461 char *port; | |
| 462 struct msn_conn *mc; | |
| 463 | |
| 464 res = g_strsplit(buf, " ", 0); | |
| 465 | |
| 466 printf("Last trid is: %d\n", md->last_trid); | |
| 467 printf("This TrId is: %d\n", atoi(res[1])); | |
| 468 | |
| 469 mc = find_msn_conn_by_trid(atoi(res[1])); | |
| 470 | |
| 471 if (!mc) | |
| 472 { | |
| 473 g_strfreev(res); | |
| 474 return; | |
| 475 } | |
| 476 | |
| 477 strcpy(buf, res[3]); | |
| 478 | |
| 479 mc->secret = g_strdup(res[5]); | |
| 480 mc->session = g_strdup(res[1]); | |
| 481 | |
| 482 g_strfreev(res); | |
| 483 | |
| 484 res = g_strsplit(buf, ":", 0); | |
| 485 | |
| 486 /* Now we have the host and port */ | |
| 1585 | 487 if (!(mc->fd = msn_connect(res[0], atoi(res[1])))) |
| 1584 | 488 return; |
| 489 | |
| 490 printf("Connected to: %s:%s\n", res[0], res[1]); | |
| 491 | |
| 1585 | 492 if (mc->inpa) |
| 493 gdk_input_remove(mc->inpa); | |
| 494 | |
| 1584 | 495 mc->inpa = gdk_input_add(mc->fd, GDK_INPUT_WRITE, msn_invite_callback, mc); |
| 496 | |
| 497 g_strfreev(res); | |
| 498 | |
| 499 return; | |
| 500 } | |
| 1569 | 501 else if (!strncmp("LST ", buf, 4)) |
| 1567 | 502 { |
| 503 char **res; | |
| 504 | |
| 505 res = g_strsplit(buf, " ", 0); | |
| 506 | |
| 1568 | 507 /* If we have zero buddies, abort */ |
| 508 if (atoi(res[5]) == 0) | |
| 509 { | |
| 510 g_strfreev(res); | |
| 511 return; | |
| 512 } | |
| 513 | |
| 1567 | 514 /* First, let's check the list type */ |
| 515 if (!strcmp("FL", res[2])) | |
| 516 { | |
| 517 /* We're dealing with a forward list. Add them | |
| 518 * to our buddylist and continue along our | |
| 519 * merry little way */ | |
| 520 | |
| 521 struct buddy *b; | |
| 522 | |
| 523 b = find_buddy(gc, res[6]); | |
| 524 | |
| 525 if (!b) | |
| 526 add_buddy(gc, "Buddies", res[6], res[7]); | |
| 527 } | |
| 528 | |
| 529 g_strfreev(res); | |
| 530 | |
| 531 return; | |
| 1259 | 532 } |
| 1628 | 533 else if (!strncmp("FLN ", buf, 4)) |
| 534 { | |
| 535 /* Someone signed off */ | |
| 536 char **res; | |
| 537 | |
| 538 res = g_strsplit(buf, " ", 0); | |
| 539 | |
| 540 serv_got_update(gc, res[1], 0, 0, 0, 0, 0, 0); | |
| 541 | |
| 542 g_strfreev(res); | |
| 543 | |
| 544 return; | |
| 545 } | |
| 546 if ( (!strncmp("NLN ", buf, 4)) || (!strncmp("ILN ", buf, 4))) | |
| 547 { | |
| 548 int status; | |
| 549 int query; | |
| 550 char **res; | |
| 551 | |
| 552 res = g_strsplit(buf, " ", 0); | |
| 553 | |
| 554 if (strcasecmp(res[0], "NLN") == 0) | |
| 555 query = 1; | |
| 556 else | |
| 557 query = 2; | |
| 558 | |
| 559 if (!strcasecmp(res[query], "NLN")) | |
| 560 status = UC_NORMAL; | |
| 561 else if (!strcasecmp(res[query], "BSY")) | |
| 562 status = UC_NORMAL | (MSN_BUSY << 5); | |
| 563 else if (!strcasecmp(res[query], "IDL")) | |
| 564 status = UC_NORMAL | (MSN_IDLE << 5); | |
| 565 else if (!strcasecmp(res[query], "BRB")) | |
| 566 status = UC_NORMAL | (MSN_BRB << 5); | |
| 567 else if (!strcasecmp(res[query], "AWY")) | |
| 568 status = UC_UNAVAILABLE; | |
| 569 else if (!strcasecmp(res[query], "PHN")) | |
| 570 status = UC_NORMAL | (MSN_PHONE << 5); | |
| 571 else if (!strcasecmp(res[query], "LUN")) | |
| 572 status = UC_NORMAL | (MSN_LUNCH << 5); | |
| 573 else | |
| 574 status = UC_NORMAL; | |
| 575 | |
| 576 serv_got_update(gc, res[query+1], 1, 0, 0, 0, status, 0); | |
| 577 | |
| 578 g_strfreev(res); | |
| 579 return; | |
| 580 } | |
| 1259 | 581 |
| 582 } | |
| 583 | |
| 1567 | 584 static void msn_login_callback(gpointer data, gint source, GdkInputCondition condition) |
| 1282 | 585 { |
| 1567 | 586 struct gaim_connection *gc = data; |
| 587 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 588 char buf[MSN_BUF_LEN]; | |
| 1259 | 589 int i = 0; |
| 1282 | 590 |
| 1567 | 591 if (!gc->inpa) |
| 592 { | |
| 593 fcntl(source, F_SETFL, 0); | |
| 594 | |
| 595 gdk_input_remove(md->inpa); | |
| 596 md->inpa = 0; | |
| 597 | |
| 598 gc->inpa = gdk_input_add(md->fd, GDK_INPUT_READ, msn_login_callback, gc); | |
| 1307 | 599 |
| 1567 | 600 if (md->status & MSN_SIGNON_GOT_XFR) |
| 601 { | |
| 602 /* Looks like we were transfered here. Just send a sign on */ | |
| 603 set_login_progress(gc, 3, "Signing On"); | |
| 604 g_snprintf(buf, MSN_BUF_LEN, "USR %d %s I %s\n", md->last_trid, md->policy, gc->username); | |
| 605 msn_write(md->fd, buf); | |
| 606 | |
| 607 /* Reset this bit */ | |
| 608 md->status ^= MSN_SIGNON_GOT_XFR; | |
| 609 } | |
| 610 else | |
| 611 { | |
| 612 /* Otherwise, send an initial request */ | |
| 613 set_login_progress(gc, 2, "Verifiying"); | |
| 1259 | 614 |
| 1567 | 615 g_snprintf(md->protocol, 6, "MSNP2"); |
| 616 | |
| 617 g_snprintf(buf, MSN_BUF_LEN, "VER %d %s\n", trId(md), md->protocol); | |
| 618 msn_write(md->fd, buf); | |
| 619 } | |
| 620 | |
| 621 return; | |
| 622 } | |
| 623 | |
| 624 bzero(buf, MSN_BUF_LEN); | |
| 625 | |
| 626 do | |
| 627 { | |
| 1588 | 628 if (!read(source, buf + i, 1)) |
| 1567 | 629 { |
| 630 hide_login_progress(gc, "Read error"); | |
| 631 signoff(gc); | |
| 1259 | 632 return; |
| 1567 | 633 } |
| 1259 | 634 |
| 1567 | 635 } while (buf[i++] != '\n'); |
| 1259 | 636 |
| 637 g_strchomp(buf); | |
| 638 | |
| 1567 | 639 printf("MSN ==> %s\n", buf); |
| 640 | |
| 641 /* Check to see what was just sent back to us. We should be seeing a VER tag. */ | |
| 642 if (!strncmp("VER ", buf, 4) && (!strstr("MSNP2", buf))) | |
| 643 { | |
| 644 /* Now that we got our ver, we shoudl send a policy request */ | |
| 645 g_snprintf(buf, MSN_BUF_LEN, "INF %d\n", trId(md)); | |
| 646 msn_write(md->fd, buf); | |
| 647 | |
| 648 return; | |
| 649 } | |
| 650 else if (!strncmp("INF ", buf, 4)) | |
| 651 { | |
| 652 char **res; | |
| 653 | |
| 654 /* Make a copy of our resulting policy */ | |
| 655 res = g_strsplit(buf, " ", 0); | |
| 656 md->policy = g_strdup(res[2]); | |
| 657 | |
| 658 /* And send our signon packet */ | |
| 659 set_login_progress(gc, 3, "Signing On"); | |
| 660 | |
| 661 g_snprintf(buf, MSN_BUF_LEN, "USR %d %s I %s\n", trId(md), md->policy, gc->username); | |
| 662 msn_write(md->fd, buf); | |
| 663 | |
| 664 g_strfreev(res); | |
| 665 | |
| 666 return; | |
| 667 } | |
| 1598 | 668 else if (!strncmp("ADD ", buf, 4)) |
| 669 { | |
| 670 char **res; | |
| 671 | |
| 672 res = g_strsplit(buf, " ", 0); | |
| 673 | |
| 674 if (!strcasecmp(res[2], "RL")) | |
| 675 { | |
| 676 struct msn_ask_add_permit *ap = g_new0(struct msn_ask_add_permit, 1); | |
| 677 | |
| 678 snprintf(buf, MSN_BUF_LEN, "The user %s (%s) wants to add you to their buddylist.", res[4], res[5]); | |
| 679 | |
| 680 ap->user = g_strdup(res[4]); | |
| 681 ap->friendly = g_strdup(res[5]); | |
| 682 ap->gc = gc; | |
| 683 | |
| 684 do_ask_dialog(buf, ap, (GtkFunction) msn_accept_add_permit, (GtkFunction) msn_cancel_add_permit); | |
| 685 } | |
| 686 | |
| 687 g_strfreev(res); | |
| 688 return; | |
| 689 } | |
| 1589 | 690 |
| 1567 | 691 else if (!strncmp("XFR ", buf, 4)) |
| 692 { | |
| 693 char **res; | |
| 694 char *host; | |
| 695 char *port; | |
| 696 | |
| 697 res = g_strsplit(buf, " ", 0); | |
| 698 | |
| 699 strcpy(buf, res[3]); | |
| 700 | |
| 701 g_strfreev(res); | |
| 702 | |
| 703 res = g_strsplit(buf, ":", 0); | |
| 704 | |
| 705 close(md->fd); | |
| 706 | |
| 1603 | 707 set_login_progress(gc, 3, "Connecting to Auth"); |
| 1567 | 708 |
| 709 /* Now we have the host and port */ | |
| 710 if (!(md->fd = msn_connect(res[0], atoi(res[1])))) | |
| 711 { | |
| 712 hide_login_progress(gc, "Error connecting to server"); | |
| 713 signoff(gc); | |
| 714 return; | |
| 715 } | |
| 716 | |
| 717 g_strfreev(res); | |
| 718 | |
| 719 md->status |= MSN_SIGNON_GOT_XFR; | |
| 720 | |
| 721 gdk_input_remove(gc->inpa); | |
| 722 gc->inpa = 0; | |
| 723 | |
| 724 md->inpa = gdk_input_add(md->fd, GDK_INPUT_WRITE, msn_login_callback, gc); | |
| 725 | |
| 726 return; | |
| 727 } | |
| 728 else if (!strncmp("USR ", buf, 4)) | |
| 729 { | |
| 730 if (md->status & MSN_SIGNON_SENT_USR) | |
| 731 { | |
| 732 char **res; | |
| 733 | |
| 734 res = g_strsplit(buf, " ", 0); | |
| 735 | |
| 736 if (strcasecmp("OK", res[2])) | |
| 737 { | |
| 738 hide_login_progress(gc, "Error signing on"); | |
| 739 signoff(gc); | |
| 740 } | |
| 741 else | |
| 742 { | |
| 743 md->friendly = g_strdup(res[4]); | |
| 744 | |
| 745 /* Ok, ok. Your account is FINALLY online. Ya think Microsoft | |
| 746 * could have had any more steps involved? */ | |
| 747 | |
| 748 set_login_progress(gc, 4, "Fetching config"); | |
| 749 | |
| 750 /* Sync our buddylist */ | |
| 751 g_snprintf(buf, MSN_BUF_LEN, "SYN %d 0\n", trId(md)); | |
| 752 msn_write(md->fd, buf); | |
| 753 | |
| 754 /* And set ourselves online */ | |
| 755 g_snprintf(buf, MSN_BUF_LEN, "CHG %d NLN\n", trId(md)); | |
| 756 msn_write(md->fd, buf); | |
| 757 | |
| 758 account_online(gc); | |
| 759 serv_finish_login(gc); | |
| 760 | |
| 761 if (bud_list_cache_exists(gc)) | |
| 762 do_import(NULL, gc); | |
| 763 | |
| 764 gdk_input_remove(gc->inpa); | |
| 765 gc->inpa = gdk_input_add(md->fd, GDK_INPUT_READ, msn_callback, gc); | |
| 766 } | |
| 767 | |
| 768 g_strfreev(res); | |
| 769 } | |
| 770 else | |
| 771 { | |
| 772 char **res; | |
| 773 char buf2[MSN_BUF_LEN]; | |
| 774 int j; | |
| 775 md5_state_t st; | |
| 776 md5_byte_t di[16]; | |
| 777 | |
| 778 res = g_strsplit(buf, " ", 0); | |
| 779 | |
| 780 /* Make a copy of our MD5 Hash key */ | |
| 781 strcpy(buf, res[4]); | |
| 782 | |
| 783 /* Generate our secret with our key and password */ | |
| 784 snprintf(buf2, MSN_BUF_LEN, "%s%s", buf, gc->password); | |
| 785 | |
| 786 md5_init(&st); | |
| 787 md5_append(&st, (const md5_byte_t *)buf2, strlen(buf2)); | |
| 788 md5_finish(&st, di); | |
| 789 | |
| 790 /* Now that we have the MD5 Hash, lets' hex encode this bad boy. I smoke bad crack. */ | |
| 791 sprintf(buf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", | |
| 792 di[0],di[1],di[2],di[3],di[4],di[5],di[6],di[7],di[8],di[9],di[10],di[11],di[12], | |
| 793 di[13],di[14],di[15]); | |
| 794 | |
| 795 /* And now, send our final sign on packet */ | |
| 796 g_snprintf(buf2, MSN_BUF_LEN, "USR %s %s S %s\n", res[1], md->policy, buf); | |
| 797 msn_write(md->fd, buf2); | |
| 798 | |
| 799 md->status |= MSN_SIGNON_SENT_USR; | |
| 800 | |
| 801 g_strfreev(res); | |
| 802 } | |
| 803 | |
| 804 return; | |
| 805 } | |
| 1259 | 806 } |
| 807 | |
| 1282 | 808 int msn_connect(char *server, int port) |
| 809 { | |
| 1259 | 810 int fd; |
| 811 struct hostent *host; | |
| 812 struct sockaddr_in site; | |
| 813 | |
| 1567 | 814 if (!(host = gethostbyname(server))) |
| 815 { | |
| 816 printf("Could not resolve host name: %s\n", server); | |
| 1259 | 817 return -1; |
| 818 } | |
| 819 | |
| 1567 | 820 bzero(&site, sizeof(struct sockaddr_in)); |
| 821 site.sin_port = htons(port); | |
| 822 memcpy(&site.sin_addr, host->h_addr, host->h_length); | |
| 823 site.sin_family = host->h_addrtype; | |
| 1259 | 824 |
| 1567 | 825 fd = socket(host->h_addrtype, SOCK_STREAM, 0); |
| 1259 | 826 |
| 1567 | 827 fcntl(fd, F_SETFL, O_NONBLOCK); |
| 1259 | 828 |
| 1567 | 829 if (connect(fd, (struct sockaddr *)&site, sizeof(struct sockaddr_in)) < 0) |
| 830 { | |
| 831 if ((errno == EINPROGRESS) || (errno == EINTR)) | |
| 832 { | |
| 833 printf("Connection would block\n"); | |
| 834 return fd; | |
| 1259 | 835 } |
| 836 | |
| 1567 | 837 close(fd); |
| 838 fd = -1; | |
| 1259 | 839 } |
| 1567 | 840 |
| 841 return fd; | |
| 1259 | 842 } |
| 843 | |
| 1282 | 844 void msn_login(struct aim_user *user) |
| 845 { | |
| 1567 | 846 struct gaim_connection *gc = new_gaim_conn(user); |
| 847 struct msn_data *md = gc->proto_data = g_new0(struct msn_data, 1); | |
| 1282 | 848 |
| 1567 | 849 gc->inpa = 0; |
| 1282 | 850 |
| 851 set_login_progress(gc, 1, "Connecting"); | |
| 1259 | 852 |
| 853 while (gtk_events_pending()) | |
| 854 gtk_main_iteration(); | |
| 1567 | 855 |
| 1259 | 856 if (!g_slist_find(connections, gc)) |
| 857 return; | |
| 858 | |
| 1567 | 859 md->status = 0; |
| 1282 | 860 |
| 1567 | 861 if (!(md->fd = msn_connect("messenger.hotmail.com", 1863))) |
| 862 { | |
| 863 hide_login_progress(gc, "Error connecting to server"); | |
| 1259 | 864 signoff(gc); |
| 865 return; | |
| 866 } | |
| 867 | |
| 1567 | 868 md->inpa = gdk_input_add(md->fd, GDK_INPUT_WRITE, msn_login_callback, gc); |
| 1259 | 869 |
| 1567 | 870 printf("Connected.\n"); |
| 1284 | 871 } |
| 872 | |
| 1584 | 873 void msn_send_im(struct gaim_connection *gc, char *who, char *message, int away) |
| 874 { | |
| 875 struct msn_conn *mc; | |
| 876 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 877 char buf[MSN_BUF_LEN]; | |
| 878 | |
| 879 if (!g_strcasecmp(who, gc->username)) | |
| 880 { | |
| 881 do_error_dialog("You can not send a message to yourself!", "Gaim: MSN Error"); | |
| 882 return; | |
| 883 } | |
| 884 | |
| 885 mc = find_msn_conn_by_user(who); | |
| 886 | |
| 887 /* If we're not already in a conversation with | |
| 888 * this person then we have to do some tricky things. */ | |
| 889 | |
| 890 if (!mc) | |
| 891 { | |
| 892 gchar buf2[MSN_BUF_LEN]; | |
| 893 gchar *address; | |
| 894 gchar *auth; | |
| 895 gchar **res; | |
| 896 | |
| 897 /* Request a new switchboard connection */ | |
| 898 g_snprintf(buf, MSN_BUF_LEN, "XFR %d SB\n", trId(md)); | |
| 899 msn_write(md->fd, buf); | |
| 900 | |
| 901 mc = g_new0(struct msn_conn, 1); | |
| 902 | |
| 903 mc->user = g_strdup(who); | |
| 904 mc->gc = gc; | |
| 905 mc->last_trid = md->last_trid; | |
| 906 mc->txqueue = g_strdup(message); | |
| 907 | |
| 908 /* Append our connection */ | |
| 909 msn_connections = g_slist_append(msn_connections, mc); | |
| 910 } | |
| 1585 | 911 else |
| 912 { | |
| 1598 | 913 g_snprintf(buf, MSN_BUF_LEN, "MSG %d N %d\r\n%s%s", trId(md), |
| 914 strlen(message) + strlen(MIME_HEADER), MIME_HEADER, message); | |
| 1585 | 915 |
| 916 msn_write(mc->fd, buf); | |
| 917 } | |
| 1584 | 918 |
| 919 } | |
| 920 | |
| 1598 | 921 static void msn_add_buddy(struct gaim_connection *gc, char *who) |
| 922 { | |
| 923 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 924 char buf[MSN_BUF_LEN - 1]; | |
| 925 | |
| 926 snprintf(buf, MSN_BUF_LEN, "ADD %d FL %s %s\n", trId(md), who, who); | |
| 927 msn_write(md->fd, buf); | |
| 928 } | |
| 929 | |
| 930 static void msn_remove_buddy(struct gaim_connection *gc, char *who) | |
| 931 { | |
| 932 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 933 char buf[MSN_BUF_LEN - 1]; | |
| 934 | |
| 935 snprintf(buf, MSN_BUF_LEN, "REM %d FL %s\n", trId(md), who); | |
| 936 msn_write(md->fd, buf); | |
| 937 } | |
| 938 | |
| 939 static void msn_rem_permit(struct gaim_connection *gc, char *who) | |
| 940 { | |
| 941 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 942 char buf[MSN_BUF_LEN - 1]; | |
| 943 | |
| 944 snprintf(buf, MSN_BUF_LEN, "REM %d AL %s\n", trId(md), who); | |
| 945 msn_write(md->fd, buf); | |
| 946 } | |
| 947 | |
| 948 static void msn_add_permit(struct gaim_connection *gc, char *who) | |
| 949 { | |
| 950 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 951 char buf[MSN_BUF_LEN - 1]; | |
| 952 | |
| 953 snprintf(buf, MSN_BUF_LEN, "ADD %d AL %s %s\n", trId(md), who, who); | |
| 954 msn_write(md->fd, buf); | |
| 955 } | |
| 956 | |
| 957 static void msn_rem_deny(struct gaim_connection *gc, char *who) | |
| 958 { | |
| 959 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 960 char buf[MSN_BUF_LEN - 1]; | |
| 961 | |
| 962 snprintf(buf, MSN_BUF_LEN, "REM %d BL %s\n", trId(md), who); | |
| 963 msn_write(md->fd, buf); | |
| 964 } | |
| 965 | |
| 966 static void msn_add_deny(struct gaim_connection *gc, char *who) | |
| 967 { | |
| 968 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 969 char buf[MSN_BUF_LEN - 1]; | |
| 970 | |
| 971 snprintf(buf, MSN_BUF_LEN, "ADD %d BL %s %s\n", trId(md), who, who); | |
| 972 msn_write(md->fd, buf); | |
| 973 } | |
| 974 | |
| 1630 | 975 static GList *msn_away_states() |
| 976 { | |
| 977 GList *m = NULL; | |
| 978 | |
| 979 m = g_list_append(m, "Available"); | |
| 980 m = g_list_append(m, "Away From Computer"); | |
| 981 m = g_list_append(m, "Be Right Back"); | |
| 982 m = g_list_append(m, "Busy"); | |
| 983 m = g_list_append(m, "On The Phone"); | |
| 984 m = g_list_append(m, "Out To Lunch"); | |
| 985 | |
| 986 return m; | |
| 987 } | |
| 988 | |
| 1600 | 989 static void msn_set_away(struct gaim_connection *gc, char *state, char *msg) |
| 990 { | |
| 991 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 992 char buf[MSN_BUF_LEN - 1]; | |
| 993 | |
| 1630 | 994 |
| 995 gc->away = NULL; | |
| 996 | |
| 1600 | 997 if (msg) |
| 1630 | 998 { |
| 999 gc->away = ""; | |
| 1600 | 1000 snprintf(buf, MSN_BUF_LEN, "CHG %d AWY\n", trId(md)); |
| 1630 | 1001 } |
| 1002 | |
| 1003 else if (state) | |
| 1004 { | |
| 1005 char away[4]; | |
| 1006 | |
| 1007 gc->away = ""; | |
| 1008 | |
| 1009 if (!strcmp(state, "Available")) | |
| 1010 sprintf(away, "NLN"); | |
| 1011 else if (!strcmp(state, "Away From Computer")) | |
| 1012 sprintf(away, "AWY"); | |
| 1013 else if (!strcmp(state, "Be Right Back")) | |
| 1014 sprintf(away, "BRB"); | |
| 1015 else if (!strcmp(state, "Busy")) | |
| 1016 sprintf(away, "BSY"); | |
| 1017 else if (!strcmp(state, "On The Phone")) | |
| 1018 sprintf(away, "PHN"); | |
| 1019 else if (!strcmp(state, "Out To Lunch")) | |
| 1020 sprintf(away, "LUN"); | |
| 1021 else | |
| 1022 sprintf(away, "NLN"); | |
| 1023 | |
| 1024 snprintf(buf, MSN_BUF_LEN, "CHG %d %s\n", trId(md), away); | |
| 1025 } | |
| 1600 | 1026 else if (gc->is_idle) |
| 1027 snprintf(buf, MSN_BUF_LEN, "CHG %d IDL\n", trId(md)); | |
| 1028 else | |
| 1029 snprintf(buf, MSN_BUF_LEN, "CHG %d NLN\n", trId(md)); | |
| 1030 | |
| 1031 msn_write(md->fd, buf); | |
| 1032 } | |
| 1033 | |
| 1034 | |
| 1035 static void msn_set_idle(struct gaim_connection *gc, int idle) | |
| 1036 { | |
| 1037 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 1038 char buf[MSN_BUF_LEN - 1]; | |
| 1039 | |
| 1040 if (idle) | |
| 1041 snprintf(buf, MSN_BUF_LEN, "CHG %d IDL\n", trId(md)); | |
| 1042 else | |
| 1043 snprintf(buf, MSN_BUF_LEN, "CHG %d NLN\n", trId(md)); | |
| 1044 | |
| 1045 msn_write(md->fd, buf); | |
| 1046 } | |
| 1047 | |
| 1048 static void msn_close(struct gaim_connection *gc) | |
| 1049 { | |
| 1050 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 1051 char buf[MSN_BUF_LEN - 1]; | |
| 1052 struct msn_conn *mc = NULL; | |
| 1053 | |
| 1054 while (msn_connections) | |
| 1055 { | |
| 1056 mc = (struct msn_conn *)msn_connections->data; | |
| 1057 | |
| 1058 free_msn_conn(mc); | |
| 1059 } | |
| 1060 | |
| 1061 if (md->fd) | |
| 1062 { | |
| 1063 snprintf(buf, MSN_BUF_LEN, "OUT\n"); | |
| 1064 msn_write(md->fd, buf); | |
| 1065 close(md->fd); | |
| 1066 } | |
| 1067 | |
| 1068 if (gc->inpa) | |
| 1069 gdk_input_remove(gc->inpa); | |
| 1070 | |
| 1071 if (md->friendly) | |
| 1072 free(md->friendly); | |
| 1073 | |
| 1074 g_free(gc->proto_data); | |
| 1075 } | |
| 1076 | |
| 1639 | 1077 static char *msn_get_away_text(int s) |
| 1078 { | |
| 1079 switch (s) | |
| 1080 { | |
| 1081 case MSN_BUSY : | |
| 1082 return "Busy"; | |
| 1083 case MSN_BRB : | |
| 1084 return "Be right back"; | |
| 1085 case MSN_AWAY : | |
| 1086 return "Away from the computer"; | |
| 1087 case MSN_PHONE : | |
| 1088 return "On the phone"; | |
| 1089 case MSN_LUNCH : | |
| 1090 return "Out to lunch"; | |
| 1640 | 1091 case MSN_IDLE : |
| 1092 return "Idle"; | |
| 1639 | 1093 default: |
| 1094 return NULL; | |
| 1095 } | |
| 1096 } | |
| 1097 | |
| 1098 static void msn_buddy_menu(GtkWidget *menu, struct gaim_connection *gc, char *who) | |
| 1099 { | |
| 1100 struct buddy *b = find_buddy(gc, who); | |
| 1101 char buf[MSN_BUF_LEN]; | |
| 1102 GtkWidget *button; | |
| 1103 | |
| 1104 if (!(b->uc >> 5)) | |
| 1105 return; | |
| 1106 | |
| 1107 g_snprintf(buf, MSN_BUF_LEN, "Status: %s", msn_get_away_text(b->uc >> 5)); | |
| 1108 | |
| 1109 button = gtk_menu_item_new_with_label(buf); | |
| 1110 gtk_menu_append(GTK_MENU(menu), button); | |
| 1111 gtk_widget_show(button); | |
| 1112 } | |
| 1113 | |
| 1572 | 1114 static char **msn_list_icon(int uc) |
| 1115 { | |
| 1116 if (uc == UC_UNAVAILABLE) | |
| 1117 return msn_away_xpm; | |
| 1118 else if (uc == UC_NORMAL) | |
| 1119 return msn_online_xpm; | |
| 1120 | |
| 1631 | 1121 return msn_away_xpm; |
| 1572 | 1122 } |
| 1123 | |
| 1259 | 1124 static struct prpl *my_protocol = NULL; |
| 1125 | |
| 1282 | 1126 void msn_init(struct prpl *ret) |
| 1127 { | |
| 1259 | 1128 ret->protocol = PROTO_MSN; |
| 1129 ret->name = msn_name; | |
| 1572 | 1130 ret->list_icon = msn_list_icon; |
| 1639 | 1131 ret->buddy_menu = msn_buddy_menu; |
| 1259 | 1132 ret->user_opts = NULL; |
| 1133 ret->login = msn_login; | |
| 1600 | 1134 ret->close = msn_close; |
| 1584 | 1135 ret->send_im = msn_send_im; |
| 1259 | 1136 ret->set_info = NULL; |
| 1137 ret->get_info = NULL; | |
| 1630 | 1138 ret->away_states = msn_away_states; |
| 1600 | 1139 ret->set_away = msn_set_away; |
| 1259 | 1140 ret->get_away_msg = NULL; |
| 1141 ret->set_dir = NULL; | |
| 1142 ret->get_dir = NULL; | |
| 1143 ret->dir_search = NULL; | |
| 1600 | 1144 ret->set_idle = msn_set_idle; |
| 1259 | 1145 ret->change_passwd = NULL; |
| 1598 | 1146 ret->add_buddy = msn_add_buddy; |
| 1259 | 1147 ret->add_buddies = NULL; |
| 1598 | 1148 ret->remove_buddy = msn_remove_buddy; |
| 1149 ret->add_permit = msn_add_permit; | |
| 1150 ret->rem_permit = msn_rem_permit; | |
| 1151 ret->add_deny = msn_add_deny; | |
| 1152 ret->rem_deny = msn_rem_deny; | |
| 1259 | 1153 ret->warn = NULL; |
| 1154 ret->accept_chat = NULL; | |
| 1155 ret->join_chat = NULL; | |
| 1156 ret->chat_invite = NULL; | |
| 1157 ret->chat_leave = NULL; | |
| 1158 ret->chat_whisper = NULL; | |
| 1159 ret->chat_send = NULL; | |
| 1160 ret->keepalive = NULL; | |
| 1161 | |
| 1162 my_protocol = ret; | |
| 1163 } | |
| 1164 | |
| 1282 | 1165 char *gaim_plugin_init(GModule * handle) |
| 1166 { | |
|
1443
336fc98b7f90
[gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1327
diff
changeset
|
1167 load_protocol(msn_init, sizeof(struct prpl)); |
| 1259 | 1168 return NULL; |
| 1169 } | |
| 1170 | |
| 1282 | 1171 void gaim_plugin_remove() |
| 1172 { | |
| 1259 | 1173 struct prpl *p = find_prpl(PROTO_MSN); |
| 1174 if (p == my_protocol) | |
| 1175 unload_protocol(p); | |
| 1176 } |
