annotate plugins/napster.c @ 1424:9d8cf2e12e68

[gaim-migrate @ 1434] Umm committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Thu, 25 Jan 2001 00:54:42 +0000
parents 6e0883ee51ce
children 28278bd61403
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * gaim - Napster Protocol Plugin
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 * Copyright (C) 2000, Rob Flynn <rob@tgflinux.com>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 *
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * (at your option) any later version.
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 *
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * GNU General Public License for more details.
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 *
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 *
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22 #include "../config.h"
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
23
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
24 #include <netdb.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
25 #include <gtk/gtk.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 #include <unistd.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27 #include <errno.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 #include <netinet/in.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 #include <arpa/inet.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 #include <time.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31 #include <string.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 #include <stdlib.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
33 #include <stdio.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
34 #include <time.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35 #include <sys/socket.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
36 #include <sys/stat.h>
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
37 #include <sys/types.h>
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
38 #include <fcntl.h>
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
39 #include <ctype.h>
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40 #include "multi.h"
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41 #include "prpl.h"
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42 #include "gaim.h"
1327
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
43 #include "pixmaps/napster.xpm"
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
44
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45 #define NAP_BUF_LEN 4096
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
46
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47 GSList *nap_connections = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
48
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 static unsigned int chat_id = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
51 struct browse_window {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
52 GtkWidget *window;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
53 GtkWidget *list;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
54 struct gaim_connection *gc;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
55 char *name;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
56 };
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
57
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
58 struct nap_download_box {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
59 GtkWidget *window;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
60 GtkWidget *ok;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
61 GtkWidget *entry;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
62 gchar *who;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
63 };
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
64
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
65 struct nap_channel {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
66 unsigned int id;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
67 gchar *name;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
68 };
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
69
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
70 struct nap_file_request {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
71 gchar *name;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
72 gchar *file;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
73 int fd;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
74 long size;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
75 long total;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
76 int status;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
77 int inpa;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
78 FILE *mp3;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
79 };
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
80
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
81 struct nap_data {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
82 int fd;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
83 int inpa;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
84
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
85 gchar *email;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
86 GSList *channels;
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
87 GSList *requests;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
88 GSList *browses;
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
89 };
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
90
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
91 static char *nap_name()
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
92 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
93 return "Napster";
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
94 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
95
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
96 char *name()
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
97 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
98 return "Napster";
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
99 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
100
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
101 char *description()
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
102 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
103 return "Allows gaim to use the Napster protocol. Yes, kids, drugs are bad.";
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
104 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
105
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
106
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
107 /* FIXME: Make this use va_arg stuff */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
108 void nap_write_packet(struct gaim_connection *gc, unsigned short command, char *message)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
109 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
110 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
111 unsigned short size;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
112
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
113 size = strlen(message);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
114
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
115 write(ndata->fd, &size, 2);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
116 write(ndata->fd, &command, 2);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
117 write(ndata->fd, message, size);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
118 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
119
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
120 void nap_send_download_req(struct gaim_connection *gc, char *who, char *file)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
121 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
122 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
123 gchar buf[NAP_BUF_LEN];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
124
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
125 g_snprintf(buf, NAP_BUF_LEN, "%s \"%s\"", who, file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
126
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
127 nap_write_packet(gc, 0xCB, buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
128 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
129
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
130 void nap_handle_download(GtkCList *clist, gint row, gint col, GdkEventButton *event, gpointer user_data)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
131 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
132 gchar **results;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
133 struct browse_window *bw = (struct browse_window *)user_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
134
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
135 gtk_clist_get_text(GTK_CLIST(bw->list), row, 0, results);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
136
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
137 nap_send_download_req(bw->gc, bw->name, results[0]);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
138
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
139 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
140
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
141 struct browse_window *browse_window_new(struct gaim_connection *gc, char *name)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
142 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
143 struct browse_window *browse = g_new0(struct browse_window, 1);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
144 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
145
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
146 browse->window = gtk_window_new(GTK_WINDOW_DIALOG);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
147 browse->name = g_strdup(name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
148 browse->list = gtk_clist_new(1);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
149 browse->gc = gc;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
150
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
151 gtk_widget_show(browse->list);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
152 gtk_container_add(GTK_CONTAINER(browse->window), browse->list);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
153
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
154 gtk_widget_set_usize(GTK_WIDGET(browse->window), 300, 250);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
155 gtk_widget_show(browse->window);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
156
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
157 /*FIXME: I dont like using select-row. Im lazy. Ill fix it later */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
158 gtk_signal_connect(GTK_OBJECT(browse->list), "select-row", GTK_SIGNAL_FUNC(nap_handle_download), browse);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
159
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
160 ndata->browses = g_slist_append(ndata->browses, browse);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
161 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
162
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
163 void browse_window_add_file(struct browse_window *bw, char *name)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
164 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
165 char *fn[1];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
166 fn[0] = strdup(name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
167 printf("User '%s' has file '%s'\n", bw->name, name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
168 gtk_clist_append(GTK_CLIST(bw->list), fn);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
169
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
170 free(fn[0]);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
171 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
172
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
173 static struct browse_window *find_browse_window_by_name(struct gaim_connection *gc, char *name)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
174 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
175 struct browse_window *browse;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
176 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
177 GSList *browses;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
178
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
179 browses = ndata->browses;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
180
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
181 while (browses) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
182 browse = (struct browse_window *)browses->data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
183
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
184 if (browse) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
185 if (!g_strcasecmp(name, browse->name)) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
186 return browse;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
187 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
188 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
189 browses = g_slist_next(browses);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
190 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
191
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
192 return NULL;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
193 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
194
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
195 static void nap_send_im(struct gaim_connection *gc, char *who, char *message, int away)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
196 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
197 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
198 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
199
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
200 g_snprintf(buf, NAP_BUF_LEN, "%s %s", who, message);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
201 nap_write_packet(gc, 0xCD, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
202 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
203
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
204 static struct nap_channel *find_channel_by_name(struct gaim_connection *gc, char *name)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
205 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
206 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
207 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
208 GSList *channels;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
209
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
210 channels = ndata->channels;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
211
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
212 while (channels) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
213 channel = (struct nap_channel *)channels->data;
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
214
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
215 if (channel) {
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
216 if (!g_strcasecmp(name, channel->name)) {
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
217 return channel;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
218 }
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
219 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
220 channels = g_slist_next(channels);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
221 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
222
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
223 return NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
224 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
225
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
226 static struct nap_channel *find_channel_by_id(struct gaim_connection *gc, int id)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
227 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
228 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
229 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
230 GSList *channels;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
231
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
232 channels = ndata->channels;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
233
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
234 while (channels) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
235 channel = (struct nap_channel *)channels->data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
236 if (id == channel->id) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
237 return channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
238 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
239
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
240 channels = g_slist_next(channels);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
241 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
242
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
243 return NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
244 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
245
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
246 static struct conversation *find_conversation_by_id(struct gaim_connection *gc, int id)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
247 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
248 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
249 GSList *bc = gc->buddy_chats;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
250 struct conversation *b = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
251
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
252 while (bc) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
253 b = (struct conversation *)bc->data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
254 if (id == b->id) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
255 break;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
256 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
257 bc = bc->next;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
258 b = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
259 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
260
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
261 if (!b) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
262 return NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
263 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
264
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
265 return b;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
266 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
267
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
268 /* This is a strange function. I smoke too many bad bad things :-) */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
269 struct nap_file_request * find_request_by_fd(struct gaim_connection *gc, int fd)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
270 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
271 struct nap_file_request *req;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
272 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
273 GSList *requests;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
274
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
275 requests = ndata->requests;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
276
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
277 while (requests) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
278 req = (struct nap_file_request *)requests->data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
279
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
280 if (req) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
281 if (req->fd == fd)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
282 return req;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
283 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
284 requests = g_slist_next(requests);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
285 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
286
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
287 return NULL;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
288 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
289
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
290 static void nap_ctc_callback(gpointer data, gint source, GdkInputCondition condition)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
291 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
292 struct gaim_connection *gc = (struct gaim_connection *)data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
293 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
294 struct nap_file_request *req;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
295 unsigned char *buf;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
296 int i = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
297 gchar *c;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
298 int len;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
299
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
300 req = find_request_by_fd(gc, source);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
301 if (!req) /* Something bad happened */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
302 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
303
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
304 buf = (char *)malloc(sizeof(char) * (NAP_BUF_LEN + 1));
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
305
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
306 if (req->status == 0)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
307 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
308 int j;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
309 gchar tmp[32];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
310 long filesize;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
311 gchar **parse_name;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
312 gchar path[2048];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
313
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
314
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
315 recv(source, buf, 1, 0);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
316
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
317 /* We should receive a '1' upon connection */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
318 if (buf[0] != '1')
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
319 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
320 do_error_dialog("Uh Oh", "Uh Oh");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
321 gdk_input_remove(req->inpa);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
322 ndata->requests = g_slist_remove(ndata->requests, req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
323 g_free(req->name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
324 g_free(req->file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
325 close(source);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
326 g_free(req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
327 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
328 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
329 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
330
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
331 /* Lets take a peek at the awaiting data */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
332 i = recv(source, buf, NAP_BUF_LEN, MSG_PEEK);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
333 buf[i] = 0; /* Make sure that we terminate our string */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
334
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
335 /* Looks like the uploader sent the proper data. Let's see how big the
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
336 * file is */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
337
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
338 for (j = 0, i = 0; isdigit(buf[i]); i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
339 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
340 tmp[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
341 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
342 tmp[j] = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
343 filesize = atol(tmp);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
344
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
345 /* Save the size of the file */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
346 req->total = filesize;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
347
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
348 /* If we have a zero file size then something bad happened */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
349 if (filesize == 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
350 gdk_input_remove(req->inpa);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
351 ndata->requests = g_slist_remove(ndata->requests, req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
352 g_free(req->name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
353 g_free(req->file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
354 g_free(req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
355 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
356 close(source);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
357 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
358 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
359
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
360 /* Now that we've done that, let's go ahead and read that
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
361 * data to get it out of the way */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
362 recv(source, buf, strlen(tmp), 0);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
363
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
364 /* Now, we should tell the server that we're download something */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
365 nap_write_packet(gc, 0xda, "\n");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
366
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
367 req->status = 1;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
368
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
369 /* FIXME: We dont want to force the file name. I'll parse this
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
370 * later */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
371
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
372 parse_name = g_strsplit(req->file, "\\", 0);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
373 g_snprintf(path, sizeof(path), "%s/%s", getenv("HOME"), parse_name[sizeof(parse_name)]);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
374 printf("Gonna try to save to: %s\n", path);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
375 g_strfreev(parse_name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
376
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
377 req->mp3 = fopen(path, "w");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
378 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
379 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
380 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
381
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
382 /* Looks like our status isn't 1. It's safe to assume we're downloadin' */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
383 i = recv(source, buf, NAP_BUF_LEN, 0);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
384
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
385 req->size += i; /* Lets add up the total */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
386
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
387 printf("Downloaded %ld of %ld\n", req->size, req->total);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
388
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
389 fwrite(buf, i, sizeof(char), req->mp3);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
390
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
391 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
392
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
393 if (req->size >= req->total) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
394 printf("Download complete.\n");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
395 nap_write_packet(gc, 0xdb, "\n"); /* Tell the server we're finished */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
396 gdk_input_remove(req->inpa);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
397 ndata->requests = g_slist_remove(ndata->requests, req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
398 g_free(req->name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
399 g_free(req->file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
400 g_free(req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
401 fclose(req->mp3);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
402 close(source);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
403 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
404 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
405
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
406 void nap_get_file(struct gaim_connection *gc, gchar *user, gchar *file, unsigned long host, unsigned int port)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
407 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
408 int fd;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
409 struct sockaddr_in site;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
410 char buf[NAP_BUF_LEN];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
411 int inpa;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
412 struct nap_file_request *req = g_new0(struct nap_file_request, 1);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
413 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
414
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
415
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
416 site.sin_family = AF_INET;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
417 site.sin_addr.s_addr = host;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
418 site.sin_port = htons(port);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
419
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
420 fd = socket(AF_INET, SOCK_STREAM, 0);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
421
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
422 if (fd < 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
423 do_error_dialog("Error connecting to user", "Gaim: Napster error");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
424 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
425 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
426
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
427 /* Make a connection with the server */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
428 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
429 do_error_dialog("Error connecting to user", "Gaim: Napster error");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
430 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
431 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
432
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
433 req->fd = fd;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
434 req->name = g_strdup(user);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
435 req->file = g_strdup(file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
436 req->size = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
437 req->status = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
438 req->total = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
439
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
440 /* Send our request to the user */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
441 g_snprintf(buf, sizeof(buf), "GET%s \"%s\" 0\n", user, file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
442 write(fd, buf, strlen(buf));
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
443
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
444 /* Add our request */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
445 ndata->requests = g_slist_append(ndata->requests, req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
446
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
447 /* And start monitoring */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
448 req->inpa = gdk_input_add(fd, GDK_INPUT_READ, nap_ctc_callback, gc);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
449 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
450
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
451 static void nap_callback(gpointer data, gint source, GdkInputCondition condition)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
452 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
453 struct gaim_connection *gc = data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
454 struct nap_data *ndata = gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
455 gchar *buf;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
456 unsigned short header[2];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
457 int i = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
458 int len;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
459 int command;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
460 gchar **res;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
461
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
462 read(source, header, 4);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
463 len = header[0];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
464 command = header[1];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
465
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
466 buf = (gchar *)g_malloc(sizeof(gchar) * (len + 1));
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
467
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
468 read(source, buf, len);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
469
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
470 buf[len] = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
471
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
472 if (command == 0xd6) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
473 res = g_strsplit(buf, " ", 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
474 /* Do we want to report what the users are doing? */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
475 printf("users: %s, files: %s, size: %sGB\n", res[0], res[1], res[2]);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
476 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
477 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
478 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
479 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
480
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
481 if (command == 0x26d) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
482 /* Do we want to use the MOTD? */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
483 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
484 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
485 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
486
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
487 if (command == 0xCD) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
488 res = g_strsplit(buf, " ", 1);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
489 serv_got_im(gc, res[0], res[1], 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
490 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
491 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
492 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
493 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
494
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
495 if (command == 0x195) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
496 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
497 int id;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
498
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
499 channel = find_channel_by_name(gc, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
500
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
501 if (!channel) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
502 chat_id++;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
503
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
504 channel = g_new0(struct nap_channel, 1);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
505
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
506 channel->id = chat_id;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
507 channel->name = g_strdup(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
508
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
509 ndata->channels = g_slist_append(ndata->channels, channel);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
510
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
511 serv_got_joined_chat(gc, chat_id, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
512 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
513
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
514 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
515 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
516 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
517
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
518 if (command == 0x198 || command == 0x196) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
519 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
520 struct conversation *convo;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
521 gchar **res;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
522
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
523 res = g_strsplit(buf, " ", 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
524
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
525 channel = find_channel_by_name(gc, res[0]);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
526 convo = find_conversation_by_id(gc, channel->id);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
527
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
528 add_chat_buddy(convo, res[1]);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
529
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
530 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
531
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
532 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
533 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
534 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
535
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
536 if (command == 0x197) {
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
537 struct nap_channel *channel;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
538 struct conversation *convo;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
539 gchar **res;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
540
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
541 res = g_strsplit(buf, " ", 0);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
542
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
543 channel = find_channel_by_name(gc, res[0]);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
544 convo = find_conversation_by_id(gc, channel->id);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
545
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
546 remove_chat_buddy(convo, res[1]);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
547
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
548 g_strfreev(res);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
549 free(buf);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
550 return;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
551 }
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
552
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
553 if (command == 0x193) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
554 gchar **res;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
555 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
556
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
557 res = g_strsplit(buf, " ", 2);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
558
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
559 channel = find_channel_by_name(gc, res[0]);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
560
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
561 if (channel)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
562 serv_got_chat_in(gc, channel->id, res[1], 0, res[2]);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
563
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
564 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
565 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
566 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
567 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
568
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
569 if (command == 0x194) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
570 do_error_dialog(buf, "Gaim: Napster Error");
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
571 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
572 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
573 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
574
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
575 if (command == 0x12e) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
576 gchar buf2[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
577
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
578 g_snprintf(buf2, NAP_BUF_LEN, "Unable to add '%s' to your hotlist", buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
579 do_error_dialog(buf2, "Gaim: Napster Error");
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
580
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
581 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
582 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
583
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
584 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
585
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
586 if (command == 0x191) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
587 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
588
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
589 channel = find_channel_by_name(gc, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
590
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
591 if (!channel) /* I'm not sure how this would happen =) */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
592 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
593
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
594 serv_got_chat_left(gc, channel->id);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
595 ndata->channels = g_slist_remove(ndata->channels, channel);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
596
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
597 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
598 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
599
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
600 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
601
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
602 if (command == 0xd1) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
603 gchar **res;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
604
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
605 res = g_strsplit(buf, " ", 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
606
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
607 serv_got_update(gc, res[0], 1, 0, time((time_t *)NULL), 0, 0, 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
608
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
609 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
610 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
611 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
612 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
613
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
614 if (command == 0xd2) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
615 serv_got_update(gc, buf, 0, 0, 0, 0, 0, 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
616 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
617 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
618 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
619
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
620 if (command == 0xd4) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
621 /* Looks like we're getting a browse response */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
622 gchar user[64];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
623 gchar file[2048];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
624 struct browse_window *bw = NULL;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
625
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
626 int i,j;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
627
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
628 for (i = 0, j = 0; buf[i] != ' '; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
629 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
630 user[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
631 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
632 user[j] = 0; i++; i++;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
633
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
634 for (j = 0; buf[i] != '\"'; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
635 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
636 file[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
637 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
638 file[j] = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
639
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
640 bw = find_browse_window_by_name(gc, user);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
641 if (!bw)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
642 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
643 /* If a browse window isn't found, let's create one */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
644 bw = browse_window_new(gc, user);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
645 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
646
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
647 browse_window_add_file(bw, file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
648
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
649 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
650 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
651
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
652 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
653
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
654 if (command == 0x12d) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
655 /* Our buddy was added successfully */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
656 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
657 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
658 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
659
1329
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
660 if (command == 0x2ec) {
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
661 /* Looks like someone logged in as us! =-O */
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
662 free(buf);
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
663
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
664 signoff(gc);
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
665 return;
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
666 }
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
667
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
668 if (command == 0xcc) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
669 /* We received a Download ACK from a user. The way this is printed is kind of
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
670 * strange so we'll need to parse this one ourselves. */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
671
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
672 gchar user[64];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
673 gchar file[2048];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
674 gchar hoststr[16];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
675 gchar portstr[16];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
676 int i,j;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
677
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
678 for (i = 0, j = 0; buf[i] != ' '; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
679 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
680 user[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
681 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
682 user[j] = 0; i++;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
683
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
684 for (j = 0; buf[i] != ' '; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
685 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
686 hoststr[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
687 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
688 hoststr[j] = 0; i++;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
689
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
690 for (j = 0; buf[i] != ' '; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
691 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
692 portstr[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
693 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
694 portstr[j] = 0; i++;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
695
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
696 i++; /* We do this to ignore the first quotation mark */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
697
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
698 for (j = 0; buf[i] != '\"'; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
699 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
700 file[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
701 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
702 file[j] = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
703
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
704 /* Aaight. We dont need nuttin' else. Let's download the file */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
705 nap_get_file(gc, user, file, atol(hoststr), atoi(portstr));
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
706
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
707 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
708
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
709 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
710 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
711
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
712 printf("NAP: [COMMAND: 0x%04x] %s\n", command, buf);
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
713
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
714 free(buf);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
715 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
716
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
717
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
718 static void nap_login_callback(gpointer data, gint source, GdkInputCondition condition)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
719 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
720 struct gaim_connection *gc = data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
721 struct nap_data *ndata = gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
722 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
723 unsigned short header[2];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
724 int i = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
725 int len;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
726 int command;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
727
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
728 read(source, header, 4);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
729 len = header[0];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
730 command = header[1];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
731
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
732 read(source, buf, len);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
733 buf[len] = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
734
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
735 if (command == 0x03) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
736 printf("Registered with E-Mail address of: %s\n", buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
737 ndata->email = g_strdup(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
738
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
739 /* Remove old inpa, add new one */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
740 gdk_input_remove(ndata->inpa);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
741 ndata->inpa = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
742 gc->inpa = gdk_input_add(ndata->fd, GDK_INPUT_READ, nap_callback, gc);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
743
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
744 /* Our signon is complete */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
745 account_online(gc);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
746 serv_finish_login(gc);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
747
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
748 if (bud_list_cache_exists(gc))
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
749 do_import(NULL, gc);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
750
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
751 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
752 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
753 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
754
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
755
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
756
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
757 static void nap_login(struct aim_user *user)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
758 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
759 int fd;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
760 struct hostent *host;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
761 struct sockaddr_in site;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
762 struct gaim_connection *gc = new_gaim_conn(user);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
763 struct nap_data *ndata = gc->proto_data = g_new0(struct nap_data, 1);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
764 char buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
765 char c;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
766 char z[4];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
767 int i;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
768 int status;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
769
1424
9d8cf2e12e68 [gaim-migrate @ 1434]
Rob Flynn <gaim@robflynn.com>
parents: 1422
diff changeset
770 host = gethostbyname("n184.napster.com");
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
771
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
772 if (!host) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
773 hide_login_progress(gc, "Unable to resolve hostname");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
774 signoff(gc);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
775 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
776 }
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
777
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
778 site.sin_family = AF_INET;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
779 site.sin_addr.s_addr = *(long *)(host->h_addr);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
780 site.sin_port = htons(8888);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
781
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
782 fd = socket(AF_INET, SOCK_STREAM, 0);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
783 if (fd < 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
784 hide_login_progress(gc, "Unable to create socket");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
785 signoff(gc);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
786 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
787 }
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
788
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
789 /* Make a connection with the server */
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
790 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
791 hide_login_progress(gc, "Unable to connect.");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
792 signoff(gc);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
793 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
794 }
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
795
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
796 ndata->fd = fd;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
797
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
798 /* And write our signon data */
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
799 g_snprintf(buf, NAP_BUF_LEN, "%s %s 0 \"Gaim - Napster Plugin\" 0", gc->username, gc->password);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
800 nap_write_packet(gc, 0x02, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
801
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
802 /* And set up the input watcher */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
803 ndata->inpa = gdk_input_add(ndata->fd, GDK_INPUT_READ, nap_login_callback, gc);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
804
1424
9d8cf2e12e68 [gaim-migrate @ 1434]
Rob Flynn <gaim@robflynn.com>
parents: 1422
diff changeset
805
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
806 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
807
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
808 static void nap_join_chat(struct gaim_connection *gc, int id, char *name)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
809 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
810 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
811 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
812
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
813 /* Make sure the name has a # preceeding it */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
814 if (name[0] != '#')
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
815 g_snprintf(buf, NAP_BUF_LEN, "#%s", name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
816 else
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
817 g_snprintf(buf, NAP_BUF_LEN, "%s", name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
818
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
819 nap_write_packet(gc, 0x190, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
820 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
821
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
822 static void nap_chat_leave(struct gaim_connection *gc, int id)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
823 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
824 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
825 struct nap_channel *channel = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
826 GSList *channels = ndata->channels;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
827
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
828 channel = find_channel_by_id(gc, id);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
829
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
830 if (!channel) /* Again, I'm not sure how this would happen */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
831 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
832
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
833 nap_write_packet(gc, 0x191, channel->name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
834
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
835 ndata->channels = g_slist_remove(ndata->channels, channel);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
836 g_free(channel->name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
837 g_free(channel);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
838
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
839 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
840
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
841 static void nap_chat_send(struct gaim_connection *gc, int id, char *message)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
842 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
843 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
844 struct nap_channel *channel = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
845 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
846
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
847 channel = find_channel_by_id(gc, id);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
848
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
849 if (!channel) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
850 /* This shouldn't happen */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
851 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
852 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
853
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
854 g_snprintf(buf, NAP_BUF_LEN, "%s %s", channel->name, message);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
855 nap_write_packet(gc, 0x192, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
856
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
857 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
858
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
859 static void nap_add_buddy(struct gaim_connection *gc, char *name)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
860 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
861 nap_write_packet(gc, 0xCF, name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
862 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
863
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
864 static void nap_remove_buddy(struct gaim_connection *gc, char *name)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
865 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
866 nap_write_packet(gc, 0x12F, name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
867 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
868
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
869 static void nap_close(struct gaim_connection *gc)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
870 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
871 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
872 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
873 struct nap_channel *channel;
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
874 struct browse_window *browse;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
875 struct nap_file_request *req;
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
876 GSList *channels = ndata->channels;
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
877 GSList *requests = ndata->requests;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
878
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
879 if (gc->inpa)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
880 gdk_input_remove(gc->inpa);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
881
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
882 while (ndata->channels) {
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
883 channel = (struct nap_channel *)ndata->channels->data;
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
884 g_free(channel->name);
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
885 ndata->channels = g_slist_remove(ndata->channels, channel);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
886 g_free(channel);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
887 }
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
888
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
889 while (ndata->browses) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
890 browse = (struct browse_window *)ndata->browses->data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
891 g_free(browse->name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
892 gtk_widget_destroy(browse->window);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
893 ndata->browses = g_slist_remove(ndata->browses, browse);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
894 g_free(browse);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
895 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
896
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
897 while (ndata->requests) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
898 req = (struct nap_file_request *)ndata->requests->data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
899 g_free(req->name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
900 g_free(req->file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
901 if (req->inpa) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
902 gdk_input_remove(req->inpa);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
903 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
904 ndata->requests = g_slist_remove(ndata->requests, req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
905 g_free(req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
906
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
907 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
908
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
909 free(gc->proto_data);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
910 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
911
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
912 static void nap_add_buddies(struct gaim_connection *gc, GList *buddies)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
913 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
914 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
915 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
916 int n = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
917
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
918 while (buddies) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
919 nap_write_packet(gc, 0xd0, (char *)buddies->data);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
920 buddies = buddies -> next;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
921 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
922 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
923
1338
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
924 static void nap_draw_new_user(GtkWidget *box)
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
925 {
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
926 GtkWidget *label;
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
927
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
928 label = gtk_label_new(_("Napster registration is currently under development"));
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
929
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
930 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
931 gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
932 gtk_widget_show(label);
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
933 }
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
934
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
935
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
936 void nap_send_browse(GtkObject *w, char *who)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
937 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
938 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
939 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
940 gchar buf[NAP_BUF_LEN];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
941
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
942 g_snprintf(buf, NAP_BUF_LEN, "%s", who);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
943 nap_write_packet(gc, 0xd3, buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
944 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
945
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
946 static void nap_action_menu(GtkWidget *menu, struct gaim_connection *gc, char *who)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
947 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
948 GtkWidget *button;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
949
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
950 button = gtk_menu_item_new_with_label("List Files");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
951 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(nap_send_browse), who);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
952 gtk_object_set_user_data(GTK_OBJECT(button), gc);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
953 gtk_menu_append(GTK_MENU(menu), button);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
954 gtk_widget_show(button);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
955 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
956
1327
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
957 static char** nap_list_icon(int uc)
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
958 {
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
959 return napster_xpm;
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
960 }
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
961
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
962 static struct prpl *my_protocol = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
963
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
964 void nap_init(struct prpl *ret)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
965 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
966 ret->protocol = PROTO_NAPSTER;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
967 ret->name = nap_name;
1327
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
968 ret->list_icon = nap_list_icon;
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
969 ret->action_menu = nap_action_menu;
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
970 ret->user_opts = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
971 ret->login = nap_login;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
972 ret->close = nap_close;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
973 ret->send_im = nap_send_im;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
974 ret->set_info = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
975 ret->get_info = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
976 ret->set_away = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
977 ret->get_away_msg = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
978 ret->set_dir = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
979 ret->get_dir = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
980 ret->dir_search = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
981 ret->set_idle = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
982 ret->change_passwd = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
983 ret->add_buddy = nap_add_buddy;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
984 ret->add_buddies = nap_add_buddies;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
985 ret->remove_buddy = nap_remove_buddy;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
986 ret->add_permit = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
987 ret->rem_permit = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
988 ret->add_deny = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
989 ret->rem_deny = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
990 ret->warn = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
991 ret->accept_chat = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
992 ret->join_chat = nap_join_chat;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
993 ret->chat_invite = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
994 ret->chat_leave = nap_chat_leave;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
995 ret->chat_whisper = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
996 ret->chat_send = nap_chat_send;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
997 ret->keepalive = NULL;
1338
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
998 ret->draw_new_user = nap_draw_new_user;
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
999
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1000 my_protocol = ret;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1001 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1002
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1003 char *gaim_plugin_init(GModule * handle)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1004 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1005 load_protocol(nap_init);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1006 return NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1007 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1008
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1009 void gaim_plugin_remove()
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1010 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1011 struct prpl *p = find_prpl(PROTO_NAPSTER);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1012 if (p == my_protocol)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1013 unload_protocol(p);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1014 }