Mercurial > pidgin
comparison src/protocols/napster/napster.c @ 2090:b66aca8e8dce
[gaim-migrate @ 2100]
change ../config.h to <config.h> because that's better. change from GdkInput functions to GaimInput for reasons mentioned elsewhere.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Tue, 31 Jul 2001 23:23:40 +0000 |
parents | 424a40f12a6c |
children | 56c4382f2909 |
comparison
equal
deleted
inserted
replaced
2089:bb1ddaaf0d26 | 2090:b66aca8e8dce |
---|---|
17 * along with this program; if not, write to the Free Software | 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 | 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 * | 19 * |
20 */ | 20 */ |
21 | 21 |
22 #include "../config.h" | 22 #include <config.h> |
23 | 23 |
24 #include <netdb.h> | 24 #include <netdb.h> |
25 #include <gtk/gtk.h> | 25 #include <gtk/gtk.h> |
26 #include <unistd.h> | 26 #include <unistd.h> |
27 #include <errno.h> | 27 #include <errno.h> |
304 } | 304 } |
305 | 305 |
306 return NULL; | 306 return NULL; |
307 } | 307 } |
308 | 308 |
309 static void nap_ctc_callback(gpointer data, gint source, GdkInputCondition condition) | 309 static void nap_ctc_callback(gpointer data, gint source, GaimInputCondition condition) |
310 { | 310 { |
311 struct gaim_connection *gc = (struct gaim_connection *)data; | 311 struct gaim_connection *gc = (struct gaim_connection *)data; |
312 struct nap_data *ndata = (struct nap_data *)gc->proto_data; | 312 struct nap_data *ndata = (struct nap_data *)gc->proto_data; |
313 struct nap_file_request *req; | 313 struct nap_file_request *req; |
314 unsigned char *buf; | 314 unsigned char *buf; |
336 | 336 |
337 /* We should receive a '1' upon connection */ | 337 /* We should receive a '1' upon connection */ |
338 if (buf[0] != '1') | 338 if (buf[0] != '1') |
339 { | 339 { |
340 do_error_dialog("Uh Oh", "Uh Oh"); | 340 do_error_dialog("Uh Oh", "Uh Oh"); |
341 gdk_input_remove(req->inpa); | 341 gaim_input_remove(req->inpa); |
342 ndata->requests = g_slist_remove(ndata->requests, req); | 342 ndata->requests = g_slist_remove(ndata->requests, req); |
343 g_free(req->name); | 343 g_free(req->name); |
344 g_free(req->file); | 344 g_free(req->file); |
345 close(source); | 345 close(source); |
346 g_free(req); | 346 g_free(req); |
365 /* Save the size of the file */ | 365 /* Save the size of the file */ |
366 req->total = filesize; | 366 req->total = filesize; |
367 | 367 |
368 /* If we have a zero file size then something bad happened */ | 368 /* If we have a zero file size then something bad happened */ |
369 if (filesize == 0) { | 369 if (filesize == 0) { |
370 gdk_input_remove(req->inpa); | 370 gaim_input_remove(req->inpa); |
371 ndata->requests = g_slist_remove(ndata->requests, req); | 371 ndata->requests = g_slist_remove(ndata->requests, req); |
372 g_free(req->name); | 372 g_free(req->name); |
373 g_free(req->file); | 373 g_free(req->file); |
374 g_free(req); | 374 g_free(req); |
375 free(buf); | 375 free(buf); |
447 free(buf); | 447 free(buf); |
448 | 448 |
449 if (req->size >= req->total) { | 449 if (req->size >= req->total) { |
450 printf("Download complete.\n"); | 450 printf("Download complete.\n"); |
451 nap_write_packet(gc, 0xdb, "\n"); /* Tell the server we're finished */ | 451 nap_write_packet(gc, 0xdb, "\n"); /* Tell the server we're finished */ |
452 gdk_input_remove(req->inpa); | 452 gaim_input_remove(req->inpa); |
453 | 453 |
454 ndata->requests = g_slist_remove(ndata->requests, req); | 454 ndata->requests = g_slist_remove(ndata->requests, req); |
455 | 455 |
456 if (req->name != NULL) | 456 if (req->name != NULL) |
457 g_free(req->name); | 457 g_free(req->name); |
463 fclose(req->mp3); | 463 fclose(req->mp3); |
464 close(source); | 464 close(source); |
465 } | 465 } |
466 } | 466 } |
467 | 467 |
468 static void nap_get_file_connect(gpointer data, gint source, GdkInputCondition cond) | 468 static void nap_get_file_connect(gpointer data, gint source, GaimInputCondition cond) |
469 { | 469 { |
470 char buf[NAP_BUF_LEN]; | 470 char buf[NAP_BUF_LEN]; |
471 struct nap_file_request *req = data; | 471 struct nap_file_request *req = data; |
472 struct gaim_connection *gc = req->gc; | 472 struct gaim_connection *gc = req->gc; |
473 struct nap_data *ndata = (struct nap_data *)gc->proto_data; | 473 struct nap_data *ndata = (struct nap_data *)gc->proto_data; |
492 | 492 |
493 /* Add our request */ | 493 /* Add our request */ |
494 ndata->requests = g_slist_append(ndata->requests, req); | 494 ndata->requests = g_slist_append(ndata->requests, req); |
495 | 495 |
496 /* And start monitoring */ | 496 /* And start monitoring */ |
497 req->inpa = gdk_input_add(req->fd, GDK_INPUT_READ, nap_ctc_callback, gc); | 497 req->inpa = gaim_input_add(req->fd, GAIM_INPUT_READ, nap_ctc_callback, gc); |
498 } | 498 } |
499 | 499 |
500 static void nap_get_file(struct gaim_connection *gc, gchar *user, gchar *file, gchar *host, unsigned int port) | 500 static void nap_get_file(struct gaim_connection *gc, gchar *user, gchar *file, gchar *host, unsigned int port) |
501 { | 501 { |
502 struct nap_file_request *req = g_new0(struct nap_file_request, 1); | 502 struct nap_file_request *req = g_new0(struct nap_file_request, 1); |
516 g_free(req->file); | 516 g_free(req->file); |
517 g_free(req); | 517 g_free(req); |
518 } | 518 } |
519 } | 519 } |
520 | 520 |
521 static void nap_callback(gpointer data, gint source, GdkInputCondition condition) | 521 static void nap_callback(gpointer data, gint source, GaimInputCondition condition) |
522 { | 522 { |
523 struct gaim_connection *gc = data; | 523 struct gaim_connection *gc = data; |
524 struct nap_data *ndata = gc->proto_data; | 524 struct nap_data *ndata = gc->proto_data; |
525 gchar *buf; | 525 gchar *buf; |
526 unsigned short header[2]; | 526 unsigned short header[2]; |
833 | 833 |
834 free(buf); | 834 free(buf); |
835 } | 835 } |
836 | 836 |
837 | 837 |
838 static void nap_login_callback(gpointer data, gint source, GdkInputCondition condition) | 838 static void nap_login_callback(gpointer data, gint source, GaimInputCondition condition) |
839 { | 839 { |
840 struct gaim_connection *gc = data; | 840 struct gaim_connection *gc = data; |
841 struct nap_data *ndata = gc->proto_data; | 841 struct nap_data *ndata = gc->proto_data; |
842 gchar buf[NAP_BUF_LEN]; | 842 gchar buf[NAP_BUF_LEN]; |
843 unsigned short header[2]; | 843 unsigned short header[2]; |
853 | 853 |
854 /* If we have some kind of error, get outta here */ | 854 /* If we have some kind of error, get outta here */ |
855 if (command == 0x00) | 855 if (command == 0x00) |
856 { | 856 { |
857 do_error_dialog(buf, "Gaim: Napster Error"); | 857 do_error_dialog(buf, "Gaim: Napster Error"); |
858 gdk_input_remove(ndata->inpa); | 858 gaim_input_remove(ndata->inpa); |
859 ndata->inpa = 0; | 859 ndata->inpa = 0; |
860 close(source); | 860 close(source); |
861 signoff(gc); | 861 signoff(gc); |
862 return; | 862 return; |
863 } | 863 } |
865 if (command == 0x03) { | 865 if (command == 0x03) { |
866 printf("Registered with E-Mail address of: %s\n", buf); | 866 printf("Registered with E-Mail address of: %s\n", buf); |
867 ndata->email = g_strdup(buf); | 867 ndata->email = g_strdup(buf); |
868 | 868 |
869 /* Remove old inpa, add new one */ | 869 /* Remove old inpa, add new one */ |
870 gdk_input_remove(ndata->inpa); | 870 gaim_input_remove(ndata->inpa); |
871 ndata->inpa = 0; | 871 ndata->inpa = 0; |
872 gc->inpa = gdk_input_add(ndata->fd, GDK_INPUT_READ, nap_callback, gc); | 872 gc->inpa = gaim_input_add(ndata->fd, GAIM_INPUT_READ, nap_callback, gc); |
873 | 873 |
874 /* Our signon is complete */ | 874 /* Our signon is complete */ |
875 account_online(gc); | 875 account_online(gc); |
876 serv_finish_login(gc); | 876 serv_finish_login(gc); |
877 | 877 |
881 return; | 881 return; |
882 } | 882 } |
883 } | 883 } |
884 | 884 |
885 | 885 |
886 static void nap_login_connect(gpointer data, gint source, GdkInputCondition cond) | 886 static void nap_login_connect(gpointer data, gint source, GaimInputCondition cond) |
887 { | 887 { |
888 struct gaim_connection *gc = data; | 888 struct gaim_connection *gc = data; |
889 struct nap_data *ndata = gc->proto_data; | 889 struct nap_data *ndata = gc->proto_data; |
890 char buf[NAP_BUF_LEN]; | 890 char buf[NAP_BUF_LEN]; |
891 | 891 |
901 /* And write our signon data */ | 901 /* And write our signon data */ |
902 g_snprintf(buf, NAP_BUF_LEN, "%s %s 0 \"gaimster\" 0", gc->username, gc->password); | 902 g_snprintf(buf, NAP_BUF_LEN, "%s %s 0 \"gaimster\" 0", gc->username, gc->password); |
903 nap_write_packet(gc, 0x02, buf); | 903 nap_write_packet(gc, 0x02, buf); |
904 | 904 |
905 /* And set up the input watcher */ | 905 /* And set up the input watcher */ |
906 ndata->inpa = gdk_input_add(ndata->fd, GDK_INPUT_READ, nap_login_callback, gc); | 906 ndata->inpa = gaim_input_add(ndata->fd, GAIM_INPUT_READ, nap_login_callback, gc); |
907 } | 907 } |
908 | 908 |
909 | 909 |
910 static void nap_login(struct aim_user *user) | 910 static void nap_login(struct aim_user *user) |
911 { | 911 { |
983 struct nap_channel *channel; | 983 struct nap_channel *channel; |
984 struct browse_window *browse; | 984 struct browse_window *browse; |
985 struct nap_file_request *req; | 985 struct nap_file_request *req; |
986 | 986 |
987 if (gc->inpa) | 987 if (gc->inpa) |
988 gdk_input_remove(gc->inpa); | 988 gaim_input_remove(gc->inpa); |
989 | 989 |
990 while (ndata->channels) { | 990 while (ndata->channels) { |
991 channel = (struct nap_channel *)ndata->channels->data; | 991 channel = (struct nap_channel *)ndata->channels->data; |
992 g_free(channel->name); | 992 g_free(channel->name); |
993 ndata->channels = g_slist_remove(ndata->channels, channel); | 993 ndata->channels = g_slist_remove(ndata->channels, channel); |
1005 while (ndata->requests) { | 1005 while (ndata->requests) { |
1006 req = (struct nap_file_request *)ndata->requests->data; | 1006 req = (struct nap_file_request *)ndata->requests->data; |
1007 g_free(req->name); | 1007 g_free(req->name); |
1008 g_free(req->file); | 1008 g_free(req->file); |
1009 if (req->inpa) { | 1009 if (req->inpa) { |
1010 gdk_input_remove(req->inpa); | 1010 gaim_input_remove(req->inpa); |
1011 } | 1011 } |
1012 ndata->requests = g_slist_remove(ndata->requests, req); | 1012 ndata->requests = g_slist_remove(ndata->requests, req); |
1013 g_free(req); | 1013 g_free(req); |
1014 | 1014 |
1015 } | 1015 } |