| 1 /* |
1 /* |
| 2 * gaim - Napster Protocol Plugin |
2 * gaim - Napster Protocol Plugin |
| 3 * |
3 * |
| 4 * Copyright (C) 2000-2001, Rob Flynn <rob@tgflinux.com> |
4 * Copyright (C) 2000-2001, Rob Flynn <rob@marko.net> |
| 5 * |
5 * |
| 6 * This program is free software; you can redistribute it and/or modify |
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 |
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 |
8 * the Free Software Foundation; either version 2 of the License, or |
| 9 * (at your option) any later version. |
9 * (at your option) any later version. |
| 39 #include "proxy.h" |
39 #include "proxy.h" |
| 40 #include "pixmaps/napster.xpm" |
40 #include "pixmaps/napster.xpm" |
| 41 |
41 |
| 42 #define NAP_BUF_LEN 4096 |
42 #define NAP_BUF_LEN 4096 |
| 43 |
43 |
| |
44 #define USEROPT_NAPSERVER 3 |
| |
45 #define NAP_SERVER "64.124.41.187" |
| |
46 #define USEROPT_NAPPORT 4 |
| |
47 #define NAP_PORT 8888 |
| |
48 |
| 44 GSList *nap_connections = NULL; |
49 GSList *nap_connections = NULL; |
| 45 |
50 |
| 46 static unsigned int chat_id = 0; |
51 static unsigned int chat_id = 0; |
| 47 |
52 |
| 48 struct nap_channel { |
53 struct nap_channel { |
| 432 static void nap_login(struct aim_user *user) |
437 static void nap_login(struct aim_user *user) |
| 433 { |
438 { |
| 434 struct gaim_connection *gc = new_gaim_conn(user); |
439 struct gaim_connection *gc = new_gaim_conn(user); |
| 435 struct nap_data *ndata = gc->proto_data = g_new0(struct nap_data, 1); |
440 struct nap_data *ndata = gc->proto_data = g_new0(struct nap_data, 1); |
| 436 |
441 |
| 437 ndata->fd = proxy_connect("64.124.41.187", 8888, nap_login_connect, gc); |
442 ndata->fd = proxy_connect(user->proto_opt[USEROPT_NAPSERVER][0] ? user->proto_opt[USEROPT_NAPSERVER] : NAP_SERVER, |
| |
443 user->proto_opt[USEROPT_NAPPORT][0] ? atoi(user->proto_opt[USEROPT_NAPPORT]) : NAP_PORT, |
| |
444 nap_login_connect, gc); |
| 438 if (ndata->fd < 0) { |
445 if (ndata->fd < 0) { |
| 439 hide_login_progress(gc, "Unable to connect"); |
446 hide_login_progress(gc, "Unable to connect"); |
| 440 signoff(gc); |
447 signoff(gc); |
| 441 } |
448 } |
| 442 } |
449 } |
| 541 nap_write_packet(gc, 0xd0, (char *)buddies->data); |
548 nap_write_packet(gc, 0xd0, (char *)buddies->data); |
| 542 buddies = buddies -> next; |
549 buddies = buddies -> next; |
| 543 } |
550 } |
| 544 } |
551 } |
| 545 |
552 |
| |
553 |
| |
554 static GList *nap_user_opts() |
| |
555 { |
| |
556 GList *m = NULL; |
| |
557 struct proto_user_opt *puo; |
| |
558 |
| |
559 puo = g_new0(struct proto_user_opt, 1); |
| |
560 puo->label = "Server:"; |
| |
561 puo->def = NAP_SERVER; |
| |
562 puo->pos = USEROPT_NAPSERVER; |
| |
563 m = g_list_append(m, puo); |
| |
564 |
| |
565 puo = g_new0(struct proto_user_opt, 1); |
| |
566 puo->label = "Port:"; |
| |
567 puo->def = "8888"; |
| |
568 puo->pos = USEROPT_NAPPORT; |
| |
569 m = g_list_append(m, puo); |
| |
570 |
| |
571 return m; |
| |
572 } |
| |
573 |
| 546 static char** nap_list_icon(int uc) |
574 static char** nap_list_icon(int uc) |
| 547 { |
575 { |
| 548 return napster_xpm; |
576 return napster_xpm; |
| 549 } |
577 } |
| 550 |
578 |
| 553 void napster_init(struct prpl *ret) |
581 void napster_init(struct prpl *ret) |
| 554 { |
582 { |
| 555 ret->protocol = PROTO_NAPSTER; |
583 ret->protocol = PROTO_NAPSTER; |
| 556 ret->name = nap_name; |
584 ret->name = nap_name; |
| 557 ret->list_icon = nap_list_icon; |
585 ret->list_icon = nap_list_icon; |
| 558 ret->user_opts = NULL; |
586 ret->user_opts = nap_user_opts; |
| 559 ret->login = nap_login; |
587 ret->login = nap_login; |
| 560 ret->close = nap_close; |
588 ret->close = nap_close; |
| 561 ret->send_im = nap_send_im; |
589 ret->send_im = nap_send_im; |
| 562 ret->set_info = NULL; |
590 ret->set_info = NULL; |
| 563 ret->get_info = NULL; |
591 ret->get_info = NULL; |