annotate plugins/napster.c @ 1492:638b57b1801d

[gaim-migrate @ 1502] bah. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sat, 17 Feb 2001 00:08:45 +0000
parents 55f67ef24683
children 13bbf7b8f920
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * gaim - Napster Protocol Plugin
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 * Copyright (C) 2000, Rob Flynn <rob@tgflinux.com>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 *
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * (at your option) any later version.
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 *
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * GNU General Public License for more details.
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 *
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 *
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22 #include "../config.h"
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
23
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
24 #include <netdb.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
25 #include <gtk/gtk.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 #include <unistd.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27 #include <errno.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 #include <netinet/in.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 #include <arpa/inet.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 #include <time.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31 #include <string.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 #include <stdlib.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
33 #include <stdio.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
34 #include <time.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35 #include <sys/socket.h>
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
36 #include <sys/stat.h>
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
37 #include <sys/types.h>
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
38 #include <fcntl.h>
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
39 #include <ctype.h>
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40 #include "multi.h"
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41 #include "prpl.h"
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42 #include "gaim.h"
1327
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
43 #include "pixmaps/napster.xpm"
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
44
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45 #define NAP_BUF_LEN 4096
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
46
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47 GSList *nap_connections = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
48
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 static unsigned int chat_id = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
51 struct search_window {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
52 GtkWidget *window;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
53 GtkWidget *list;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
54 };
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
55
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
56 struct browse_window {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
57 GtkWidget *window;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
58 GtkWidget *list;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
59 struct gaim_connection *gc;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
60 char *name;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
61 };
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
62
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
63 struct nap_download_box {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
64 GtkWidget *window;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
65 GtkWidget *ok;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
66 GtkWidget *entry;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
67 gchar *who;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
68 };
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
69
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
70 struct nap_channel {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
71 unsigned int id;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
72 gchar *name;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
73 };
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
74
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
75 struct nap_file_request {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
76 gchar *name;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
77 gchar *file;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
78 int fd;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
79 long size;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
80 long total;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
81 int status;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
82 int inpa;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
83 FILE *mp3;
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);
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
425 gtk_progress_set_format_string(GTK_PROGRESS(req->progress), "%P %%");
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
426 gtk_progress_set_show_text(GTK_PROGRESS(req->progress), TRUE);
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
427 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
428
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
429 hbox = gtk_hbox_new(TRUE, 5);
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
430
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
431 req->ok = gtk_button_new_with_label("Ok");
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
432 req->cancel = gtk_button_new_with_label("Cancel");
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
433
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
434 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
435 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
436
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
437 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
438
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
439 gtk_container_add(GTK_CONTAINER(req->window), vbox);
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
440
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
441 gtk_widget_show_all(req->window);
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
442
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
443 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
444 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
445 }
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 /* 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
448 i = recv(source, buf, NAP_BUF_LEN, 0);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
449
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
450 req->size += i; /* Lets add up the total */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
451
1444
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
452 // 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
453
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
454 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
455
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
456 while (gtk_events_pending())
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
457 gtk_main_iteration();
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
458
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
459 fwrite(buf, i, sizeof(char), req->mp3);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
460
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
461 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
462
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
463 if (req->size >= req->total) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
464 printf("Download complete.\n");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
465 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
466 gdk_input_remove(req->inpa);
1444
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
467
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
468 ndata->requests = g_slist_remove(ndata->requests, req);
1444
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
469
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
470 if (req->name != NULL)
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
471 g_free(req->name);
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
472
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
473 if (req->file != NULL)
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
474 g_free(req->file);
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
475
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
476 g_free(req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
477 fclose(req->mp3);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
478 close(source);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
479 }
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 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
483 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
484 int fd;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
485 struct sockaddr_in site;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
486 char buf[NAP_BUF_LEN];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
487 int inpa;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
488 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
489 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
490
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 site.sin_family = AF_INET;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
493 site.sin_addr.s_addr = host;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
494 site.sin_port = htons(port);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
495
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
496 fd = socket(AF_INET, SOCK_STREAM, 0);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
497
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
498 if (fd < 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
499 do_error_dialog("Error connecting to user", "Gaim: Napster error");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
500 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
501 }
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 /* Make a connection with the server */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
504 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
505 do_error_dialog("Error connecting to user", "Gaim: Napster error");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
506 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
507 }
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 req->fd = fd;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
510 req->name = g_strdup(user);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
511 req->file = g_strdup(file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
512 req->size = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
513 req->status = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
514 req->total = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
515
1444
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
516 send(fd, "GET", 3, 0);
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
517
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
518 /* Send our request to the user */
1444
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
519 g_snprintf(buf, sizeof(buf), "%s \"%s\" 0",gc->username, file);
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
520
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
521 send(fd, buf, strlen(buf), 0);
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
522
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
523 /* Add our request */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
524 ndata->requests = g_slist_append(ndata->requests, req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
525
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
526 /* And start monitoring */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
527 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
528 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
529
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
530 static void nap_callback(gpointer data, gint source, GdkInputCondition condition)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
531 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
532 struct gaim_connection *gc = data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
533 struct nap_data *ndata = gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
534 gchar *buf;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
535 unsigned short header[2];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
536 int i = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
537 int len;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
538 int command;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
539 gchar **res;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
540
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
541 read(source, header, 4);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
542 len = header[0];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
543 command = header[1];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
544
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
545 buf = (gchar *)g_malloc(sizeof(gchar) * (len + 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 read(source, buf, len);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
548
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
549 buf[len] = 0;
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
550
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
551 printf("DEBUG: %s\n", buf);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
552
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
553 if (command == 0xd6) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
554 res = g_strsplit(buf, " ", 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
555 /* Do we want to report what the users are doing? */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
556 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
557 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
558 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
559 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
560 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
561
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
562 if (command == 0x26d) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
563 /* Do we want to use the MOTD? */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
564 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
565 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
566 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
567
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
568 if (command == 0xCD) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
569 res = g_strsplit(buf, " ", 1);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
570 serv_got_im(gc, res[0], res[1], 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
571 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
572 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
573 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
574 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
575
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
576 if (command == 0x195) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
577 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
578 int id;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
579
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
580 channel = find_channel_by_name(gc, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
581
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
582 if (!channel) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
583 chat_id++;
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 channel = g_new0(struct nap_channel, 1);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
586
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
587 channel->id = chat_id;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
588 channel->name = g_strdup(buf);
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 ndata->channels = g_slist_append(ndata->channels, channel);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
591
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
592 serv_got_joined_chat(gc, chat_id, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
593 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
594
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
595 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
596 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
597 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
598
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
599 if (command == 0x198 || command == 0x196) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
600 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
601 struct conversation *convo;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
602 gchar **res;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
603
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
604 res = g_strsplit(buf, " ", 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
605
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
606 channel = find_channel_by_name(gc, res[0]);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
607 convo = find_conversation_by_id(gc, channel->id);
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 add_chat_buddy(convo, res[1]);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
610
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
611 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
612
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
613 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
614 return;
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
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
617 if (command == 0x197) {
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
618 struct nap_channel *channel;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
619 struct conversation *convo;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
620 gchar **res;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
621
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
622 res = g_strsplit(buf, " ", 0);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
623
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
624 channel = find_channel_by_name(gc, res[0]);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
625 convo = find_conversation_by_id(gc, channel->id);
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 remove_chat_buddy(convo, res[1]);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
628
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
629 g_strfreev(res);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
630 free(buf);
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
631 return;
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
632 }
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
633
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
634 if (command == 0x193) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
635 gchar **res;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
636 struct nap_channel *channel;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
637
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
638 res = g_strsplit(buf, " ", 2);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
639
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
640 channel = find_channel_by_name(gc, res[0]);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
641
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
642 if (channel)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
643 serv_got_chat_in(gc, channel->id, res[1], 0, res[2]);
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 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
646 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
647 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
648 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
649
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
650 if (command == 0x194) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
651 do_error_dialog(buf, "Gaim: Napster Error");
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
652 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
653 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
654 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
655
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
656 if (command == 0x12e) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
657 gchar buf2[NAP_BUF_LEN];
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 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
660 do_error_dialog(buf2, "Gaim: Napster Error");
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 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
663 return;
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 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
666
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
667 if (command == 0x191) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
668 struct nap_channel *channel;
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 channel = find_channel_by_name(gc, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
671
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
672 if (!channel) /* I'm not sure how this would happen =) */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
673 return;
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 serv_got_chat_left(gc, channel->id);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
676 ndata->channels = g_slist_remove(ndata->channels, channel);
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 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
679 return;
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 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
682
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
683 if (command == 0xd1) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
684 gchar **res;
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 res = g_strsplit(buf, " ", 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
687
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
688 serv_got_update(gc, res[0], 1, 0, time((time_t *)NULL), 0, 0, 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
689
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
690 g_strfreev(res);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
691 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
692 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
693 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
694
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
695 if (command == 0xd2) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
696 serv_got_update(gc, buf, 0, 0, 0, 0, 0, 0);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
697 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
698 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
699 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
700
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
701 if (command == 0xd4) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
702 /* Looks like we're getting a browse response */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
703 gchar user[64];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
704 gchar file[2048];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
705 struct browse_window *bw = NULL;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
706
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
707 int i,j;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
708
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
709 for (i = 0, j = 0; buf[i] != ' '; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
710 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
711 user[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
712 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
713 user[j] = 0; i++; i++;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
714
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
715 for (j = 0; buf[i] != '\"'; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
716 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
717 file[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
718 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
719 file[j] = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
720
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
721 bw = find_browse_window_by_name(gc, user);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
722 if (!bw)
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 /* If a browse window isn't found, let's create one */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
725 bw = browse_window_new(gc, user);
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
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
728 browse_window_add_file(bw, file);
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 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
731 return;
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 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
734
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
735 if (command == 0xc9) {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
736 /* We've received a search response */
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
737 gchar *file = (gchar *)g_malloc(sizeof(gchar) * (NAP_BUF_LEN+1));
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
738 gchar *tmp;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
739 gchar rest[NAP_BUF_LEN];
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
740 gchar *data[5];
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
741 gchar **parse_name;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
742
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
743 int i, j;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
744
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
745 for (i = 1, j = 0; buf[i] != '\"'; i++, j++)
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
746 {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
747 file[j] = buf[i];
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
748 }
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] = 0; 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 tmp = (gchar *)g_malloc(sizeof(gchar) * (strlen(file) + 1));
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
753 strcpy(tmp, rindex(file, '\\')+1);
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 strcpy(rest, buf+i);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
756
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
757 parse_name = g_strsplit(rest, " ", 0);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
758
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
759 data[0] = g_strdup(tmp);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
760 data[1] = g_strdup(parse_name[6]);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
761 data[2] = g_strdup(parse_name[2]);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
762 data[3] = g_strdup(parse_name[3]);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
763 data[4] = g_strdup(parse_name[8]);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
764
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
765 // 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
766 i = gtk_clist_append(GTK_CLIST(search_dialog->list), data);
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 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
769 g_strfreev(parse_name);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
770 // g_free(file);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
771 g_free(tmp);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
772 g_free(buf);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
773 return;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
774 }
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
775
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
776 if (command == 0xca)
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 /* End of search */
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
779 g_free(buf);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
780 return;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
781 }
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
782
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
783 if (command == 0x12d) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
784 /* Our buddy was added successfully */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
785 free(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
786 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
787 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
788
1329
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
789 if (command == 0x2ec) {
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
790 /* Looks like someone logged in as us! =-O */
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
791 free(buf);
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
792
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
793 signoff(gc);
e2d8b713d928 [gaim-migrate @ 1339]
Rob Flynn <gaim@robflynn.com>
parents: 1327
diff changeset
794 return;
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
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
797 if (command == 0xcc) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
798 /* 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
799 * strange so we'll need to parse this one ourselves. */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
800
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
801 gchar user[64];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
802 gchar file[2048];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
803 gchar hoststr[16];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
804 gchar portstr[16];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
805 int i,j;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
806
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
807 for (i = 0, j = 0; buf[i] != ' '; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
808 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
809 user[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
810 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
811 user[j] = 0; i++;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
812
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
813 for (j = 0; buf[i] != ' '; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
814 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
815 hoststr[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
816 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
817 hoststr[j] = 0; i++;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
818
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
819 for (j = 0; buf[i] != ' '; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
820 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
821 portstr[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
822 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
823 portstr[j] = 0; i++;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
824
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
825 i++; /* We do this to ignore the first quotation mark */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
826
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
827 for (j = 0; buf[i] != '\"'; i++, j++)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
828 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
829 file[j] = buf[i];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
830 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
831 file[j] = 0;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
832
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
833 /* Aaight. We dont need nuttin' else. Let's download the file */
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
834 nap_get_file(gc, user, file, atol(hoststr), atoi(portstr));
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 free(buf);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
837
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
838 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
839 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
840
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
841 printf("NAP: [COMMAND: 0x%04x] %s\n", command, buf);
1422
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 free(buf);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
844 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
845
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
846
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
847 static void nap_login_callback(gpointer data, gint source, GdkInputCondition condition)
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 struct gaim_connection *gc = data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
850 struct nap_data *ndata = gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
851 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
852 unsigned short header[2];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
853 int i = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
854 int len;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
855 int command;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
856
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
857 read(source, header, 4);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
858 len = header[0];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
859 command = header[1];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
860
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
861 read(source, buf, len);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
862 buf[len] = 0;
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 if (command == 0x03) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
865 printf("Registered with E-Mail address of: %s\n", buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
866 ndata->email = g_strdup(buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
867
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
868 /* Remove old inpa, add new one */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
869 gdk_input_remove(ndata->inpa);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
870 ndata->inpa = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
871 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
872
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
873 /* Our signon is complete */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
874 account_online(gc);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
875 serv_finish_login(gc);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
876
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
877 if (bud_list_cache_exists(gc))
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
878 do_import(NULL, 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 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
881 }
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
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
884
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
885
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
886 static void nap_login(struct aim_user *user)
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 int fd;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
889 struct hostent *host;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
890 struct sockaddr_in site;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
891 struct gaim_connection *gc = new_gaim_conn(user);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
892 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
893 char buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
894 char c;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
895 char z[4];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
896 int i;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
897 int status;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
898
1444
55f67ef24683 [gaim-migrate @ 1454]
Rob Flynn <gaim@robflynn.com>
parents: 1443
diff changeset
899 host = gethostbyname("64.124.41.175");
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
900
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
901 if (!host) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
902 hide_login_progress(gc, "Unable to resolve hostname");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
903 signoff(gc);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
904 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
905 }
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
906
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
907 site.sin_family = AF_INET;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
908 site.sin_addr.s_addr = *(long *)(host->h_addr);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
909 site.sin_port = htons(8888);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
910
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
911 fd = socket(AF_INET, SOCK_STREAM, 0);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
912 if (fd < 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
913 hide_login_progress(gc, "Unable to create socket");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
914 signoff(gc);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
915 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
916 }
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
917
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
918 /* Make a connection with the server */
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
919 if (connect(fd, (struct sockaddr *)&site, sizeof(site)) < 0) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
920 hide_login_progress(gc, "Unable to connect.");
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
921 signoff(gc);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
922 return;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
923 }
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
924
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
925 ndata->fd = fd;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
926
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
927 /* And write our signon data */
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
928 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
929 nap_write_packet(gc, 0x02, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
930
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
931 /* And set up the input watcher */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
932 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
933
1424
9d8cf2e12e68 [gaim-migrate @ 1434]
Rob Flynn <gaim@robflynn.com>
parents: 1422
diff changeset
934
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
935 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
936
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
937 static void nap_join_chat(struct gaim_connection *gc, int id, char *name)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
938 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
939 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
940 gchar buf[NAP_BUF_LEN];
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 /* Make sure the name has a # preceeding it */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
943 if (name[0] != '#')
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
944 g_snprintf(buf, NAP_BUF_LEN, "#%s", name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
945 else
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
946 g_snprintf(buf, NAP_BUF_LEN, "%s", name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
947
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
948 nap_write_packet(gc, 0x190, buf);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
949 }
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 static void nap_chat_leave(struct gaim_connection *gc, int id)
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 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
954 struct nap_channel *channel = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
955 GSList *channels = ndata->channels;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
956
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
957 channel = find_channel_by_id(gc, id);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
958
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
959 if (!channel) /* Again, I'm not sure how this would happen */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
960 return;
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 nap_write_packet(gc, 0x191, channel->name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
963
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
964 ndata->channels = g_slist_remove(ndata->channels, channel);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
965 g_free(channel->name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
966 g_free(channel);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
967
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
968 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
969
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
970 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
971 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
972 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
973 struct nap_channel *channel = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
974 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
975
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
976 channel = find_channel_by_id(gc, id);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
977
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
978 if (!channel) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
979 /* This shouldn't happen */
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
980 return;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
981 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
982
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
983 g_snprintf(buf, NAP_BUF_LEN, "%s %s", channel->name, message);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
984 nap_write_packet(gc, 0x192, buf);
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 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
987
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
988 static void nap_add_buddy(struct gaim_connection *gc, char *name)
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 nap_write_packet(gc, 0xCF, name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
991 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
992
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
993 static void nap_remove_buddy(struct gaim_connection *gc, char *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 nap_write_packet(gc, 0x12F, name);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
996 }
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 static void nap_close(struct gaim_connection *gc)
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 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1001 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1002 struct nap_channel *channel;
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1003 struct browse_window *browse;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1004 struct nap_file_request *req;
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1005 GSList *channels = ndata->channels;
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1006 GSList *requests = ndata->requests;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1007
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1008 if (gc->inpa)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1009 gdk_input_remove(gc->inpa);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1010
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
1011 while (ndata->channels) {
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
1012 channel = (struct nap_channel *)ndata->channels->data;
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1013 g_free(channel->name);
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
1014 ndata->channels = g_slist_remove(ndata->channels, channel);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1015 g_free(channel);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1016 }
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
1017
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1018 while (ndata->browses) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1019 browse = (struct browse_window *)ndata->browses->data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1020 g_free(browse->name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1021 gtk_widget_destroy(browse->window);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1022 ndata->browses = g_slist_remove(ndata->browses, browse);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1023 g_free(browse);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1024 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1025
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1026 while (ndata->requests) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1027 req = (struct nap_file_request *)ndata->requests->data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1028 g_free(req->name);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1029 g_free(req->file);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1030 if (req->inpa) {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1031 gdk_input_remove(req->inpa);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1032 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1033 ndata->requests = g_slist_remove(ndata->requests, req);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1034 g_free(req);
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 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1037
1325
08aa745310f6 [gaim-migrate @ 1335]
Rob Flynn <gaim@robflynn.com>
parents: 1323
diff changeset
1038 free(gc->proto_data);
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1039 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1040
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1041 static void nap_add_buddies(struct gaim_connection *gc, GList *buddies)
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 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1044 gchar buf[NAP_BUF_LEN];
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1045 int n = 0;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1046
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1047 while (buddies) {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1048 nap_write_packet(gc, 0xd0, (char *)buddies->data);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1049 buddies = buddies -> next;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1050 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1051 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1052
1338
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1053 static void nap_draw_new_user(GtkWidget *box)
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1054 {
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1055 GtkWidget *label;
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1056
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1057 label = gtk_label_new(_("Napster registration is currently under development"));
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1058
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1059 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1060 gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1061 gtk_widget_show(label);
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1062 }
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1063
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1064
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1065 void nap_send_browse(GtkObject *w, char *who)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1066 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1067 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
1068 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1069 gchar buf[NAP_BUF_LEN];
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1070
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1071 g_snprintf(buf, NAP_BUF_LEN, "%s", who);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1072 nap_write_packet(gc, 0xd3, buf);
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
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1075 void nap_find_callback(GtkObject *w, GtkWidget *entry)
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1076 {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1077 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
1078 gchar *search;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1079 gchar buf[NAP_BUF_LEN];
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1080
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1081 search = gtk_entry_get_text(GTK_ENTRY(entry));
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1082 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
1083
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1084 nap_write_packet(gc, 0xc8, buf);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1085 }
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 void destroy_window(GtkObject *w, GtkWidget *win)
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 gtk_widget_destroy(win);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1090 }
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 void nap_show_search(GtkObject *w, void *omit)
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 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
1095
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1096 if (!search_dialog)
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1097 {
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1098 GtkWidget *window;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1099 GtkWidget *sw;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1100 GtkWidget *vbox;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1101 GtkWidget *hbox;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1102 GtkWidget *label;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1103 GtkWidget *button;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1104 GtkWidget *entry;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1105 GtkWidget *list;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1106 gchar *titles[5] = {"Mp3 Name", "Nick", "Size", "Bitrate", "Connection"};
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1107 search_dialog = g_new0(struct search_window, 1);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1108
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1109 window = gtk_window_new(GTK_WINDOW_DIALOG);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1110
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1111 vbox = gtk_vbox_new(FALSE, 0);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1112
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1113 /* First Line */
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1114 hbox = gtk_hbox_new(FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1115 label = gtk_label_new("Search for:");
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1116 gtk_widget_show(label);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1117 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1118
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1119 entry = gtk_entry_new();
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1120 gtk_widget_show(entry);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1121 gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1122
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1123 button = gtk_button_new_with_label("Find");
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1124 gtk_widget_show(button);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1125 gtk_object_set_user_data(GTK_OBJECT(button), gc);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1126 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
1127
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1128 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1129
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1130 button = gtk_button_new_with_label("Cancel");
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1131 gtk_widget_show(button);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1132 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1133
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1134
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1135 gtk_widget_show(hbox);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1136 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1137 /* End First List */
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1138
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1139 /* Second Line */
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1140
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1141 sw = gtk_scrolled_window_new(NULL, NULL);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1142
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1143 list = gtk_clist_new_with_titles(5, titles);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1144
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1145 gtk_clist_column_titles_show(GTK_CLIST(list));
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1146
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1147 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
1148
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1149 gtk_container_add(GTK_CONTAINER(sw), list);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1150 gtk_widget_show(list);
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_box_pack_start(GTK_BOX(vbox), sw, FALSE, FALSE, 5);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1153
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1154 gtk_widget_show(sw);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1155
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1156 /* End Second Line */
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1157
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1158 gtk_widget_show(vbox);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1159
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1160 gtk_container_add(GTK_CONTAINER(window), vbox);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1161 gtk_container_set_border_width(GTK_CONTAINER(window), 10);
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_widget_set_usize(GTK_WIDGET(list), 500, 350);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1164 gtk_widget_set_usize(GTK_WIDGET(window), 500, 400);
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_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
1167 gtk_widget_show(window);
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 search_dialog->window = window;
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1170 search_dialog->list = list;
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
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1173 gtk_widget_show(search_dialog->window);
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
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1176 static void nap_action_menu(GtkWidget *menu, struct gaim_connection *gc, char *who)
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1177 {
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1178 GtkWidget *button;
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1179
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1180 button = gtk_menu_item_new_with_label("Browse Files");
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1181 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
1182 gtk_object_set_user_data(GTK_OBJECT(button), gc);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1183 gtk_menu_append(GTK_MENU(menu), button);
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1184 gtk_widget_show(button);
1427
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1185
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1186 button = gtk_menu_item_new_with_label("Search Napster");
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1187 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
1188 gtk_object_set_user_data(GTK_OBJECT(button), gc);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1189 gtk_menu_append(GTK_MENU(menu), button);
28278bd61403 [gaim-migrate @ 1437]
Rob Flynn <gaim@robflynn.com>
parents: 1424
diff changeset
1190 gtk_widget_show(button);
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1191 }
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1192
1327
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
1193 static char** nap_list_icon(int uc)
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
1194 {
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
1195 return napster_xpm;
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
1196 }
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
1197
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1198 static struct prpl *my_protocol = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1199
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1200 void nap_init(struct prpl *ret)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1201 {
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1202 ret->protocol = PROTO_NAPSTER;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1203 ret->name = nap_name;
1327
113a3d16f1ce [gaim-migrate @ 1337]
Rob Flynn <gaim@robflynn.com>
parents: 1325
diff changeset
1204 ret->list_icon = nap_list_icon;
1422
6e0883ee51ce [gaim-migrate @ 1432]
Rob Flynn <gaim@robflynn.com>
parents: 1338
diff changeset
1205 ret->action_menu = nap_action_menu;
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1206 ret->user_opts = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1207 ret->login = nap_login;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1208 ret->close = nap_close;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1209 ret->send_im = nap_send_im;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1210 ret->set_info = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1211 ret->get_info = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1212 ret->set_away = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1213 ret->get_away_msg = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1214 ret->set_dir = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1215 ret->get_dir = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1216 ret->dir_search = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1217 ret->set_idle = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1218 ret->change_passwd = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1219 ret->add_buddy = nap_add_buddy;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1220 ret->add_buddies = nap_add_buddies;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1221 ret->remove_buddy = nap_remove_buddy;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1222 ret->add_permit = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1223 ret->rem_permit = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1224 ret->add_deny = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1225 ret->rem_deny = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1226 ret->warn = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1227 ret->accept_chat = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1228 ret->join_chat = nap_join_chat;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1229 ret->chat_invite = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1230 ret->chat_leave = nap_chat_leave;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1231 ret->chat_whisper = NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1232 ret->chat_send = nap_chat_send;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1233 ret->keepalive = NULL;
1338
2e046be5e44a [gaim-migrate @ 1348]
Rob Flynn <gaim@robflynn.com>
parents: 1329
diff changeset
1234 ret->draw_new_user = nap_draw_new_user;
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1235
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1236 my_protocol = ret;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1237 }
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 char *gaim_plugin_init(GModule * handle)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1240 {
1443
336fc98b7f90 [gaim-migrate @ 1453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1427
diff changeset
1241 load_protocol(nap_init, sizeof(struct prpl));
1323
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1242 return NULL;
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1243 }
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1244
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1245 void gaim_plugin_remove()
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 struct prpl *p = find_prpl(PROTO_NAPSTER);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1248 if (p == my_protocol)
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1249 unload_protocol(p);
4cbb78f05e4b [gaim-migrate @ 1333]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1250 }