annotate plugins/napster.c @ 1830:086213e7fb73

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