Mercurial > pidgin.yaz
annotate src/protocols/napster/napster.c @ 2170:c24595d3c364
[gaim-migrate @ 2180]
buddy_menu
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 27 Aug 2001 07:11:50 +0000 |
parents | edf8c5a70e5b |
children | cff4fbe01c7b |
rev | line source |
---|---|
2086 | 1 /* |
2 * gaim - Napster Protocol Plugin | |
3 * | |
4 * Copyright (C) 2000-2001, Rob Flynn <rob@tgflinux.com> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
22 #include <config.h> |
2086 | 23 |
24 #include <netdb.h> | |
25 #include <gtk/gtk.h> | |
26 #include <unistd.h> | |
27 #include <errno.h> | |
28 #include <netinet/in.h> | |
29 #include <arpa/inet.h> | |
30 #include <time.h> | |
31 #include <string.h> | |
32 #include <stdlib.h> | |
33 #include <stdio.h> | |
34 #include <time.h> | |
35 #include <sys/socket.h> | |
36 #include <sys/stat.h> | |
37 #include <sys/types.h> | |
38 #include <fcntl.h> | |
39 #include <ctype.h> | |
40 #include "multi.h" | |
41 #include "prpl.h" | |
42 #include "gaim.h" | |
43 #include "proxy.h" | |
44 #include "pixmaps/napster.xpm" | |
45 | |
46 #define NAP_BUF_LEN 4096 | |
47 | |
48 GSList *nap_connections = NULL; | |
49 | |
50 static unsigned int chat_id = 0; | |
51 | |
52 struct search_window { | |
53 GtkWidget *window; | |
54 GtkWidget *list; | |
55 }; | |
56 | |
57 struct browse_window { | |
58 GtkWidget *window; | |
59 GtkWidget *list; | |
60 struct gaim_connection *gc; | |
61 char *name; | |
62 }; | |
63 | |
64 struct nap_download_box { | |
65 GtkWidget *window; | |
66 GtkWidget *ok; | |
67 GtkWidget *entry; | |
68 gchar *who; | |
69 }; | |
70 | |
71 struct nap_channel { | |
72 unsigned int id; | |
73 gchar *name; | |
74 }; | |
75 | |
76 struct nap_file_request { | |
77 gchar *name; | |
78 gchar *file; | |
79 int fd; | |
80 long size; | |
81 long total; | |
82 int status; | |
83 int inpa; | |
84 FILE *mp3; | |
85 GtkWidget *window; | |
86 GtkWidget *progress; | |
87 GtkWidget *ok; | |
88 GtkWidget *cancel; | |
89 struct gaim_connection *gc; | |
90 }; | |
91 | |
92 struct nap_data { | |
93 int fd; | |
94 int inpa; | |
95 | |
96 gchar *email; | |
97 GSList *channels; | |
98 GSList *requests; | |
99 GSList *browses; | |
100 }; | |
101 | |
102 static struct search_window *search_dialog = NULL; | |
103 | |
104 static char *nap_name() | |
105 { | |
106 return "Napster"; | |
107 } | |
108 | |
109 | |
110 /* FIXME: Make this use va_arg stuff */ | |
111 static void nap_write_packet(struct gaim_connection *gc, unsigned short command, char *message) | |
112 { | |
113 struct nap_data *ndata = (struct nap_data *)gc->proto_data; | |
114 unsigned short size; | |
115 | |
116 size = strlen(message); | |
117 write(ndata->fd, &size, 2); | |
118 write(ndata->fd, &command, 2); | |
119 write(ndata->fd, message, size); | |
120 | |
121 } | |
122 | |
123 static void nap_send_download_req(struct gaim_connection *gc, char *who, char *file) | |
124 { | |
125 struct nap_data *ndata = (struct nap_data *)gc->proto_data; | |
126 gchar buf[NAP_BUF_LEN]; | |
127 | |
128 g_snprintf(buf, NAP_BUF_LEN, "%s \"%s\"", who, file); | |
129 | |
130 printf("%s\n", buf); | |
131 printf("%d\n", ndata->fd); | |
132 nap_write_packet(gc, 0xCB, buf); | |
133 } | |
134 | |
135 // FIXME: These next two windows should really be together | |
136 // and should use the same clist style look too. | |
137 | |
138 static void nap_handle_download(GtkCList *clist, gint row, gint col, GdkEventButton *event, gpointer user_data) | |
139 { | |
140 gchar *results; | |
141 struct browse_window *bw = (struct browse_window *)user_data; | |
142 | |
143 gtk_clist_get_text(GTK_CLIST(clist), row, 0, &results); | |
144 | |
145 nap_send_download_req(bw->gc, bw->name, results); | |
146 | |
147 } | |
148 | |
149 static void nap_handle_download_search(GtkCList *clist, gint row, gint col, GdkEventButton *event, gpointer user_data) | |
150 { | |
151 gchar *filename; | |
152 gchar *nick; | |
153 | |
154 struct gaim_connection *gc = (struct gaim_connection *)user_data; | |
155 | |
156 filename = (gchar *)gtk_clist_get_row_data(GTK_CLIST(clist), row); | |
157 | |
158 gtk_clist_get_text(GTK_CLIST(clist), row, 1, &nick); | |
159 | |
160 printf("Trying to download: %s from %s\n", filename, nick); | |
161 nap_send_download_req(gc, nick, filename); | |
162 } | |
163 | |
164 static struct browse_window *browse_window_new(struct gaim_connection *gc, char *name) | |
165 { | |
166 struct browse_window *browse = g_new0(struct browse_window, 1); | |
167 struct nap_data *ndata = (struct nap_data *)gc->proto_data; | |
168 | |
169 browse->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
170 browse->name = g_strdup(name); | |
171 browse->list = gtk_clist_new(1); | |
172 browse->gc = gc; | |
173 | |
174 gtk_widget_show(browse->list); | |
175 gtk_container_add(GTK_CONTAINER(browse->window), browse->list); | |
176 | |
177 gtk_widget_set_usize(GTK_WIDGET(browse->window), 300, 250); | |
178 gtk_widget_show(browse->window); | |
179 | |
180 /*FIXME: I dont like using select-row. Im lazy. Ill fix it later */ | |
181 gtk_signal_connect(GTK_OBJECT(browse->list), "select-row", GTK_SIGNAL_FUNC(nap_handle_download), browse); | |
182 | |
183 ndata->browses = g_slist_append(ndata->browses, browse); | |
184 | |
185 return browse; | |
186 } | |
187 | |
188 static void browse_window_add_file(struct browse_window *bw, char *name) | |
189 { | |
190 char *fn[1]; | |
191 fn[0] = strdup(name); | |
192 printf("User '%s' has file '%s'\n", bw->name, name); | |
193 gtk_clist_append(GTK_CLIST(bw->list), fn); | |
194 | |
195 free(fn[0]); | |
196 } | |
197 | |
198 static struct browse_window *find_browse_window_by_name(struct gaim_connection *gc, char *name) | |
199 { | |
200 struct browse_window *browse; | |
201 struct nap_data *ndata = (struct nap_data *)gc->proto_data; | |
202 GSList *browses; | |
203 | |
204 browses = ndata->browses; | |
205 | |
206 while (browses) { | |
207 browse = (struct browse_window *)browses->data; | |
208 | |
209 if (browse) { | |
210 if (!g_strcasecmp(name, browse->name)) { | |
211 return browse; | |
212 } | |
213 } | |
214 browses = g_slist_next(browses); | |
215 } | |
216 | |
217 return NULL; | |
218 } | |
219 | |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
220 static int nap_send_im(struct gaim_connection *gc, char *who, char *message, int away) |
2086 | 221 { |
222 gchar buf[NAP_BUF_LEN]; | |
223 | |
224 g_snprintf(buf, NAP_BUF_LEN, "%s %s", who, message); | |
225 nap_write_packet(gc, 0xCD, buf); | |
2123
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
226 |
56c4382f2909
[gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
227 return 0; |
2086 | 228 } |
229 | |
230 static struct nap_channel *find_channel_by_name(struct gaim_connection *gc, char *name) | |
231 { | |
232 struct nap_channel *channel; | |
233 struct nap_data *ndata = (struct nap_data *)gc->proto_data; | |
234 GSList *channels; | |
235 | |
236 channels = ndata->channels; | |
237 | |
238 while (channels) { | |
239 channel = (struct nap_channel *)channels->data; | |
240 | |
241 if (channel) { | |
242 if (!g_strcasecmp(name, channel->name)) { | |
243 return channel; | |
244 } | |
245 } | |
246 channels = g_slist_next(channels); | |
247 } | |
248 | |
249 return NULL; | |
250 } | |
251 | |
252 static struct nap_channel *find_channel_by_id(struct gaim_connection *gc, int id) | |
253 { | |
254 struct nap_channel *channel; | |
255 struct nap_data *ndata = (struct nap_data *)gc->proto_data; | |
256 GSList *channels; | |
257 | |
258 channels = ndata->channels; | |
259 | |
260 while (channels) { | |
261 channel = (struct nap_channel *)channels->data; | |
262 if (id == channel->id) { | |
263 return channel; | |
264 } | |
265 | |
266 channels = g_slist_next(channels); | |
267 } | |
268 | |
269 return NULL; | |
270 } | |
271 | |
272 static struct conversation *find_conversation_by_id(struct gaim_connection *gc, int id) | |
273 { | |
274 GSList *bc = gc->buddy_chats; | |
275 struct conversation *b = NULL; | |
276 | |
277 while (bc) { | |
278 b = (struct conversation *)bc->data; | |
279 if (id == b->id) { | |
280 break; | |
281 } | |
282 bc = bc->next; | |
283 b = NULL; | |
284 } | |
285 | |
286 return b; | |
287 } | |
288 | |
289 /* This is a strange function. I smoke too many bad bad things :-) */ | |
290 static struct nap_file_request * find_request_by_fd(struct gaim_connection *gc, int fd) | |
291 { | |
292 struct nap_file_request *req; | |
293 struct nap_data *ndata = (struct nap_data *)gc->proto_data; | |
294 GSList *requests; | |
295 | |
296 requests = ndata->requests; | |
297 | |
298 while (requests) { | |
299 req = (struct nap_file_request *)requests->data; | |
300 | |
301 if (req) { | |
302 if (req->fd == fd) | |
303 return req; | |
304 } | |
305 requests = g_slist_next(requests); | |
306 } | |
307 | |
308 return NULL; | |
309 } | |
310 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
311 static void nap_ctc_callback(gpointer data, gint source, GaimInputCondition condition) |
2086 | 312 { |
313 struct gaim_connection *gc = (struct gaim_connection *)data; | |
314 struct nap_data *ndata = (struct nap_data *)gc->proto_data; | |
315 struct nap_file_request *req; | |
316 unsigned char *buf; | |
317 int i = 0; | |
318 | |
319 req = find_request_by_fd(gc, source); | |
320 if (!req) /* Something bad happened */ | |
321 return; | |
322 | |
323 buf = (char *)malloc(sizeof(char) * (NAP_BUF_LEN + 1)); | |
324 | |
325 if (req->status == 0) | |
326 { | |
327 int j; | |
328 gchar tmp[32]; | |
329 long filesize; | |
330 gchar **parse_name; | |
331 gchar path[2048]; | |
332 GtkWidget *hbox; | |
333 GtkWidget *vbox; | |
334 GtkWidget *label; | |
335 gchar *buf2; | |
336 | |
337 recv(source, buf, 1, 0); | |
338 | |
339 /* We should receive a '1' upon connection */ | |
340 if (buf[0] != '1') | |
341 { | |
342 do_error_dialog("Uh Oh", "Uh Oh"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
343 gaim_input_remove(req->inpa); |
2086 | 344 ndata->requests = g_slist_remove(ndata->requests, req); |
345 g_free(req->name); | |
346 g_free(req->file); | |
347 close(source); | |
348 g_free(req); | |
349 free(buf); | |
350 return; | |
351 } | |
352 | |
353 /* Lets take a peek at the awaiting data */ | |
354 i = recv(source, buf, NAP_BUF_LEN, MSG_PEEK); | |
355 buf[i] = 0; /* Make sure that we terminate our string */ | |
356 | |
357 /* Looks like the uploader sent the proper data. Let's see how big the | |
358 * file is */ | |
359 | |
360 for (j = 0, i = 0; isdigit(buf[i]); i++, j++) | |
361 { | |
362 tmp[j] = buf[i]; | |
363 } | |
364 tmp[j] = 0; | |
365 filesize = atol(tmp); | |
366 | |
367 /* Save the size of the file */ | |
368 req->total = filesize; | |
369 | |
370 /* If we have a zero file size then something bad happened */ | |
371 if (filesize == 0) { | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
372 gaim_input_remove(req->inpa); |
2086 | 373 ndata->requests = g_slist_remove(ndata->requests, req); |
374 g_free(req->name); | |
375 g_free(req->file); | |
376 g_free(req); | |
377 free(buf); | |
378 close(source); | |
379 return; | |
380 } | |
381 | |
382 /* Now that we've done that, let's go ahead and read that | |
383 * data to get it out of the way */ | |
384 recv(source, buf, strlen(tmp), 0); | |
385 | |
386 /* Now, we should tell the server that we're download something */ | |
387 nap_write_packet(gc, 0xda, "\n"); | |
388 | |
389 req->status = 1; | |
390 | |
391 /* FIXME: We dont want to force the file name. I'll parse this | |
392 * later */ | |
393 | |
394 parse_name = g_strsplit(req->file, "\\", 0); | |
395 g_snprintf(path, sizeof(path), "%s/%s", getenv("HOME"), parse_name[sizeof(parse_name)]); | |
396 printf("Gonna try to save to: %s\n", path); | |
397 g_strfreev(parse_name); | |
398 | |
399 req->mp3 = fopen(path, "w"); | |
400 | |
401 req->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
402 | |
403 vbox = gtk_vbox_new(FALSE, 5); | |
404 | |
405 buf2 = (gchar *)g_malloc(sizeof(gchar) * (strlen(req->file) + 33)); | |
406 g_snprintf(buf2, strlen(req->file) + 32, "Downloading File: %s", req->file); | |
407 label = gtk_label_new(buf2); | |
408 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 5); | |
409 | |
410 req->progress = gtk_progress_bar_new(); | |
411 gtk_progress_bar_update(GTK_PROGRESS_BAR(req->progress), 0); | |
412 gtk_progress_configure(GTK_PROGRESS(req->progress), 0, 0, (float)req->total/(float)1024); | |
413 gtk_progress_set_format_string(GTK_PROGRESS(req->progress), "%P%% (%VKB / %UKB)"); | |
414 gtk_progress_set_show_text(GTK_PROGRESS(req->progress), TRUE); | |
415 gtk_box_pack_start(GTK_BOX(vbox), req->progress, FALSE, FALSE, 5); | |
416 | |
417 hbox = gtk_hbox_new(TRUE, 5); | |
418 | |
419 req->ok = gtk_button_new_with_label("Ok"); | |
420 req->cancel = gtk_button_new_with_label("Cancel"); | |
421 | |
422 gtk_box_pack_end(GTK_BOX(hbox), req->cancel, FALSE, FALSE, 5); | |
423 gtk_box_pack_end(GTK_BOX(hbox), req->ok, FALSE, FALSE, 5); | |
424 | |
425 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
426 | |
427 gtk_container_add(GTK_CONTAINER(req->window), vbox); | |
428 | |
429 gtk_widget_show_all(req->window); | |
430 | |
431 free(buf); | |
432 return; | |
433 } | |
434 | |
435 /* Looks like our status isn't 1. It's safe to assume we're downloadin' */ | |
436 i = recv(source, buf, NAP_BUF_LEN, 0); | |
437 | |
438 req->size += i; /* Lets add up the total */ | |
439 | |
440 // printf("Downloaded %ld of %ld (%f)\n", req->size, req->total, (float)req->size/(float)req->total); | |
441 | |
442 gtk_progress_bar_update(GTK_PROGRESS_BAR(req->progress), (float)req->size/(float)req->total); | |
443 | |
444 while (gtk_events_pending()) | |
445 gtk_main_iteration(); | |
446 | |
447 fwrite(buf, i, sizeof(char), req->mp3); | |
448 | |
449 free(buf); | |
450 | |
451 if (req->size >= req->total) { | |
452 printf("Download complete.\n"); | |
453 nap_write_packet(gc, 0xdb, "\n"); /* Tell the server we're finished */ | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
454 gaim_input_remove(req->inpa); |
2086 | 455 |
456 ndata->requests = g_slist_remove(ndata->requests, req); | |
457 | |
458 if (req->name != NULL) | |
459 g_free(req->name); | |
460 | |
461 if (req->file != NULL) | |
462 g_free(req->file); | |
463 | |
464 g_free(req); | |
465 fclose(req->mp3); | |
466 close(source); | |
467 } | |
468 } | |
469 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
470 static void nap_get_file_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 471 { |
472 char buf[NAP_BUF_LEN]; | |
473 struct nap_file_request *req = data; | |
474 struct gaim_connection *gc = req->gc; | |
475 struct nap_data *ndata = (struct nap_data *)gc->proto_data; | |
476 | |
477 if (source < 0) { | |
478 do_error_dialog("Error connecting to user", "Gaim: Napster error"); | |
479 g_free(req->name); | |
480 g_free(req->file); | |
481 g_free(req); | |
482 return; | |
483 } | |
484 | |
485 if (req->fd != source) | |
486 req->fd = source; | |
487 | |
488 send(req->fd, "GET", 3, 0); | |
489 | |
490 /* Send our request to the user */ | |
491 g_snprintf(buf, sizeof(buf), "%s \"%s\" 0", gc->username, req->file); | |
492 | |
493 send(req->fd, buf, strlen(buf), 0); | |
494 | |
495 /* Add our request */ | |
496 ndata->requests = g_slist_append(ndata->requests, req); | |
497 | |
498 /* And start monitoring */ | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
499 req->inpa = gaim_input_add(req->fd, GAIM_INPUT_READ, nap_ctc_callback, gc); |
2086 | 500 } |
501 | |
502 static void nap_get_file(struct gaim_connection *gc, gchar *user, gchar *file, gchar *host, unsigned int port) | |
503 { | |
504 struct nap_file_request *req = g_new0(struct nap_file_request, 1); | |
505 | |
506 req->name = g_strdup(user); | |
507 req->file = g_strdup(file); | |
508 req->size = 0; | |
509 req->status = 0; | |
510 req->total = 0; | |
511 req->gc = gc; | |
512 | |
513 /* Make a connection with the server */ | |
514 req->fd = proxy_connect(host, port, nap_get_file_connect, req); | |
515 if (req->fd < 0) { | |
516 do_error_dialog("Error connecting to user", "Gaim: Napster error"); | |
517 g_free(req->name); | |
518 g_free(req->file); | |
519 g_free(req); | |
520 } | |
521 } | |
522 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
523 static void nap_callback(gpointer data, gint source, GaimInputCondition condition) |
2086 | 524 { |
525 struct gaim_connection *gc = data; | |
526 struct nap_data *ndata = gc->proto_data; | |
527 gchar *buf; | |
528 unsigned short header[2]; | |
529 int len; | |
530 int command; | |
531 gchar **res; | |
532 | |
533 recv(source, header, 4, 0); | |
534 // read(source, header, 4); | |
535 len = header[0]; | |
536 command = header[1]; | |
537 | |
538 buf = (gchar *)g_malloc(sizeof(gchar) * (len + 1)); | |
539 | |
540 // read(source, buf, len); | |
541 recv(source, buf, len, 0); | |
542 | |
543 buf[len] = 0; | |
544 | |
545 printf("DEBUG: %s\n", buf); | |
546 | |
547 if (command == 0xd6) { | |
548 res = g_strsplit(buf, " ", 0); | |
549 /* Do we want to report what the users are doing? */ | |
550 printf("users: %s, files: %s, size: %sGB\n", res[0], res[1], res[2]); | |
551 g_strfreev(res); | |
552 free(buf); | |
553 return; | |
554 } | |
555 | |
556 if (command == 0x26d) { | |
557 /* Do we want to use the MOTD? */ | |
558 free(buf); | |
559 return; | |
560 } | |
561 | |
562 if (command == 0xCD) { | |
563 res = g_strsplit(buf, " ", 1); | |
564 serv_got_im(gc, res[0], res[1], 0, time((time_t)NULL)); | |
565 g_strfreev(res); | |
566 free(buf); | |
567 return; | |
568 } | |
569 | |
570 if (command == 0x195) { | |
571 struct nap_channel *channel; | |
572 | |
573 channel = find_channel_by_name(gc, buf); | |
574 | |
575 if (!channel) { | |
576 chat_id++; | |
577 | |
578 channel = g_new0(struct nap_channel, 1); | |
579 | |
580 channel->id = chat_id; | |
581 channel->name = g_strdup(buf); | |
582 | |
583 ndata->channels = g_slist_append(ndata->channels, channel); | |
584 | |
585 serv_got_joined_chat(gc, chat_id, buf); | |
586 } | |
587 | |
588 free(buf); | |
589 return; | |
590 } | |
591 | |
592 if (command == 0x198 || command == 0x196) { | |
593 struct nap_channel *channel; | |
594 struct conversation *convo; | |
595 gchar **res; | |
596 | |
597 res = g_strsplit(buf, " ", 0); | |
598 | |
599 channel = find_channel_by_name(gc, res[0]); | |
600 convo = find_conversation_by_id(gc, channel->id); | |
601 | |
602 add_chat_buddy(convo, res[1]); | |
603 | |
604 g_strfreev(res); | |
605 | |
606 free(buf); | |
607 return; | |
608 } | |
609 | |
610 if (command == 0x197) { | |
611 struct nap_channel *channel; | |
612 struct conversation *convo; | |
613 gchar **res; | |
614 | |
615 res = g_strsplit(buf, " ", 0); | |
616 | |
617 channel = find_channel_by_name(gc, res[0]); | |
618 convo = find_conversation_by_id(gc, channel->id); | |
619 | |
620 remove_chat_buddy(convo, res[1]); | |
621 | |
622 g_strfreev(res); | |
623 free(buf); | |
624 return; | |
625 } | |
626 | |
627 if (command == 0x193) { | |
628 gchar **res; | |
629 struct nap_channel *channel; | |
630 | |
631 res = g_strsplit(buf, " ", 2); | |
632 | |
633 channel = find_channel_by_name(gc, res[0]); | |
634 | |
635 if (channel) | |
636 serv_got_chat_in(gc, channel->id, res[1], 0, res[2], time((time_t)NULL)); | |
637 | |
638 g_strfreev(res); | |
639 free(buf); | |
640 return; | |
641 } | |
642 | |
643 if (command == 0x194) { | |
644 do_error_dialog(buf, "Gaim: Napster Error"); | |
645 free(buf); | |
646 return; | |
647 } | |
648 | |
649 if (command == 0x12e) { | |
650 gchar buf2[NAP_BUF_LEN]; | |
651 | |
652 g_snprintf(buf2, NAP_BUF_LEN, "Unable to add '%s' to your hotlist", buf); | |
653 do_error_dialog(buf2, "Gaim: Napster Error"); | |
654 | |
655 free(buf); | |
656 return; | |
657 | |
658 } | |
659 | |
660 if (command == 0x191) { | |
661 struct nap_channel *channel; | |
662 | |
663 channel = find_channel_by_name(gc, buf); | |
664 | |
665 if (!channel) /* I'm not sure how this would happen =) */ | |
666 return; | |
667 | |
668 serv_got_chat_left(gc, channel->id); | |
669 ndata->channels = g_slist_remove(ndata->channels, channel); | |
670 | |
671 free(buf); | |
672 return; | |
673 | |
674 } | |
675 | |
676 if (command == 0xd1) { | |
677 gchar **res; | |
678 | |
679 res = g_strsplit(buf, " ", 0); | |
680 | |
681 serv_got_update(gc, res[0], 1, 0, 0, 0, 0, 0); | |
682 | |
683 g_strfreev(res); | |
684 free(buf); | |
685 return; | |
686 } | |
687 | |
688 if (command == 0xd2) { | |
689 serv_got_update(gc, buf, 0, 0, 0, 0, 0, 0); | |
690 free(buf); | |
691 return; | |
692 } | |
693 | |
694 if (command == 0xd4) { | |
695 /* Looks like we're getting a browse response */ | |
696 gchar user[64]; | |
697 gchar file[2048]; | |
698 struct browse_window *bw = NULL; | |
699 | |
700 int i,j; | |
701 | |
702 for (i = 0, j = 0; buf[i] != ' '; i++, j++) | |
703 { | |
704 user[j] = buf[i]; | |
705 } | |
706 user[j] = 0; i++; i++; | |
707 | |
708 for (j = 0; buf[i] != '\"'; i++, j++) | |
709 { | |
710 file[j] = buf[i]; | |
711 } | |
712 file[j] = 0; | |
713 | |
714 bw = find_browse_window_by_name(gc, user); | |
715 if (!bw) | |
716 { | |
717 /* If a browse window isn't found, let's create one */ | |
718 bw = browse_window_new(gc, user); | |
719 } | |
720 | |
721 browse_window_add_file(bw, file); | |
722 | |
723 free(buf); | |
724 return; | |
725 | |
726 } | |
727 | |
728 if (command == 0xc9) { | |
729 /* We've received a search response */ | |
730 gchar *file = (gchar *)g_malloc(sizeof(gchar) * (NAP_BUF_LEN+1)); | |
731 gchar *tmp; | |
732 gchar rest[NAP_BUF_LEN]; | |
733 gchar *data[5]; | |
734 gchar **parse_name; | |
735 | |
736 int i, j; | |
737 | |
738 for (i = 1, j = 0; ((buf[i] != '\"') && (buf[i] != 0)); i++, j++) | |
739 { | |
740 file[j] = buf[i]; | |
741 } | |
742 | |
743 file[j] = 0; i++; | |
744 | |
745 tmp = (gchar *)g_malloc(sizeof(gchar) * (strlen(file) + 1)); | |
746 strcpy(tmp, rindex(file, '\\')+1); | |
747 | |
748 strcpy(rest, buf+i); | |
749 | |
750 parse_name = g_strsplit(rest, " ", 0); | |
751 | |
752 data[0] = g_strdup(tmp); | |
753 data[1] = g_strdup(parse_name[6]); | |
754 data[2] = g_strdup(parse_name[2]); | |
755 data[3] = g_strdup(parse_name[3]); | |
756 data[4] = g_strdup(parse_name[8]); | |
757 | |
758 // printf("File: %s, 1: %s, 2: %s, 3: %s\n", data[0], data[1], data[2], data[3]); | |
759 i = gtk_clist_append(GTK_CLIST(search_dialog->list), data); | |
760 | |
761 gtk_clist_set_row_data(GTK_CLIST(search_dialog->list), i, file); | |
762 g_strfreev(parse_name); | |
763 // g_free(file); | |
764 g_free(tmp); | |
765 g_free(buf); | |
766 return; | |
767 } | |
768 | |
769 if (command == 0xca) | |
770 { | |
771 /* End of search */ | |
772 g_free(buf); | |
773 return; | |
774 } | |
775 | |
776 if (command == 0x12d) { | |
777 /* Our buddy was added successfully */ | |
778 free(buf); | |
779 return; | |
780 } | |
781 | |
782 if (command == 0x2ec) { | |
783 /* Looks like someone logged in as us! =-O */ | |
784 free(buf); | |
785 | |
786 signoff(gc); | |
787 return; | |
788 } | |
789 | |
790 if (command == 0xcc) { | |
791 /* We received a Download ACK from a user. The way this is printed is kind of | |
792 * strange so we'll need to parse this one ourselves. */ | |
793 | |
794 gchar user[64]; | |
795 gchar file[2048]; | |
796 gchar hoststr[16]; | |
797 gchar portstr[16]; | |
798 int i,j; | |
799 | |
800 for (i = 0, j = 0; buf[i] != ' '; i++, j++) | |
801 { | |
802 user[j] = buf[i]; | |
803 } | |
804 user[j] = 0; i++; | |
805 | |
806 for (j = 0; buf[i] != ' '; i++, j++) | |
807 { | |
808 hoststr[j] = buf[i]; | |
809 } | |
810 hoststr[j] = 0; i++; | |
811 | |
812 for (j = 0; buf[i] != ' '; i++, j++) | |
813 { | |
814 portstr[j] = buf[i]; | |
815 } | |
816 portstr[j] = 0; i++; | |
817 | |
818 i++; /* We do this to ignore the first quotation mark */ | |
819 | |
820 for (j = 0; buf[i] != '\"'; i++, j++) | |
821 { | |
822 file[j] = buf[i]; | |
823 } | |
824 file[j] = 0; | |
825 | |
826 /* Aaight. We dont need nuttin' else. Let's download the file */ | |
827 nap_get_file(gc, user, file, hoststr, atoi(portstr)); | |
828 | |
829 free(buf); | |
830 | |
831 return; | |
832 } | |
833 | |
834 printf("NAP: [COMMAND: 0x%04x] %s\n", command, buf); | |
835 | |
836 free(buf); | |
837 } | |
838 | |
839 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
840 static void nap_login_callback(gpointer data, gint source, GaimInputCondition condition) |
2086 | 841 { |
842 struct gaim_connection *gc = data; | |
843 struct nap_data *ndata = gc->proto_data; | |
844 gchar buf[NAP_BUF_LEN]; | |
845 unsigned short header[2]; | |
846 int len; | |
847 int command; | |
848 | |
849 read(source, header, 4); | |
850 len = header[0]; | |
851 command = header[1]; | |
852 | |
853 read(source, buf, len); | |
854 buf[len] = 0; | |
855 | |
856 /* If we have some kind of error, get outta here */ | |
857 if (command == 0x00) | |
858 { | |
859 do_error_dialog(buf, "Gaim: Napster Error"); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
860 gaim_input_remove(ndata->inpa); |
2086 | 861 ndata->inpa = 0; |
862 close(source); | |
863 signoff(gc); | |
864 return; | |
865 } | |
866 | |
867 if (command == 0x03) { | |
868 printf("Registered with E-Mail address of: %s\n", buf); | |
869 ndata->email = g_strdup(buf); | |
870 | |
871 /* Remove old inpa, add new one */ | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
872 gaim_input_remove(ndata->inpa); |
2086 | 873 ndata->inpa = 0; |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
874 gc->inpa = gaim_input_add(ndata->fd, GAIM_INPUT_READ, nap_callback, gc); |
2086 | 875 |
876 /* Our signon is complete */ | |
877 account_online(gc); | |
878 serv_finish_login(gc); | |
879 | |
880 if (bud_list_cache_exists(gc)) | |
881 do_import(NULL, gc); | |
882 | |
883 return; | |
884 } | |
885 } | |
886 | |
887 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
888 static void nap_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 889 { |
890 struct gaim_connection *gc = data; | |
891 struct nap_data *ndata = gc->proto_data; | |
892 char buf[NAP_BUF_LEN]; | |
893 | |
894 if (source < 0) { | |
895 hide_login_progress(gc, "Unable to connect"); | |
896 signoff(gc); | |
897 return; | |
898 } | |
899 | |
900 if (ndata->fd != source) | |
901 ndata->fd = source; | |
902 | |
903 /* And write our signon data */ | |
904 g_snprintf(buf, NAP_BUF_LEN, "%s %s 0 \"gaimster\" 0", gc->username, gc->password); | |
905 nap_write_packet(gc, 0x02, buf); | |
906 | |
907 /* And set up the input watcher */ | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
908 ndata->inpa = gaim_input_add(ndata->fd, GAIM_INPUT_READ, nap_login_callback, gc); |
2086 | 909 } |
910 | |
911 | |
912 static void nap_login(struct aim_user *user) | |
913 { | |
914 struct gaim_connection *gc = new_gaim_conn(user); | |
915 struct nap_data *ndata = gc->proto_data = g_new0(struct nap_data, 1); | |
916 | |
917 ndata->fd = proxy_connect("64.124.41.187", 8888, nap_login_connect, gc); | |
918 if (ndata->fd < 0) { | |
919 hide_login_progress(gc, "Unable to connect"); | |
920 signoff(gc); | |
921 } | |
922 } | |
923 | |
924 static void nap_join_chat(struct gaim_connection *gc, int id, char *name) | |
925 { | |
926 gchar buf[NAP_BUF_LEN]; | |
927 | |
928 /* Make sure the name has a # preceeding it */ | |
929 if (name[0] != '#') | |
930 g_snprintf(buf, NAP_BUF_LEN, "#%s", name); | |
931 else | |
932 g_snprintf(buf, NAP_BUF_LEN, "%s", name); | |
933 | |
934 nap_write_packet(gc, 0x190, buf); | |
935 } | |
936 | |
937 static void nap_chat_leave(struct gaim_connection *gc, int id) | |
938 { | |
939 struct nap_data *ndata = (struct nap_data *)gc->proto_data; | |
940 struct nap_channel *channel = NULL; | |
941 | |
942 channel = find_channel_by_id(gc, id); | |
943 | |
944 if (!channel) /* Again, I'm not sure how this would happen */ | |
945 return; | |
946 | |
947 nap_write_packet(gc, 0x191, channel->name); | |
948 | |
949 ndata->channels = g_slist_remove(ndata->channels, channel); | |
950 g_free(channel->name); | |
951 g_free(channel); | |
952 | |
953 } | |
954 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
955 static int nap_chat_send(struct gaim_connection *gc, int id, char *message) |
2086 | 956 { |
957 struct nap_channel *channel = NULL; | |
958 gchar buf[NAP_BUF_LEN]; | |
959 | |
960 channel = find_channel_by_id(gc, id); | |
961 | |
962 if (!channel) { | |
963 /* This shouldn't happen */ | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
964 return -EINVAL; |
2086 | 965 } |
966 | |
967 g_snprintf(buf, NAP_BUF_LEN, "%s %s", channel->name, message); | |
968 nap_write_packet(gc, 0x192, buf); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
969 return 0; |
2086 | 970 } |
971 | |
972 static void nap_add_buddy(struct gaim_connection *gc, char *name) | |
973 { | |
974 nap_write_packet(gc, 0xCF, name); | |
975 } | |
976 | |
977 static void nap_remove_buddy(struct gaim_connection *gc, char *name) | |
978 { | |
979 nap_write_packet(gc, 0x12F, name); | |
980 } | |
981 | |
982 static void nap_close(struct gaim_connection *gc) | |
983 { | |
984 struct nap_data *ndata = (struct nap_data *)gc->proto_data; | |
985 struct nap_channel *channel; | |
986 struct browse_window *browse; | |
987 struct nap_file_request *req; | |
988 | |
989 if (gc->inpa) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
990 gaim_input_remove(gc->inpa); |
2086 | 991 |
992 while (ndata->channels) { | |
993 channel = (struct nap_channel *)ndata->channels->data; | |
994 g_free(channel->name); | |
995 ndata->channels = g_slist_remove(ndata->channels, channel); | |
996 g_free(channel); | |
997 } | |
998 | |
999 while (ndata->browses) { | |
1000 browse = (struct browse_window *)ndata->browses->data; | |
1001 g_free(browse->name); | |
1002 gtk_widget_destroy(browse->window); | |
1003 ndata->browses = g_slist_remove(ndata->browses, browse); | |
1004 g_free(browse); | |
1005 } | |
1006 | |
1007 while (ndata->requests) { | |
1008 req = (struct nap_file_request *)ndata->requests->data; | |
1009 g_free(req->name); | |
1010 g_free(req->file); | |
1011 if (req->inpa) { | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1012 gaim_input_remove(req->inpa); |
2086 | 1013 } |
1014 ndata->requests = g_slist_remove(ndata->requests, req); | |
1015 g_free(req); | |
1016 | |
1017 } | |
1018 | |
1019 free(gc->proto_data); | |
1020 } | |
1021 | |
1022 static void nap_add_buddies(struct gaim_connection *gc, GList *buddies) | |
1023 { | |
1024 while (buddies) { | |
1025 nap_write_packet(gc, 0xd0, (char *)buddies->data); | |
1026 buddies = buddies -> next; | |
1027 } | |
1028 } | |
1029 | |
1030 static void nap_draw_new_user(GtkWidget *box) | |
1031 { | |
1032 GtkWidget *label; | |
1033 | |
1034 label = gtk_label_new(_("Napster registration is currently under development")); | |
1035 | |
1036 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
1037 gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5); | |
1038 gtk_widget_show(label); | |
1039 } | |
1040 | |
1041 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1042 static void nap_send_browse(struct gaim_connection *gc, char *who) |
2086 | 1043 { |
1044 gchar buf[NAP_BUF_LEN]; | |
1045 | |
1046 g_snprintf(buf, NAP_BUF_LEN, "%s", who); | |
1047 nap_write_packet(gc, 0xd3, buf); | |
1048 } | |
1049 | |
1050 static void nap_find_callback(GtkObject *w, GtkWidget *entry) | |
1051 { | |
1052 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w); | |
1053 const gchar *search; | |
1054 gchar buf[NAP_BUF_LEN]; | |
1055 | |
1056 search = gtk_entry_get_text(GTK_ENTRY(entry)); | |
1057 g_snprintf(buf, NAP_BUF_LEN, "FILENAME CONTAINS \"%s\" MAX_RESULTS 50", search); | |
1058 | |
1059 nap_write_packet(gc, 0xc8, buf); | |
1060 } | |
1061 | |
1062 static void destroy_window(GtkObject *w, GtkWidget *win) | |
1063 { | |
1064 gtk_widget_destroy(win); | |
1065 } | |
1066 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1067 static void nap_show_search(struct gaim_connection *gc, char *omit) |
2086 | 1068 { |
1069 if (!search_dialog) | |
1070 { | |
1071 GtkWidget *window; | |
1072 GtkWidget *sw; | |
1073 GtkWidget *vbox; | |
1074 GtkWidget *hbox; | |
1075 GtkWidget *label; | |
1076 GtkWidget *button; | |
1077 GtkWidget *entry; | |
1078 GtkWidget *list; | |
1079 gchar *titles[5] = {"Mp3 Name", "Nick", "Size", "Bitrate", "Connection"}; | |
1080 search_dialog = g_new0(struct search_window, 1); | |
1081 | |
1082 window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1083 | |
1084 vbox = gtk_vbox_new(FALSE, 0); | |
1085 | |
1086 /* First Line */ | |
1087 hbox = gtk_hbox_new(FALSE, 5); | |
1088 label = gtk_label_new("Search for:"); | |
1089 gtk_widget_show(label); | |
1090 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
1091 | |
1092 entry = gtk_entry_new(); | |
1093 gtk_widget_show(entry); | |
1094 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5); | |
1095 | |
1096 button = gtk_button_new_with_label("Find"); | |
1097 gtk_widget_show(button); | |
1098 gtk_object_set_user_data(GTK_OBJECT(button), gc); | |
1099 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(nap_find_callback), entry); | |
1100 | |
1101 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5); | |
1102 | |
1103 button = gtk_button_new_with_label("Cancel"); | |
1104 gtk_widget_show(button); | |
1105 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5); | |
1106 | |
1107 | |
1108 gtk_widget_show(hbox); | |
1109 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
1110 /* End First List */ | |
1111 | |
1112 /* Second Line */ | |
1113 | |
1114 sw = gtk_scrolled_window_new(NULL, NULL); | |
1115 | |
1116 list = gtk_clist_new_with_titles(5, titles); | |
1117 | |
1118 gtk_clist_column_titles_show(GTK_CLIST(list)); | |
1119 | |
1120 gtk_signal_connect(GTK_OBJECT(list), "select-row", GTK_SIGNAL_FUNC(nap_handle_download_search), gc); | |
1121 | |
1122 gtk_container_add(GTK_CONTAINER(sw), list); | |
1123 gtk_widget_show(list); | |
1124 | |
1125 gtk_box_pack_start(GTK_BOX(vbox), sw, FALSE, FALSE, 5); | |
1126 | |
1127 gtk_widget_show(sw); | |
1128 | |
1129 /* End Second Line */ | |
1130 | |
1131 gtk_widget_show(vbox); | |
1132 | |
1133 gtk_container_add(GTK_CONTAINER(window), vbox); | |
1134 gtk_container_set_border_width(GTK_CONTAINER(window), 10); | |
1135 | |
1136 gtk_widget_set_usize(GTK_WIDGET(list), 500, 350); | |
1137 gtk_widget_set_usize(GTK_WIDGET(window), 500, 400); | |
1138 | |
1139 gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(destroy_window), window); | |
1140 gtk_widget_show(window); | |
1141 | |
1142 search_dialog->window = window; | |
1143 search_dialog->list = list; | |
1144 } | |
1145 | |
1146 gtk_widget_show(search_dialog->window); | |
1147 } | |
1148 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1149 static GList *nap_buddy_menu(struct gaim_connection *gc, char *who) |
2086 | 1150 { |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1151 GList *m = NULL; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1152 struct proto_buddy_menu *pbm; |
2086 | 1153 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1154 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1155 pbm->label = _("Browse Files"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1156 pbm->callback = nap_send_browse; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1157 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1158 m = g_list_append(m, pbm); |
2086 | 1159 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1160 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1161 pbm->label = _("Search Napster"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1162 pbm->callback = nap_show_search; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1163 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1164 m = g_list_append(m, pbm); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1165 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1166 return m; |
2086 | 1167 } |
1168 | |
1169 static char** nap_list_icon(int uc) | |
1170 { | |
1171 return napster_xpm; | |
1172 } | |
1173 | |
1174 static struct prpl *my_protocol = NULL; | |
1175 | |
1176 void napster_init(struct prpl *ret) | |
1177 { | |
1178 ret->protocol = PROTO_NAPSTER; | |
1179 ret->name = nap_name; | |
1180 ret->list_icon = nap_list_icon; | |
1181 ret->buddy_menu = nap_buddy_menu; | |
1182 ret->user_opts = NULL; | |
1183 ret->login = nap_login; | |
1184 ret->close = nap_close; | |
1185 ret->send_im = nap_send_im; | |
1186 ret->set_info = NULL; | |
1187 ret->get_info = NULL; | |
1188 ret->set_away = NULL; | |
1189 ret->get_away_msg = NULL; | |
1190 ret->set_dir = NULL; | |
1191 ret->get_dir = NULL; | |
1192 ret->dir_search = NULL; | |
1193 ret->set_idle = NULL; | |
1194 ret->change_passwd = NULL; | |
1195 ret->add_buddy = nap_add_buddy; | |
1196 ret->add_buddies = nap_add_buddies; | |
1197 ret->remove_buddy = nap_remove_buddy; | |
1198 ret->add_permit = NULL; | |
1199 ret->rem_permit = NULL; | |
1200 ret->add_deny = NULL; | |
1201 ret->rem_deny = NULL; | |
1202 ret->warn = NULL; | |
1203 ret->accept_chat = NULL; | |
1204 ret->join_chat = nap_join_chat; | |
1205 ret->chat_invite = NULL; | |
1206 ret->chat_leave = nap_chat_leave; | |
1207 ret->chat_whisper = NULL; | |
1208 ret->chat_send = nap_chat_send; | |
1209 ret->keepalive = NULL; | |
1210 ret->draw_new_user = nap_draw_new_user; | |
1211 | |
1212 my_protocol = ret; | |
1213 } | |
1214 | |
1215 #ifndef STATIC | |
1216 | |
1217 char *gaim_plugin_init(GModule * handle) | |
1218 { | |
1219 load_protocol(napster_init, sizeof(struct prpl)); | |
1220 return NULL; | |
1221 } | |
1222 | |
1223 void gaim_plugin_remove() | |
1224 { | |
1225 struct prpl *p = find_prpl(PROTO_NAPSTER); | |
1226 if (p == my_protocol) | |
1227 unload_protocol(p); | |
1228 } | |
1229 | |
1230 char *name() | |
1231 { | |
1232 return "Napster"; | |
1233 } | |
1234 | |
1235 char *description() | |
1236 { | |
2162
a464da684307
[gaim-migrate @ 2172]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
1237 return PRPL_DESC("Napster"); |
2086 | 1238 } |
1239 | |
1240 #endif |