annotate plugins/napster.c @ 1437:1f0660a2c893

[gaim-migrate @ 1447] i'm in a fucking bad mood committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sun, 28 Jan 2001 23:11:57 +0000
parents 28278bd61403
children 336fc98b7f90
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
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
51 struct search_window {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
52 GtkWidget *window;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
53 GtkWidget *list;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
54 };
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
55
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
56 struct browse_window {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
57 GtkWidget *window;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
58 GtkWidget *list;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
59 struct gaim_connection *gc;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
60 char *name;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
61 };
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
62
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
63 struct nap_download_box {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
64 GtkWidget *window;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
65 GtkWidget *ok;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
66 GtkWidget *entry;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
67 gchar *who;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
68 };
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
69
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
70 struct nap_channel {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
71 unsigned int id;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
72 gchar *name;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
73 };
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
74
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
75 struct nap_file_request {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
76 gchar *name;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
77 gchar *file;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
78 int fd;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
79 long size;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
80 long total;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
81 int status;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
82 int inpa;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
83 FILE *mp3;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
84 };
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
85
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
86 struct nap_data {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
87 int fd;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
88 int inpa;
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 gchar *email;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
91 GSList *channels;
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
92 GSList *requests;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
93 GSList *browses;
1323
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
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
96 static struct search_window *search_dialog = NULL;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
97
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
98 static char *nap_name()
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 return "Napster";
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
101 }
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 char *name()
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 return "Napster";
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
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
108 char *description()
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 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
111 }
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
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
114 /* FIXME: Make this use va_arg stuff */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
115 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
116 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
117 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
118 unsigned short size;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
119
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
120 size = strlen(message);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
121
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
122 write(ndata->fd, &size, 2);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
123 write(ndata->fd, &command, 2);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
124 write(ndata->fd, message, size);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
125 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
126
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
127 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
128 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
129 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
130 gchar buf[NAP_BUF_LEN];
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 g_snprintf(buf, NAP_BUF_LEN, "%s \"%s\"", who, file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
133
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
134 printf("%s\n", buf);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
135 printf("%d\n", ndata->fd);
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
136 nap_write_packet(gc, 0xCB, buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
137 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
138
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
139 // FIXME: These next two windows should really be together
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
140 // and should use the same clist style look too.
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
141
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
142 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
143 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
144 gchar **results;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
145 struct browse_window *bw = (struct browse_window *)user_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
146
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
147 gtk_clist_get_text(GTK_CLIST(clist), row, 0, results);
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
148
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
149 nap_send_download_req(bw->gc, bw->name, results[0]);
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 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
152
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
153 void nap_handle_download_search(GtkCList *clist, gint row, gint col, GdkEventButton *event, gpointer user_data)
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
154 {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
155 gchar *filename;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
156 gchar *nick;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
157
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
158 int i = 0;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
159 struct gaim_connection *gc = (struct gaim_connection *)user_data;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
160
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
161 filename = (gchar *)gtk_clist_get_row_data(GTK_CLIST(clist), row);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
162
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
163 gtk_clist_get_text(GTK_CLIST(clist), row, 1, &nick);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
164
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
165 printf("Trying to download: %s from %s\n", filename, nick);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
166 nap_send_download_req(gc, nick, filename);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
167 }
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
168
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
169 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
170 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
171 struct browse_window *browse = g_new0(struct browse_window, 1);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
172 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
173
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
174 browse->window = gtk_window_new(GTK_WINDOW_DIALOG);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
175 browse->name = g_strdup(name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
176 browse->list = gtk_clist_new(1);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
177 browse->gc = gc;
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 gtk_widget_show(browse->list);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
180 gtk_container_add(GTK_CONTAINER(browse->window), browse->list);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
181
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
182 gtk_widget_set_usize(GTK_WIDGET(browse->window), 300, 250);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
183 gtk_widget_show(browse->window);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
184
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
185 /*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
186 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
187
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
188 ndata->browses = g_slist_append(ndata->browses, browse);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
189 }
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 void browse_window_add_file(struct browse_window *bw, char *name)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
192 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
193 char *fn[1];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
194 fn[0] = strdup(name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
195 printf("User '%s' has file '%s'\n", bw->name, name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
196 gtk_clist_append(GTK_CLIST(bw->list), fn);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
197
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
198 free(fn[0]);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
199 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
200
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
201 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
202 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
203 struct browse_window *browse;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
204 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
205 GSList *browses;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
206
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
207 browses = ndata->browses;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
208
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
209 while (browses) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
210 browse = (struct browse_window *)browses->data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
211
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
212 if (browse) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
213 if (!g_strcasecmp(name, browse->name)) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
214 return browse;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
215 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
216 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
217 browses = g_slist_next(browses);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
218 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
219
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
220 return NULL;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
221 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
222
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
223 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
224 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
225 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
226 gchar buf[NAP_BUF_LEN];
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 g_snprintf(buf, NAP_BUF_LEN, "%s %s", who, message);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
229 nap_write_packet(gc, 0xCD, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
230 }
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 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
233 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
234 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
235 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
236 GSList *channels;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
237
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
238 channels = ndata->channels;
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 while (channels) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
241 channel = (struct nap_channel *)channels->data;
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
242
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
243 if (channel) {
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
244 if (!g_strcasecmp(name, channel->name)) {
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
245 return channel;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
246 }
1323
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 channels = g_slist_next(channels);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
249 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
250
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
251 return NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
252 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
253
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
254 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
255 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
256 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
257 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
258 GSList *channels;
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 channels = ndata->channels;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
261
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
262 while (channels) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
263 channel = (struct nap_channel *)channels->data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
264 if (id == channel->id) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
265 return channel;
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
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
268 channels = g_slist_next(channels);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
269 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
270
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
271 return NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
272 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
273
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
274 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
275 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
276 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
277 GSList *bc = gc->buddy_chats;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
278 struct conversation *b = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
279
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
280 while (bc) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
281 b = (struct conversation *)bc->data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
282 if (id == b->id) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
283 break;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
284 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
285 bc = bc->next;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
286 b = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
287 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
288
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
289 if (!b) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
290 return NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
291 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
292
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
293 return b;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
294 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
295
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
296 /* 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
297 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
298 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
299 struct nap_file_request *req;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
300 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
301 GSList *requests;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
302
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
303 requests = ndata->requests;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
304
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
305 while (requests) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
306 req = (struct nap_file_request *)requests->data;
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 if (req) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
309 if (req->fd == fd)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
310 return req;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
311 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
312 requests = g_slist_next(requests);
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 return NULL;
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
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
318 static void nap_ctc_callback(gpointer data, gint source, GdkInputCondition condition)
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 struct gaim_connection *gc = (struct gaim_connection *)data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
321 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
322 struct nap_file_request *req;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
323 unsigned char *buf;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
324 int i = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
325 gchar *c;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
326 int len;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
327
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
328 req = find_request_by_fd(gc, source);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
329 if (!req) /* Something bad happened */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
330 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
331
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
332 buf = (char *)malloc(sizeof(char) * (NAP_BUF_LEN + 1));
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
333
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
334 if (req->status == 0)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
335 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
336 int j;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
337 gchar tmp[32];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
338 long filesize;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
339 gchar **parse_name;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
340 gchar path[2048];
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
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
343 recv(source, buf, 1, 0);
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 /* We should receive a '1' upon connection */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
346 if (buf[0] != '1')
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 do_error_dialog("Uh Oh", "Uh Oh");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
349 gdk_input_remove(req->inpa);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
350 ndata->requests = g_slist_remove(ndata->requests, req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
351 g_free(req->name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
352 g_free(req->file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
353 close(source);
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 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
357 }
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 /* Lets take a peek at the awaiting data */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
360 i = recv(source, buf, NAP_BUF_LEN, MSG_PEEK);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
361 buf[i] = 0; /* Make sure that we terminate our string */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
362
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
363 /* 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
364 * file is */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
365
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
366 for (j = 0, i = 0; isdigit(buf[i]); i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
367 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
368 tmp[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
369 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
370 tmp[j] = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
371 filesize = atol(tmp);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
372
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
373 /* Save the size of the file */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
374 req->total = filesize;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
375
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
376 /* If we have a zero file size then something bad happened */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
377 if (filesize == 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
378 gdk_input_remove(req->inpa);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
379 ndata->requests = g_slist_remove(ndata->requests, req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
380 g_free(req->name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
381 g_free(req->file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
382 g_free(req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
383 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
384 close(source);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
385 return;
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
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
388 /* 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
389 * data to get it out of the way */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
390 recv(source, buf, strlen(tmp), 0);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
391
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
392 /* Now, we should tell the server that we're download something */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
393 nap_write_packet(gc, 0xda, "\n");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
394
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
395 req->status = 1;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
396
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
397 /* 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
398 * later */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
399
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
400 parse_name = g_strsplit(req->file, "\\", 0);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
401 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
402 printf("Gonna try to save to: %s\n", path);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
403 g_strfreev(parse_name);
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 req->mp3 = fopen(path, "w");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
406 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
407 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
408 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
409
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
410 /* 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
411 i = recv(source, buf, NAP_BUF_LEN, 0);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
412
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
413 req->size += i; /* Lets add up the total */
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 printf("Downloaded %ld of %ld\n", req->size, req->total);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
416
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
417 fwrite(buf, i, sizeof(char), req->mp3);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
418
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
419 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
420
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
421 if (req->size >= req->total) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
422 printf("Download complete.\n");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
423 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
424 gdk_input_remove(req->inpa);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
425 ndata->requests = g_slist_remove(ndata->requests, req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
426 g_free(req->name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
427 g_free(req->file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
428 g_free(req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
429 fclose(req->mp3);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
430 close(source);
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
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
434 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
435 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
436 int fd;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
437 struct sockaddr_in site;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
438 char buf[NAP_BUF_LEN];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
439 int inpa;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
440 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
441 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
442
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 site.sin_family = AF_INET;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
445 site.sin_addr.s_addr = host;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
446 site.sin_port = htons(port);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
447
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
448 fd = socket(AF_INET, SOCK_STREAM, 0);
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 if (fd < 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
451 do_error_dialog("Error connecting to user", "Gaim: Napster error");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
452 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
453 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
454
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
455 /* Make a connection with the server */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
456 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
457 do_error_dialog("Error connecting to user", "Gaim: Napster error");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
458 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
459 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
460
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
461 req->fd = fd;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
462 req->name = g_strdup(user);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
463 req->file = g_strdup(file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
464 req->size = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
465 req->status = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
466 req->total = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
467
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
468 /* Send our request to the user */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
469 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
470 write(fd, buf, strlen(buf));
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
471
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
472 /* Add our request */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
473 ndata->requests = g_slist_append(ndata->requests, req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
474
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
475 /* And start monitoring */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
476 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
477 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
478
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
479 static void nap_callback(gpointer data, gint source, GdkInputCondition condition)
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 struct gaim_connection *gc = data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
482 struct nap_data *ndata = gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
483 gchar *buf;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
484 unsigned short header[2];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
485 int i = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
486 int len;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
487 int command;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
488 gchar **res;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
489
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
490 read(source, header, 4);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
491 len = header[0];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
492 command = header[1];
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 buf = (gchar *)g_malloc(sizeof(gchar) * (len + 1));
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
495
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
496 read(source, buf, len);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
497
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
498 buf[len] = 0;
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
499
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
500 printf("DEBUG: %s\n", buf);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
501
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
502 if (command == 0xd6) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
503 res = g_strsplit(buf, " ", 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
504 /* Do we want to report what the users are doing? */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
505 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
506 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
507 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
508 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
509 }
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 if (command == 0x26d) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
512 /* Do we want to use the MOTD? */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
513 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
514 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
515 }
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 if (command == 0xCD) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
518 res = g_strsplit(buf, " ", 1);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
519 serv_got_im(gc, res[0], res[1], 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
520 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
521 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
522 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
523 }
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 if (command == 0x195) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
526 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
527 int id;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
528
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
529 channel = find_channel_by_name(gc, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
530
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
531 if (!channel) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
532 chat_id++;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
533
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
534 channel = g_new0(struct nap_channel, 1);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
535
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
536 channel->id = chat_id;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
537 channel->name = g_strdup(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
538
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
539 ndata->channels = g_slist_append(ndata->channels, channel);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
540
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
541 serv_got_joined_chat(gc, chat_id, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
542 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
543
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
544 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
545 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
546 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
547
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
548 if (command == 0x198 || command == 0x196) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
549 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
550 struct conversation *convo;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
551 gchar **res;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
552
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
553 res = g_strsplit(buf, " ", 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
554
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
555 channel = find_channel_by_name(gc, res[0]);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
556 convo = find_conversation_by_id(gc, channel->id);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
557
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
558 add_chat_buddy(convo, res[1]);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
559
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
560 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
561
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
562 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
563 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
564 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
565
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
566 if (command == 0x197) {
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
567 struct nap_channel *channel;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
568 struct conversation *convo;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
569 gchar **res;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
570
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
571 res = g_strsplit(buf, " ", 0);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
572
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
573 channel = find_channel_by_name(gc, res[0]);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
574 convo = find_conversation_by_id(gc, channel->id);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
575
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
576 remove_chat_buddy(convo, res[1]);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
577
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
578 g_strfreev(res);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
579 free(buf);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
580 return;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
581 }
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
582
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
583 if (command == 0x193) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
584 gchar **res;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
585 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
586
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
587 res = g_strsplit(buf, " ", 2);
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, res[0]);
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)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
592 serv_got_chat_in(gc, channel->id, res[1], 0, res[2]);
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 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
595 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
596 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
597 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
598
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
599 if (command == 0x194) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
600 do_error_dialog(buf, "Gaim: Napster Error");
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
601 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
602 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
603 }
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 if (command == 0x12e) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
606 gchar buf2[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
607
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
608 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
609 do_error_dialog(buf2, "Gaim: Napster Error");
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
610
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
611 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
612 return;
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 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
615
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
616 if (command == 0x191) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
617 struct nap_channel *channel;
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 channel = find_channel_by_name(gc, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
620
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
621 if (!channel) /* I'm not sure how this would happen =) */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
622 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
623
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
624 serv_got_chat_left(gc, channel->id);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
625 ndata->channels = g_slist_remove(ndata->channels, channel);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
626
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
627 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
628 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
629
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
630 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
631
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
632 if (command == 0xd1) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
633 gchar **res;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
634
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
635 res = g_strsplit(buf, " ", 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
636
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
637 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
638
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
639 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
640 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
641 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
642 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
643
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
644 if (command == 0xd2) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
645 serv_got_update(gc, buf, 0, 0, 0, 0, 0, 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
646 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
647 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
648 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
649
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
650 if (command == 0xd4) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
651 /* Looks like we're getting a browse response */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
652 gchar user[64];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
653 gchar file[2048];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
654 struct browse_window *bw = NULL;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
655
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
656 int i,j;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
657
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
658 for (i = 0, j = 0; buf[i] != ' '; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
659 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
660 user[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
661 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
662 user[j] = 0; i++; i++;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
663
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
664 for (j = 0; buf[i] != '\"'; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
665 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
666 file[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
667 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
668 file[j] = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
669
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
670 bw = find_browse_window_by_name(gc, user);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
671 if (!bw)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
672 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
673 /* If a browse window isn't found, let's create one */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
674 bw = browse_window_new(gc, user);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
675 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
676
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
677 browse_window_add_file(bw, file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
678
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
679 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
680 return;
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 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
683
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
684 if (command == 0xc9) {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
685 /* We've received a search response */
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
686 gchar *file = (gchar *)g_malloc(sizeof(gchar) * (NAP_BUF_LEN+1));
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
687 gchar *tmp;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
688 gchar rest[NAP_BUF_LEN];
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
689 gchar *data[5];
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
690 gchar **parse_name;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
691
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
692 int i, j;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
693
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
694 for (i = 1, j = 0; buf[i] != '\"'; i++, j++)
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
695 {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
696 file[j] = buf[i];
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
697 }
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
698
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
699 file[j] = 0; i++;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
700
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
701 tmp = (gchar *)g_malloc(sizeof(gchar) * (strlen(file) + 1));
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
702 strcpy(tmp, rindex(file, '\\')+1);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
703
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
704 strcpy(rest, buf+i);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
705
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
706 parse_name = g_strsplit(rest, " ", 0);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
707
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
708 data[0] = g_strdup(tmp);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
709 data[1] = g_strdup(parse_name[6]);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
710 data[2] = g_strdup(parse_name[2]);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
711 data[3] = g_strdup(parse_name[3]);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
712 data[4] = g_strdup(parse_name[8]);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
713
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
714 // printf("File: %s, 1: %s, 2: %s, 3: %s\n", data[0], data[1], data[2], data[3]);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
715 i = gtk_clist_append(GTK_CLIST(search_dialog->list), data);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
716
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
717 gtk_clist_set_row_data(GTK_CLIST(search_dialog->list), i, file);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
718 g_strfreev(parse_name);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
719 // g_free(file);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
720 g_free(tmp);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
721 g_free(buf);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
722 return;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
723 }
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
724
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
725 if (command == 0xca)
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
726 {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
727 /* End of search */
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
728 g_free(buf);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
729 return;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
730 }
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
731
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
732 if (command == 0x12d) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
733 /* Our buddy was added successfully */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
734 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
735 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
736 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
737
1329
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
738 if (command == 0x2ec) {
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
739 /* Looks like someone logged in as us! =-O */
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
740 free(buf);
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
741
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
742 signoff(gc);
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
743 return;
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
744 }
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
745
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
746 if (command == 0xcc) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
747 /* 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
748 * strange so we'll need to parse this one ourselves. */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
749
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
750 gchar user[64];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
751 gchar file[2048];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
752 gchar hoststr[16];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
753 gchar portstr[16];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
754 int i,j;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
755
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
756 for (i = 0, j = 0; buf[i] != ' '; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
757 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
758 user[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
759 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
760 user[j] = 0; i++;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
761
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
762 for (j = 0; buf[i] != ' '; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
763 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
764 hoststr[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
765 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
766 hoststr[j] = 0; i++;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
767
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
768 for (j = 0; buf[i] != ' '; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
769 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
770 portstr[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
771 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
772 portstr[j] = 0; i++;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
773
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
774 i++; /* We do this to ignore the first quotation mark */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
775
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
776 for (j = 0; buf[i] != '\"'; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
777 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
778 file[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
779 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
780 file[j] = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
781
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
782 /* Aaight. We dont need nuttin' else. Let's download the file */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
783 nap_get_file(gc, user, file, atol(hoststr), atoi(portstr));
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
784
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
785 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
786
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
787 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
788 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
789
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
790 printf("NAP: [COMMAND: 0x%04x] %s\n", command, buf);
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
791
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
792 free(buf);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
793 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
794
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 static void nap_login_callback(gpointer data, gint source, GdkInputCondition condition)
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 struct gaim_connection *gc = data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
799 struct nap_data *ndata = gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
800 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
801 unsigned short header[2];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
802 int i = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
803 int len;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
804 int command;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
805
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
806 read(source, header, 4);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
807 len = header[0];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
808 command = header[1];
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 read(source, buf, len);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
811 buf[len] = 0;
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 if (command == 0x03) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
814 printf("Registered with E-Mail address of: %s\n", buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
815 ndata->email = g_strdup(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
816
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
817 /* Remove old inpa, add new one */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
818 gdk_input_remove(ndata->inpa);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
819 ndata->inpa = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
820 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
821
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
822 /* Our signon is complete */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
823 account_online(gc);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
824 serv_finish_login(gc);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
825
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
826 if (bud_list_cache_exists(gc))
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
827 do_import(NULL, gc);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
828
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
829 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
830 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
831 }
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
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
834
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
835 static void nap_login(struct aim_user *user)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
836 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
837 int fd;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
838 struct hostent *host;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
839 struct sockaddr_in site;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
840 struct gaim_connection *gc = new_gaim_conn(user);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
841 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
842 char buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
843 char c;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
844 char z[4];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
845 int i;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
846 int status;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
847
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
848 host = gethostbyname("208.184.216.87");
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
849
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
850 if (!host) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
851 hide_login_progress(gc, "Unable to resolve hostname");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
852 signoff(gc);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
853 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
854 }
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
855
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
856 site.sin_family = AF_INET;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
857 site.sin_addr.s_addr = *(long *)(host->h_addr);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
858 site.sin_port = htons(8888);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
859
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
860 fd = socket(AF_INET, SOCK_STREAM, 0);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
861 if (fd < 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
862 hide_login_progress(gc, "Unable to create socket");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
863 signoff(gc);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
864 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
865 }
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
866
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
867 /* Make a connection with the server */
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
868 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
869 hide_login_progress(gc, "Unable to connect.");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
870 signoff(gc);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
871 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
872 }
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
873
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
874 ndata->fd = fd;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
875
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
876 /* And write our signon data */
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
877 g_snprintf(buf, NAP_BUF_LEN, "%s %s 0 \"gaimster\" 0", gc->username, gc->password);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
878 nap_write_packet(gc, 0x02, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
879
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
880 /* And set up the input watcher */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
881 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
882
1424
9d8cf2e12e68 [gaim-migrate @ 1434]
Rob Flynn <gaim@robflynn.com>
parents: 1422
diff changeset
883
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
884 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
885
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
886 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
887 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
888 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
889 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
890
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
891 /* Make sure the name has a # preceeding it */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
892 if (name[0] != '#')
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
893 g_snprintf(buf, NAP_BUF_LEN, "#%s", name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
894 else
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
895 g_snprintf(buf, NAP_BUF_LEN, "%s", name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
896
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
897 nap_write_packet(gc, 0x190, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
898 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
899
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
900 static void nap_chat_leave(struct gaim_connection *gc, int id)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
901 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
902 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
903 struct nap_channel *channel = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
904 GSList *channels = ndata->channels;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
905
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
906 channel = find_channel_by_id(gc, id);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
907
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
908 if (!channel) /* Again, I'm not sure how this would happen */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
909 return;
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 nap_write_packet(gc, 0x191, channel->name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
912
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
913 ndata->channels = g_slist_remove(ndata->channels, channel);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
914 g_free(channel->name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
915 g_free(channel);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
916
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
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
919 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
920 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
921 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
922 struct nap_channel *channel = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
923 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
924
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
925 channel = find_channel_by_id(gc, id);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
926
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
927 if (!channel) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
928 /* This shouldn't happen */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
929 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
930 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
931
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
932 g_snprintf(buf, NAP_BUF_LEN, "%s %s", channel->name, message);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
933 nap_write_packet(gc, 0x192, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
934
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
935 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
936
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
937 static void nap_add_buddy(struct gaim_connection *gc, char *name)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
938 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
939 nap_write_packet(gc, 0xCF, name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
940 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
941
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
942 static void nap_remove_buddy(struct gaim_connection *gc, char *name)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
943 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
944 nap_write_packet(gc, 0x12F, name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
945 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
946
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
947 static void nap_close(struct gaim_connection *gc)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
948 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
949 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
950 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
951 struct nap_channel *channel;
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
952 struct browse_window *browse;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
953 struct nap_file_request *req;
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
954 GSList *channels = ndata->channels;
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
955 GSList *requests = ndata->requests;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
956
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
957 if (gc->inpa)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
958 gdk_input_remove(gc->inpa);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
959
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
960 while (ndata->channels) {
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
961 channel = (struct nap_channel *)ndata->channels->data;
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
962 g_free(channel->name);
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
963 ndata->channels = g_slist_remove(ndata->channels, channel);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
964 g_free(channel);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
965 }
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
966
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
967 while (ndata->browses) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
968 browse = (struct browse_window *)ndata->browses->data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
969 g_free(browse->name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
970 gtk_widget_destroy(browse->window);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
971 ndata->browses = g_slist_remove(ndata->browses, browse);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
972 g_free(browse);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
973 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
974
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
975 while (ndata->requests) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
976 req = (struct nap_file_request *)ndata->requests->data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
977 g_free(req->name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
978 g_free(req->file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
979 if (req->inpa) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
980 gdk_input_remove(req->inpa);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
981 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
982 ndata->requests = g_slist_remove(ndata->requests, req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
983 g_free(req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
984
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
985 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
986
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
987 free(gc->proto_data);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
988 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
989
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
990 static void nap_add_buddies(struct gaim_connection *gc, GList *buddies)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
991 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
992 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
993 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
994 int n = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
995
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
996 while (buddies) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
997 nap_write_packet(gc, 0xd0, (char *)buddies->data);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
998 buddies = buddies -> next;
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 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1001
1338
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1002 static void nap_draw_new_user(GtkWidget *box)
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1003 {
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1004 GtkWidget *label;
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1005
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1006 label = gtk_label_new(_("Napster registration is currently under development"));
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1007
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1008 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1009 gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1010 gtk_widget_show(label);
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1011 }
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1012
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1013
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1014 void nap_send_browse(GtkObject *w, char *who)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1015 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1016 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
1017 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1018 gchar buf[NAP_BUF_LEN];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1019
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1020 g_snprintf(buf, NAP_BUF_LEN, "%s", who);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1021 nap_write_packet(gc, 0xd3, buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1022 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1023
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1024 void nap_find_callback(GtkObject *w, GtkWidget *entry)
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1025 {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1026 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1027 gchar *search;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1028 gchar buf[NAP_BUF_LEN];
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1029
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1030 search = gtk_entry_get_text(GTK_ENTRY(entry));
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1031 g_snprintf(buf, NAP_BUF_LEN, "FILENAME CONTAINS \"%s\" MAX_RESULTS 50", search);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1032
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1033 nap_write_packet(gc, 0xc8, buf);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1034 }
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1035
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1036 void destroy_window(GtkObject *w, GtkWidget *win)
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1037 {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1038 gtk_widget_destroy(win);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1039 }
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1040
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1041 void nap_show_search(GtkObject *w, void *omit)
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1042 {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1043 struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1044
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1045 if (!search_dialog)
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1046 {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1047 GtkWidget *window;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1048 GtkWidget *sw;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1049 GtkWidget *vbox;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1050 GtkWidget *hbox;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1051 GtkWidget *label;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1052 GtkWidget *button;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1053 GtkWidget *entry;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1054 GtkWidget *list;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1055 gchar *titles[5] = {"Mp3 Name", "Nick", "Size", "Bitrate", "Connection"};
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1056 search_dialog = g_new0(struct search_window, 1);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1057
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1058 window = gtk_window_new(GTK_WINDOW_DIALOG);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1059
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1060 vbox = gtk_vbox_new(FALSE, 0);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1061
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1062 /* First Line */
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1063 hbox = gtk_hbox_new(FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1064 label = gtk_label_new("Search for:");
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1065 gtk_widget_show(label);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1066 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1067
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1068 entry = gtk_entry_new();
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1069 gtk_widget_show(entry);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1070 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1071
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1072 button = gtk_button_new_with_label("Find");
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1073 gtk_widget_show(button);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1074 gtk_object_set_user_data(GTK_OBJECT(button), gc);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1075 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(nap_find_callback), entry);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1076
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1077 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1078
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1079 button = gtk_button_new_with_label("Cancel");
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1080 gtk_widget_show(button);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1081 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1082
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1083
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1084 gtk_widget_show(hbox);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1085 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1086 /* End First List */
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1087
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1088 /* Second Line */
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1089
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1090 sw = gtk_scrolled_window_new(NULL, NULL);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1091
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1092 list = gtk_clist_new_with_titles(5, titles);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1093
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1094 gtk_clist_column_titles_show(GTK_CLIST(list));
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1095
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1096 gtk_signal_connect(GTK_OBJECT(list), "select-row", GTK_SIGNAL_FUNC(nap_handle_download_search), gc);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1097
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1098 gtk_container_add(GTK_CONTAINER(sw), list);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1099 gtk_widget_show(list);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1100
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1101 gtk_box_pack_start(GTK_BOX(vbox), sw, FALSE, FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1102
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1103 gtk_widget_show(sw);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1104
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1105 /* End Second Line */
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1106
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1107 gtk_widget_show(vbox);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1108
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1109 gtk_container_add(GTK_CONTAINER(window), vbox);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1110 gtk_container_set_border_width(GTK_CONTAINER(window), 10);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1111
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1112 gtk_widget_set_usize(GTK_WIDGET(list), 500, 350);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1113 gtk_widget_set_usize(GTK_WIDGET(window), 500, 400);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1114
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1115 gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(destroy_window), window);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1116 gtk_widget_show(window);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1117
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1118 search_dialog->window = window;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1119 search_dialog->list = list;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1120 }
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1121
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1122 gtk_widget_show(search_dialog->window);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1123 }
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1124
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1125 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
1126 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1127 GtkWidget *button;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1128
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1129 button = gtk_menu_item_new_with_label("Browse Files");
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1130 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
1131 gtk_object_set_user_data(GTK_OBJECT(button), gc);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1132 gtk_menu_append(GTK_MENU(menu), button);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1133 gtk_widget_show(button);
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1134
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1135 button = gtk_menu_item_new_with_label("Search Napster");
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1136 gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(nap_show_search), NULL);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1137 gtk_object_set_user_data(GTK_OBJECT(button), gc);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1138 gtk_menu_append(GTK_MENU(menu), button);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1139 gtk_widget_show(button);
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1140 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1141
1327
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
1142 static char** nap_list_icon(int uc)
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
1143 {
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
1144 return napster_xpm;
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
1145 }
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
1146
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1147 static struct prpl *my_protocol = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1148
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1149 void nap_init(struct prpl *ret)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1150 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1151 ret->protocol = PROTO_NAPSTER;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1152 ret->name = nap_name;
1327
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
1153 ret->list_icon = nap_list_icon;
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1154 ret->action_menu = nap_action_menu;
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1155 ret->user_opts = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1156 ret->login = nap_login;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1157 ret->close = nap_close;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1158 ret->send_im = nap_send_im;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1159 ret->set_info = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1160 ret->get_info = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1161 ret->set_away = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1162 ret->get_away_msg = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1163 ret->set_dir = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1164 ret->get_dir = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1165 ret->dir_search = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1166 ret->set_idle = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1167 ret->change_passwd = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1168 ret->add_buddy = nap_add_buddy;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1169 ret->add_buddies = nap_add_buddies;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1170 ret->remove_buddy = nap_remove_buddy;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1171 ret->add_permit = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1172 ret->rem_permit = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1173 ret->add_deny = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1174 ret->rem_deny = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1175 ret->warn = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1176 ret->accept_chat = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1177 ret->join_chat = nap_join_chat;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1178 ret->chat_invite = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1179 ret->chat_leave = nap_chat_leave;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1180 ret->chat_whisper = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1181 ret->chat_send = nap_chat_send;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1182 ret->keepalive = NULL;
1338
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1183 ret->draw_new_user = nap_draw_new_user;
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1184
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1185 my_protocol = ret;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1186 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1187
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1188 char *gaim_plugin_init(GModule * handle)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1189 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1190 load_protocol(nap_init);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1191 return NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1192 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1193
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1194 void gaim_plugin_remove()
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1195 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1196 struct prpl *p = find_prpl(PROTO_NAPSTER);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1197 if (p == my_protocol)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1198 unload_protocol(p);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1199 }