Mercurial > pidgin
annotate plugins/msn/msn.c @ 1572:d60672672a13
[gaim-migrate @ 1582]
Users can receive messages and stuff.
committer: Tailor Script <tailor@pidgin.im>
| author | Rob Flynn <gaim@robflynn.com> |
|---|---|
| date | Thu, 15 Mar 2001 08:38:16 +0000 |
| parents | 446536be85dd |
| children | 30a4ecea466a |
| 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 |
| 63 struct msn_data { | |
| 64 int fd; | |
| 65 | |
| 66 char protocol[6]; | |
| 67 char *friendly; | |
| 68 gchar *policy; | |
| 1567 | 69 int inpa; |
| 70 int status; | |
| 71 time_t last_trid; | |
| 1259 | 72 }; |
| 73 | |
| 74 struct msn_conn { | |
| 75 gchar *user; | |
| 76 int inpa; | |
| 77 int fd; | |
| 1572 | 78 struct gaim_connection *gc; |
| 79 char *secret; | |
| 80 char *session; | |
| 1259 | 81 }; |
| 82 | |
| 1567 | 83 GSList *msn_connections = NULL; |
| 1259 | 84 |
| 1567 | 85 unsigned long long globalc = 0; |
| 1572 | 86 static void msn_callback(gpointer data, gint source, GdkInputCondition condition); |
| 1259 | 87 |
| 1282 | 88 static char *msn_name() |
| 89 { | |
| 1259 | 90 return "MSN"; |
| 91 } | |
| 92 | |
| 1282 | 93 char *name() |
| 94 { | |
| 1259 | 95 return "MSN"; |
| 96 } | |
| 97 | |
| 1282 | 98 char *description() |
| 99 { | |
| 1259 | 100 return "Allows gaim to use the MSN protocol. For some reason, this frightens me."; |
| 101 } | |
| 102 | |
| 1567 | 103 time_t trId(struct msn_data *md) |
| 1282 | 104 { |
| 1567 | 105 md->last_trid = time((time_t *)NULL) + globalc++; |
| 106 return md->last_trid; | |
| 107 } | |
| 108 | |
| 109 void msn_write(int fd, char *buf) | |
| 110 { | |
| 111 write(fd, buf, strlen(buf)); | |
| 112 printf("MSN <== %s", buf); | |
| 113 } | |
| 1259 | 114 |
| 1572 | 115 static void msn_answer_callback(gpointer data, gint source, GdkInputCondition condition) |
| 116 { | |
| 117 struct msn_conn *mc = data; | |
| 118 char buf[MSN_BUF_LEN]; | |
| 119 | |
| 120 fcntl(source, F_SETFL, 0); | |
| 121 | |
| 122 g_snprintf(buf, MSN_BUF_LEN, "ANS 1 %s %s %s\n", mc->gc->username, mc->secret, mc->session); | |
| 123 msn_write(mc->fd, buf); | |
| 124 | |
| 125 gdk_input_remove(mc->inpa); | |
| 126 mc->inpa = gdk_input_add(mc->fd, GDK_INPUT_READ, msn_callback, mc->gc); | |
| 127 | |
| 128 /* Append our connection */ | |
| 129 msn_connections = g_slist_append(msn_connections, mc); | |
| 130 } | |
| 131 | |
| 1567 | 132 static void msn_callback(gpointer data, gint source, GdkInputCondition condition) |
| 133 { | |
| 134 struct gaim_connection *gc = data; | |
| 135 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 136 char buf[MSN_BUF_LEN]; | |
| 137 int i = 0; | |
| 1572 | 138 int num; |
| 1259 | 139 |
| 1567 | 140 bzero(buf, MSN_BUF_LEN); |
| 141 | |
| 142 do | |
| 143 { | |
| 144 if (read(source, buf + i, 1) < 0) | |
| 145 { | |
| 146 hide_login_progress(gc, "Read error"); | |
| 147 signoff(gc); | |
| 148 return; | |
| 1259 | 149 } |
| 150 | |
| 1567 | 151 } while (buf[i++] != '\n'); |
| 152 | |
| 153 g_strchomp(buf); | |
| 154 | |
| 1572 | 155 printf("MSN(%d) ==> %s\n", source, buf); |
| 1567 | 156 |
| 1569 | 157 if (!strncmp("NLN ", buf, 4) || !strncmp("ILN ", buf, 4)) |
| 158 { | |
| 159 int status; | |
| 160 int query; | |
| 161 char **res; | |
| 162 | |
| 163 res = g_strsplit(buf, " ", 0); | |
| 164 | |
| 165 if (!strcmp(res[0], "NLN")) | |
| 166 query = 1; | |
| 167 else | |
| 168 query = 2; | |
| 169 | |
| 170 if (!strcasecmp(res[query], "NLN")) | |
| 171 status = UC_NORMAL; | |
| 172 else if (!strcasecmp(res[query], "BSY")) | |
| 173 status = UC_NORMAL | (MSN_BUSY << 5); | |
| 174 else if (!strcasecmp(res[query], "IDL")) | |
| 175 status = UC_NORMAL | (MSN_IDLE << 5); | |
| 176 else if (!strcasecmp(res[query], "BRB")) | |
| 177 status = UC_NORMAL | (MSN_BRB << 5); | |
| 178 else if (!strcasecmp(res[query], "AWY")) | |
| 179 status = UC_UNAVAILABLE; | |
| 180 else if (!strcasecmp(res[query], "PHN")) | |
| 181 status = UC_NORMAL | (MSN_PHONE << 5); | |
| 182 else if (!strcasecmp(res[query], "LUN")) | |
| 183 status = UC_NORMAL | (MSN_LUNCH << 5); | |
| 184 else | |
| 185 status = UC_NORMAL; | |
| 186 | |
| 187 serv_got_update(gc, res[query+1], 1, 0, 0, 0, status, 0); | |
| 188 | |
| 189 g_strfreev(res); | |
| 190 | |
| 191 return; | |
| 192 | |
| 193 } | |
| 1572 | 194 else if (!strncmp("MSG ", buf, 4)) |
| 195 { | |
| 196 /* We are receiving an incoming message */ | |
| 197 gchar **res; | |
| 198 gchar *user; | |
| 199 gchar *msgdata; | |
| 200 int size; | |
| 201 | |
| 202 res = g_strsplit(buf, " ", 0); | |
| 203 | |
| 204 user = g_strdup(res[1]); | |
| 205 size = atoi(res[3]); | |
| 206 | |
| 207 /* Ok, we know who we're receiving a message from as well as | |
| 208 * how big the message is */ | |
| 209 | |
| 210 msgdata = (gchar *)g_malloc(sizeof(gchar) *(size + 1)); | |
| 211 num = recv(source, msgdata, size, 0); | |
| 212 msgdata[size] = 0; | |
| 213 | |
| 214 if (num < size) | |
| 215 printf("MSN: Uhh .. we gots a problem!. Expected %d but got %d.\n", size, num); | |
| 216 | |
| 217 /* We should ignore messages from the user Hotmail */ | |
| 218 if (!strcasecmp("hotmail", res[1])) | |
| 219 { | |
| 220 g_strfreev(res); | |
| 221 g_free(msgdata); | |
| 222 return; | |
| 223 } | |
| 224 | |
| 225 /* Check to see if any body is in the message */ | |
| 226 if (!strcmp(strstr(msgdata, "\r\n\r\n") + 4, "\r\n")) | |
| 227 { | |
| 228 g_strfreev(res); | |
| 229 g_free(msgdata); | |
| 230 return; | |
| 231 } | |
| 232 | |
| 233 /* Otherwise, everything is ok. Let's show the message. Skipping, | |
| 234 * of course, the header. */ | |
| 235 | |
| 236 serv_got_im(gc, res[1], strstr(msgdata, "\r\n\r\n") + 4, 0); | |
| 237 | |
| 238 g_strfreev(res); | |
| 239 g_free(msgdata); | |
| 240 | |
| 241 return; | |
| 242 } | |
| 243 else if (!strncmp("RNG ", buf, 4)) | |
| 244 { | |
| 245 /* Ok, someone wants to talk to us. Ring ring? Hi!!! */ | |
| 246 gchar **address; | |
| 247 gchar **res; | |
| 248 struct msn_conn *mc = g_new0(struct msn_conn, 1); | |
| 249 | |
| 250 res = g_strsplit(buf, " ", 0); | |
| 251 address = g_strsplit(res[2], ":", 0); | |
| 252 | |
| 253 if (!(mc->fd = msn_connect(address[0], atoi(address[1])))) | |
| 254 { | |
| 255 /* Looks like we had an error connecting. */ | |
| 256 g_strfreev(address); | |
| 257 g_strfreev(res); | |
| 258 g_free(mc); | |
| 259 return; | |
| 260 } | |
| 261 | |
| 262 /* Set up our struct with user and input watcher */ | |
| 263 mc->user = g_strdup(res[5]); | |
| 264 mc->secret = g_strdup(res[4]); | |
| 265 mc->session = g_strdup(res[1]); | |
| 266 mc->gc = gc; | |
| 267 | |
| 268 mc->inpa = gdk_input_add(mc->fd, GDK_INPUT_WRITE, msn_answer_callback, mc); | |
| 269 | |
| 270 g_strfreev(address); | |
| 271 g_strfreev(res); | |
| 272 | |
| 273 return; | |
| 274 } | |
| 1569 | 275 else if (!strncmp("LST ", buf, 4)) |
| 1567 | 276 { |
| 277 char **res; | |
| 278 | |
| 279 res = g_strsplit(buf, " ", 0); | |
| 280 | |
| 1568 | 281 /* If we have zero buddies, abort */ |
| 282 if (atoi(res[5]) == 0) | |
| 283 { | |
| 284 g_strfreev(res); | |
| 285 return; | |
| 286 } | |
| 287 | |
| 1567 | 288 /* First, let's check the list type */ |
| 289 if (!strcmp("FL", res[2])) | |
| 290 { | |
| 291 /* We're dealing with a forward list. Add them | |
| 292 * to our buddylist and continue along our | |
| 293 * merry little way */ | |
| 294 | |
| 295 struct buddy *b; | |
| 296 | |
| 297 b = find_buddy(gc, res[6]); | |
| 298 | |
| 299 if (!b) | |
| 300 add_buddy(gc, "Buddies", res[6], res[7]); | |
| 301 } | |
| 302 | |
| 303 g_strfreev(res); | |
| 304 | |
| 305 return; | |
| 1259 | 306 } |
| 307 | |
| 308 } | |
| 309 | |
| 1567 | 310 static void msn_login_callback(gpointer data, gint source, GdkInputCondition condition) |
| 1282 | 311 { |
| 1567 | 312 struct gaim_connection *gc = data; |
| 313 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
| 314 char buf[MSN_BUF_LEN]; | |
| 1259 | 315 int i = 0; |
| 1282 | 316 |
| 1567 | 317 if (!gc->inpa) |
| 318 { | |
| 319 fcntl(source, F_SETFL, 0); | |
| 320 | |
| 321 gdk_input_remove(md->inpa); | |
| 322 md->inpa = 0; | |
| 323 | |
| 324 gc->inpa = gdk_input_add(md->fd, GDK_INPUT_READ, msn_login_callback, gc); | |
| 1307 | 325 |
| 1567 | 326 if (md->status & MSN_SIGNON_GOT_XFR) |
| 327 { | |
| 328 /* Looks like we were transfered here. Just send a sign on */ | |
| 329 set_login_progress(gc, 3, "Signing On"); | |
| 330 g_snprintf(buf, MSN_BUF_LEN, "USR %d %s I %s\n", md->last_trid, md->policy, gc->username); | |
| 331 msn_write(md->fd, buf); | |
| 332 | |
| 333 /* Reset this bit */ | |
| 334 md->status ^= MSN_SIGNON_GOT_XFR; | |
| 335 } | |
| 336 else | |
| 337 { | |
| 338 /* Otherwise, send an initial request */ | |
| 339 set_login_progress(gc, 2, "Verifiying"); | |
| 1259 | 340 |
| 1567 | 341 g_snprintf(md->protocol, 6, "MSNP2"); |
| 342 | |
| 343 g_snprintf(buf, MSN_BUF_LEN, "VER %d %s\n", trId(md), md->protocol); | |
| 344 msn_write(md->fd, buf); | |
| 345 } | |
| 346 | |
| 347 return; | |
| 348 } | |
| 349 | |
| 350 bzero(buf, MSN_BUF_LEN); | |
| 351 | |
| 352 do | |
| 353 { | |
| 354 if (read(source, buf + i, 1) < 0) | |
| 355 { | |
| 356 hide_login_progress(gc, "Read error"); | |
| 357 signoff(gc); | |
| 1259 | 358 return; |
| 1567 | 359 } |
| 1259 | 360 |
| 1567 | 361 } while (buf[i++] != '\n'); |
| 1259 | 362 |
| 363 g_strchomp(buf); | |
| 364 | |
| 1567 | 365 printf("MSN ==> %s\n", buf); |
| 366 | |
| 367 /* Check to see what was just sent back to us. We should be seeing a VER tag. */ | |
| 368 if (!strncmp("VER ", buf, 4) && (!strstr("MSNP2", buf))) | |
| 369 { | |
| 370 /* Now that we got our ver, we shoudl send a policy request */ | |
| 371 g_snprintf(buf, MSN_BUF_LEN, "INF %d\n", trId(md)); | |
| 372 msn_write(md->fd, buf); | |
| 373 | |
| 374 return; | |
| 375 } | |
| 376 else if (!strncmp("INF ", buf, 4)) | |
| 377 { | |
| 378 char **res; | |
| 379 | |
| 380 /* Make a copy of our resulting policy */ | |
| 381 res = g_strsplit(buf, " ", 0); | |
| 382 md->policy = g_strdup(res[2]); | |
| 383 | |
| 384 /* And send our signon packet */ | |
| 385 set_login_progress(gc, 3, "Signing On"); | |
| 386 | |
| 387 g_snprintf(buf, MSN_BUF_LEN, "USR %d %s I %s\n", trId(md), md->policy, gc->username); | |
| 388 msn_write(md->fd, buf); | |
| 389 | |
| 390 g_strfreev(res); | |
| 391 | |
| 392 return; | |
| 393 } | |
| 394 else if (!strncmp("XFR ", buf, 4)) | |
| 395 { | |
| 396 char **res; | |
| 397 char *host; | |
| 398 char *port; | |
| 399 | |
| 400 res = g_strsplit(buf, " ", 0); | |
| 401 | |
| 402 strcpy(buf, res[3]); | |
| 403 | |
| 404 g_strfreev(res); | |
| 405 | |
| 406 res = g_strsplit(buf, ":", 0); | |
| 407 | |
| 408 close(md->fd); | |
| 409 | |
| 410 set_login_progress(gc, 1, "Connecting"); | |
| 411 | |
| 412 /* Now we have the host and port */ | |
| 413 if (!(md->fd = msn_connect(res[0], atoi(res[1])))) | |
| 414 { | |
| 415 hide_login_progress(gc, "Error connecting to server"); | |
| 416 signoff(gc); | |
| 417 return; | |
| 418 } | |
| 419 | |
| 420 g_strfreev(res); | |
| 421 | |
| 422 md->status |= MSN_SIGNON_GOT_XFR; | |
| 423 | |
| 424 gdk_input_remove(gc->inpa); | |
| 425 gc->inpa = 0; | |
| 426 | |
| 427 md->inpa = gdk_input_add(md->fd, GDK_INPUT_WRITE, msn_login_callback, gc); | |
| 428 | |
| 429 return; | |
| 430 } | |
| 431 else if (!strncmp("USR ", buf, 4)) | |
| 432 { | |
| 433 if (md->status & MSN_SIGNON_SENT_USR) | |
| 434 { | |
| 435 char **res; | |
| 436 | |
| 437 res = g_strsplit(buf, " ", 0); | |
| 438 | |
| 439 if (strcasecmp("OK", res[2])) | |
| 440 { | |
| 441 hide_login_progress(gc, "Error signing on"); | |
| 442 signoff(gc); | |
| 443 } | |
| 444 else | |
| 445 { | |
| 446 md->friendly = g_strdup(res[4]); | |
| 447 | |
| 448 /* Ok, ok. Your account is FINALLY online. Ya think Microsoft | |
| 449 * could have had any more steps involved? */ | |
| 450 | |
| 451 set_login_progress(gc, 4, "Fetching config"); | |
| 452 | |
| 453 /* Sync our buddylist */ | |
| 454 g_snprintf(buf, MSN_BUF_LEN, "SYN %d 0\n", trId(md)); | |
| 455 msn_write(md->fd, buf); | |
| 456 | |
| 457 /* And set ourselves online */ | |
| 458 g_snprintf(buf, MSN_BUF_LEN, "CHG %d NLN\n", trId(md)); | |
| 459 msn_write(md->fd, buf); | |
| 460 | |
| 461 account_online(gc); | |
| 462 serv_finish_login(gc); | |
| 463 | |
| 464 if (bud_list_cache_exists(gc)) | |
| 465 do_import(NULL, gc); | |
| 466 | |
| 467 gdk_input_remove(gc->inpa); | |
| 468 gc->inpa = gdk_input_add(md->fd, GDK_INPUT_READ, msn_callback, gc); | |
| 469 } | |
| 470 | |
| 471 g_strfreev(res); | |
| 472 } | |
| 473 else | |
| 474 { | |
| 475 char **res; | |
| 476 char buf2[MSN_BUF_LEN]; | |
| 477 int j; | |
| 478 md5_state_t st; | |
| 479 md5_byte_t di[16]; | |
| 480 | |
| 481 res = g_strsplit(buf, " ", 0); | |
| 482 | |
| 483 /* Make a copy of our MD5 Hash key */ | |
| 484 strcpy(buf, res[4]); | |
| 485 | |
| 486 /* Generate our secret with our key and password */ | |
| 487 snprintf(buf2, MSN_BUF_LEN, "%s%s", buf, gc->password); | |
| 488 | |
| 489 md5_init(&st); | |
| 490 md5_append(&st, (const md5_byte_t *)buf2, strlen(buf2)); | |
| 491 md5_finish(&st, di); | |
| 492 | |
| 493 /* Now that we have the MD5 Hash, lets' hex encode this bad boy. I smoke bad crack. */ | |
| 494 sprintf(buf, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", | |
| 495 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], | |
| 496 di[13],di[14],di[15]); | |
| 497 | |
| 498 /* And now, send our final sign on packet */ | |
| 499 g_snprintf(buf2, MSN_BUF_LEN, "USR %s %s S %s\n", res[1], md->policy, buf); | |
| 500 msn_write(md->fd, buf2); | |
| 501 | |
| 502 md->status |= MSN_SIGNON_SENT_USR; | |
| 503 | |
| 504 g_strfreev(res); | |
| 505 } | |
| 506 | |
| 507 return; | |
| 508 } | |
| 1259 | 509 } |
| 510 | |
| 1282 | 511 int msn_connect(char *server, int port) |
| 512 { | |
| 1259 | 513 int fd; |
| 514 struct hostent *host; | |
| 515 struct sockaddr_in site; | |
| 516 | |
| 1567 | 517 if (!(host = gethostbyname(server))) |
| 518 { | |
| 519 printf("Could not resolve host name: %s\n", server); | |
| 1259 | 520 return -1; |
| 521 } | |
| 522 | |
| 1567 | 523 bzero(&site, sizeof(struct sockaddr_in)); |
| 524 site.sin_port = htons(port); | |
| 525 memcpy(&site.sin_addr, host->h_addr, host->h_length); | |
| 526 site.sin_family = host->h_addrtype; | |
| 1259 | 527 |
| 1567 | 528 fd = socket(host->h_addrtype, SOCK_STREAM, 0); |
| 1259 | 529 |
| 1567 | 530 fcntl(fd, F_SETFL, O_NONBLOCK); |
| 1259 | 531 |
| 1567 | 532 if (connect(fd, (struct sockaddr *)&site, sizeof(struct sockaddr_in)) < 0) |
| 533 { | |
| 534 if ((errno == EINPROGRESS) || (errno == EINTR)) | |
| 535 { | |
| 536 printf("Connection would block\n"); | |
| 537 return fd; | |
| 1259 | 538 } |
| 539 | |
| 1567 | 540 close(fd); |
| 541 fd = -1; | |
| 1259 | 542 } |
| 1567 | 543 |
| 544 return fd; | |
| 1259 | 545 } |
| 546 | |
| 1282 | 547 void msn_login(struct aim_user *user) |
| 548 { | |
| 1567 | 549 struct gaim_connection *gc = new_gaim_conn(user); |
| 550 struct msn_data *md = gc->proto_data = g_new0(struct msn_data, 1); | |
| 1282 | 551 |
| 1567 | 552 gc->inpa = 0; |
| 1282 | 553 |
| 554 set_login_progress(gc, 1, "Connecting"); | |
| 1259 | 555 |
| 556 while (gtk_events_pending()) | |
| 557 gtk_main_iteration(); | |
| 1567 | 558 |
| 1259 | 559 if (!g_slist_find(connections, gc)) |
| 560 return; | |
| 561 | |
| 1567 | 562 md->status = 0; |
| 1282 | 563 |
| 1567 | 564 if (!(md->fd = msn_connect("messenger.hotmail.com", 1863))) |
| 565 { | |
| 566 hide_login_progress(gc, "Error connecting to server"); | |
| 1259 | 567 signoff(gc); |
| 568 return; | |
| 569 } | |
| 570 | |
| 1567 | 571 md->inpa = gdk_input_add(md->fd, GDK_INPUT_WRITE, msn_login_callback, gc); |
| 1259 | 572 |
| 1567 | 573 printf("Connected.\n"); |
| 1284 | 574 } |
| 575 | |
| 1572 | 576 static char **msn_list_icon(int uc) |
| 577 { | |
| 578 if (uc == UC_UNAVAILABLE) | |
| 579 return msn_away_xpm; | |
| 580 else if (uc == UC_NORMAL) | |
| 581 return msn_online_xpm; | |
| 582 | |
| 583 return msn_online_xpm; | |
| 584 } | |
| 585 | |
| 1259 | 586 static struct prpl *my_protocol = NULL; |
| 587 | |
| 1282 | 588 void msn_init(struct prpl *ret) |
| 589 { | |
| 1259 | 590 ret->protocol = PROTO_MSN; |
| 591 ret->name = msn_name; | |
| 1572 | 592 ret->list_icon = msn_list_icon; |
|
1499
de0b946e86a4
[gaim-migrate @ 1509]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1443
diff
changeset
|
593 ret->buddy_menu = NULL; |
| 1259 | 594 ret->user_opts = NULL; |
| 595 ret->login = msn_login; | |
| 1567 | 596 ret->close = NULL; |
| 597 ret->send_im = NULL; | |
| 1259 | 598 ret->set_info = NULL; |
| 599 ret->get_info = NULL; | |
| 1567 | 600 ret->set_away = NULL; |
| 1259 | 601 ret->get_away_msg = NULL; |
| 602 ret->set_dir = NULL; | |
| 603 ret->get_dir = NULL; | |
| 604 ret->dir_search = NULL; | |
| 1567 | 605 ret->set_idle = NULL; |
| 1259 | 606 ret->change_passwd = NULL; |
| 1567 | 607 ret->add_buddy = NULL; |
| 1259 | 608 ret->add_buddies = NULL; |
| 1567 | 609 ret->remove_buddy = NULL; |
| 610 ret->add_permit = NULL; | |
| 611 ret->rem_permit = NULL; | |
| 612 ret->add_deny = NULL; | |
| 613 ret->rem_deny = NULL; | |
| 1259 | 614 ret->warn = NULL; |
| 615 ret->accept_chat = NULL; | |
| 616 ret->join_chat = NULL; | |
| 617 ret->chat_invite = NULL; | |
| 618 ret->chat_leave = NULL; | |
| 619 ret->chat_whisper = NULL; | |
| 620 ret->chat_send = NULL; | |
| 621 ret->keepalive = NULL; | |
| 622 | |
| 623 my_protocol = ret; | |
| 624 } | |
| 625 | |
| 1282 | 626 char *gaim_plugin_init(GModule * handle) |
| 627 { | |
|
1443
336fc98b7f90
[gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1327
diff
changeset
|
628 load_protocol(msn_init, sizeof(struct prpl)); |
| 1259 | 629 return NULL; |
| 630 } | |
| 631 | |
| 1282 | 632 void gaim_plugin_remove() |
| 633 { | |
| 1259 | 634 struct prpl *p = find_prpl(PROTO_MSN); |
| 635 if (p == my_protocol) | |
| 636 unload_protocol(p); | |
| 637 } |
