annotate src/protocols/napster/napster.c @ 6392:e9974608b319

[gaim-migrate @ 6897] deryni absolutely rocks. Amazing guy. We now have these beautiful protocol icons on tabs that update to reflect status. Away, grey on idle, even the sign on/off doors. Wow. This will no doubt be known as the highlight of 0.67. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 06 Aug 2003 11:38:57 +0000
parents 8f94cce8faa5
children 42fdf16f1dad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * gaim - Napster Protocol Plugin
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
3322
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
4 * Copyright (C) 2000-2001, Rob Flynn <rob@marko.net>
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * (at your option) any later version.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * GNU General Public License for more details.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
21 #include "internal.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
23 #include "account.h"
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
24 #include "accountopt.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
25 #include "conversation.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
26 #include "debug.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #include "multi.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
28 #include "notify.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include "prpl.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include "proxy.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
31 #include "util.h"
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3593
diff changeset
32
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
33 /* XXX */
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
34 #include "gaim.h"
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3593
diff changeset
35
3322
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
36 #define NAP_SERVER "64.124.41.187"
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
37 #define NAP_PORT 8888
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
38
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
39 #define NAPSTER_CONNECT_STEPS 2
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
40
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 GSList *nap_connections = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 struct nap_data {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 int fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 gchar *email;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
48 static GaimConversation *nap_find_chat(GaimConnection *gc, const char *name)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 {
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
50 GSList *bcs = gc->buddy_chats;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
52 while (bcs) {
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
53 GaimConversation *b = bcs->data;
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
54 if (!gaim_utf8_strcasecmp(b->name, name))
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
55 return b;
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
56 bcs = bcs->next;
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
57 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
58
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
59 return NULL;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
60 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
61
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
62 static void nap_write_packet(GaimConnection *gc, unsigned short command, const char *format, ...)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
63 {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
64 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
65 va_list ap;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
66 gchar *message;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
67 unsigned short size;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
68
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
69 va_start(ap, format);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
70 message = g_strdup_vprintf(format, ap);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
71 va_end(ap);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
72
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
73 size = strlen(message);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
74 gaim_debug(GAIM_DEBUG_MISC, "napster", "S %3hd: %s\n", command, message);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
75
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
76 write(ndata->fd, &size, 2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
77 write(ndata->fd, &command, 2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
78 write(ndata->fd, message, size);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
79
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
80 g_free(message);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
81 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
82
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
83 static int nap_do_irc_style(GaimConnection *gc, const char *message, const char *name)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
84 {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
85 gchar **res;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
86
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
87 gaim_debug(GAIM_DEBUG_MISC, "napster", "C %s\n", message);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
88
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
89 res = g_strsplit(message, " ", 2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
90
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
91 if (!strcasecmp(res[0], "/ME")) { /* MSG_CLIENT_PUBLIC */
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
92 nap_write_packet(gc, 824, "%s \"%s\"", name, res[1]);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
93
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
94 } else if (!strcasecmp(res[0], "/MSG")) { /* MSG_CLIENT_PUBLIC */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
95 nap_write_packet(gc, 205, "%s", res[1]);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
96
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
97 } else if (!strcasecmp(res[0], "/JOIN")) { /* join chatroom MSG_CLIENT_JOIN */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
98 if (!res[1]) {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
99 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
100 return 1;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
101 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
102 if (res[1][0] != '#')
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
103 nap_write_packet(gc, 400, "#%s", res[1]);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
104 else
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
105 nap_write_packet(gc, 400, "%s", res[1]);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
106
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
107 } else if (!strcasecmp(res[0], "/PART")) { /* partchatroom MSG_CLIENT_PART */
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
108 nap_write_packet(gc, 401, "%s", res[1] ? res[1] : name);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
109
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
110 } else if (!strcasecmp(res[0], "/TOPIC")) { /* set topic MSG_SERVER_TOPIC */
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
111 nap_write_packet(gc, 410, "%s", res[1] ? res[1] : name);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
112
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
113 } else if (!strcasecmp(res[0], "/WHOIS")) { /* whois request MSG_CLIENT_WHOIS */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
114 nap_write_packet(gc, 603, "%s", res[1]);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
115
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
116 } else if (!strcasecmp(res[0], "/PING")) { /* send ping MSG_CLIENT_PING */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
117 nap_write_packet(gc, 751, "%s", res[1]);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
118
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
119 } else if (!strcasecmp(res[0], "/KICK")) { /* kick asswipe MSG_CLIENT_KICK */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
120 nap_write_packet(gc, 829, "%s", res[1]);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
121
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
122 } else {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
123 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
124 return 1;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
125 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
126
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
127 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
128 return 0;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
129 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
130
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
131 /* 205 - MSG_CLIENT_PRIVMSG */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
132 static int nap_send_im(GaimConnection *gc, const char *who, const char *message, int len, int flags)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
133 {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
134
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
135 if ((strlen(message) < 2) || (message[0] != '/' ) || (message[1] == '/')) {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
136 /* Actually send a chat message */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
137 nap_write_packet(gc, 205, "%s %s", who, message);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
138 } else {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
139 /* user typed an IRC-style command */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
140 nap_do_irc_style(gc, message, who);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
143 return 1;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
144 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
145
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
146 /* 207 - MSG_CLIENT_ADD_HOTLIST */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
147 static void nap_add_buddy(GaimConnection *gc, const char *name)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
148 {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
149 nap_write_packet(gc, 207, "%s", name);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
150 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
151
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
152 /* 208 - MSG_CLIENT_ADD_HOTLIST_SEQ */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
153 static void nap_add_buddies(GaimConnection *gc, GList *buddies)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
154 {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
155 while (buddies) {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
156 nap_write_packet(gc, 208, "%s", (char *)buddies->data);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
157 buddies = buddies -> next;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
158 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
159 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
160
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
161 /* 303 - MSG_CLIENT_REMOVE_HOTLIST */
6059
d8cd876e613e [gaim-migrate @ 6509]
Mark Doliner <mark@kingant.net>
parents: 5920
diff changeset
162 static void nap_remove_buddy(GaimConnection *gc, const char *name, const char *group)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
163 {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
164 nap_write_packet(gc, 303, "%s", name);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
165 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
166
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
167 /* 400 - MSG_CLIENT_JOIN */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
168 static void nap_join_chat(GaimConnection *gc, GHashTable *data)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
169 {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
170 char *name;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
171
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
172 if (!data)
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
173 return;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
174
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
175 name = g_hash_table_lookup(data, "group");
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
176
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
177 /* Make sure the name has a # preceeding it */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
178 if (name[0] != '#')
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
179 nap_write_packet(gc, 400, "#%s", name);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
180 else
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
181 nap_write_packet(gc, 400, "%s", name);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
182 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
183
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
184 /* 401 - MSG_CLIENT_PART */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
185 static void nap_chat_leave(GaimConnection *gc, int id)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
186 {
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
187 GaimConversation *c = gaim_find_chat(gc, id);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
188
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
189 if (!c)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
190 return;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
191
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
192 nap_write_packet(gc, 401, "%s", c->name);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
193 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
194
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
195 /* 402 - MSG_CLIENT_PUBLIC */
6059
d8cd876e613e [gaim-migrate @ 6509]
Mark Doliner <mark@kingant.net>
parents: 5920
diff changeset
196 static int nap_chat_send(GaimConnection *gc, int id, const char *message)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
197 {
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
198 GaimConversation *c = gaim_find_chat(gc, id);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
199
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
200 if (!c)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
201 return -EINVAL;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
202
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
203 if ((strlen(message) < 2) || (message[0] != '/' ) || (message[1] == '/')) {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
204 /* Actually send a chat message */
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
205 nap_write_packet(gc, 402, "%s %s", c->name, message);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
206 } else {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
207 /* user typed an IRC-style command */
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
208 nap_do_irc_style(gc, message, c->name);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
209 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
210
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
211 return 0;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
212 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
213
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
214 /* 603 - MSG_CLIENT_WHOIS */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
215 static void nap_get_info(GaimConnection *gc, const char *who)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
216 {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
217 nap_write_packet(gc, 603, "%s", who);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
220 static void nap_callback(gpointer data, gint source, GaimInputCondition condition)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221 {
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
222 GaimConnection *gc = data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 struct nap_data *ndata = gc->proto_data;
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
224 GaimConversation *c;
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
225 gchar *buf, *buf2, *buf3, **res;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 unsigned short header[2];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 int len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228 int command;
2220
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
229 int i;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
231 if (read(source, (void*)header, 4) != 4) {
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
232 gaim_connection_error(gc, _("Unable to read header from server"));
2220
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
233 return;
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
234 }
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
235
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236 len = header[0];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 command = header[1];
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
238 buf = (gchar *)g_malloc((len + 1) * sizeof(gchar));
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
239 buf[len] = '\0';
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240
2220
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
241 i = 0;
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
242 do {
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
243 int tmp = read(source, buf + i, len - i);
2220
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
244 if (tmp <= 0) {
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
245 g_free(buf);
6321
3613007cbb6e [gaim-migrate @ 6820]
Luke Schierer <lschiere@pidgin.im>
parents: 6059
diff changeset
246 buf = g_strdup_printf(_("Unable to read mesage from server. Command is %hd, length is %hd."), len, command);
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
247 gaim_connection_error(gc, buf);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
248 g_free(buf);
2220
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
249 return;
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
250 }
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
251 i += tmp;
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
252 } while (i != len);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
254 gaim_debug(GAIM_DEBUG_MISC, "napster", "R %3hd: %s\n", command, buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
256 switch (command) {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
257 case 000: /* MSG_SERVER_ERROR */
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
258 gaim_notify_error(gc, NULL, buf, NULL);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
259 gaim_input_remove(gc->inpa);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
260 gc->inpa = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261 close(source);
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
262 gaim_connection_destroy(gc);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
263 break;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
265 case 003: /* MSG_SERVER_EMAIL */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
266 gaim_debug(GAIM_DEBUG_MISC, "napster", "Registered with e-mail address: %s\n", buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 ndata->email = g_strdup(buf);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 /* Our signon is complete */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
270 gaim_connection_set_state(gc, GAIM_CONNECTED);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 serv_finish_login(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
273 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
274
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
275 case 201: /* MSG_SERVER_SEARCH_RESULT */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
276 res = g_strsplit(buf, " ", 0);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
277 serv_got_update(gc, res[0], 1, 0, 0, 0, 0);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
278 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
279 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
280
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
281 case 202: /* MSG_SERVER_SEARCH_END */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
282 serv_got_update(gc, buf, 0, 0, 0, 0, 0);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
283 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
284
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
285 case 205: /* MSG_CLIENT_PRIVMSG */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
286 res = g_strsplit(buf, " ", 2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
287 serv_got_im(gc, res[0], res[1], 0, time(NULL), -1);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
288 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
289 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
290
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
291 case 209: /* MSG_SERVER_USER_SIGNON */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
292 /* USERNAME SPEED */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
293 res = g_strsplit(buf, " ", 2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
294 serv_got_update(gc, res[0], 1, 0, 0, 0, 0);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
295 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
296 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
297
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
298 case 210: /* MSG_SERVER_USER_SIGNOFF */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
299 /* USERNAME SPEED */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
300 res = g_strsplit(buf, " ", 2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
301 serv_got_update(gc, res[0], 0, 0, 0, 0, 0);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
302 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
303 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
304
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
305 case 214: /* MSG_SERVER_STATS */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
306 res = g_strsplit(buf, " ", 3);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
307 buf2 = g_strdup_printf(_("users: %s, files: %s, size: %sGB"), res[0], res[1], res[2]);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
308 serv_got_im(gc, "server", buf2, 0, time(NULL), -1);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
309 g_free(buf2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
310 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
311 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
312
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
313 case 301: /* MSG_SERVER_HOTLIST_ACK */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
314 /* Our buddy was added successfully */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
315 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
316
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
317 case 302: /* MSG_SERVER_HOTLIST_ERROR */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
318 buf2 = g_strdup_printf(_("Unable to add \"%s\" to your Napster hotlist"), buf);
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
319 gaim_notify_error(gc, NULL, buf2, NULL);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
320 g_free(buf2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
321 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
322
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
323 case 316: /* MSG_SERVER_DISCONNECTING */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
324 /* we have been kicked off =^( */
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
325 gaim_notify_error(gc, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
326 _("You were disconnected from the server."), NULL);
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
327 gaim_connection_destroy(gc);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
328 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
329
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
330 case 401: /* MSG_CLIENT_PART */
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
331 c = nap_find_chat(gc, buf);
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
332 if (c)
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
333 serv_got_chat_left(gc, gaim_chat_get_id(GAIM_CHAT(c)));
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
334 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
335
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
336 case 403: /* MSG_SERVER_PUBLIC */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
337 res = g_strsplit(buf, " ", 3);
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
338 c = nap_find_chat(gc, res[0]);
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
339 if (c)
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
340 serv_got_chat_in(gc, gaim_chat_get_id(GAIM_CHAT(c)), res[1], 0, res[2], time((time_t)NULL));
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
341 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
342 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
343
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
344 case 404: /* MSG_SERVER_NOSUCH */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
345 /* abused by opennap servers to broadcast stuff */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
346 serv_got_im(gc, "server", buf, 0, time(NULL), -1);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
347 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
348
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
349 case 405: /* MSG_SERVER_JOIN_ACK */
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
350 c = nap_find_chat(gc, buf);
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
351 if (!c)
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
352 serv_got_joined_chat(gc, gaim_chat_get_id(GAIM_CHAT(c)), buf);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
353 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
354
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
355 case 407: /* MSG_SERVER_PART */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
356 res = g_strsplit(buf, " ", 0);
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
357 c = nap_find_chat(gc, res[0]);
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
358 gaim_chat_remove_user(GAIM_CHAT(c), res[1], NULL);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
359 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
360 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
361
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
362 case 406: /* MSG_SERVER_JOIN */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
363 case 408: /* MSG_SERVER_CHANNEL_USER_LIST */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
364 res = g_strsplit(buf, " ", 4);
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
365 c = nap_find_chat(gc, res[0]);
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
366 gaim_chat_add_user(GAIM_CHAT(c), res[1], NULL);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
367 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
368 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
369
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
370 case 409: /* MSG_SERVER_CHANNEL_USER_LIST_END */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
371 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
372
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
373 case 410: /* MSG_SERVER_TOPIC */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
374 /* display the topic in the channel */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
375 res = g_strsplit(buf, " ", 2);
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
376 c = nap_find_chat(gc, res[0]);
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
377 gaim_chat_set_topic(GAIM_CHAT(c), res[0], res[1]);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
378 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
379 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
380
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
381 case 603: /* MSG_CLIENT_WHOIS */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
382 buf2 = g_strdup_printf(_("%s requested your information"), buf);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
383 serv_got_im(gc, "server", buf2, 0, time(NULL), -1);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
384 g_free(buf2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
385 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
386
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
387 case 604: /* MSG_SERVER_WHOIS_RESPONSE */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
388 /* XXX - Format is: "Elite" 37 " " "Active" 0 0 0 0 "gaim 0.63cvs" 0 0 192.168.1.41 32798 0 unknown flounder */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
389 res = g_strsplit(buf, " ", 2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
390 g_show_info_text(gc, res[0], 2, res[1], NULL);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
391 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
392 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
393
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
394 case 621:
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
395 case 622: /* MSG_CLIENT_MOTD */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
396 /* also replaces MSG_SERVER_MOTD, so we should display it */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
397 serv_got_im(gc, "motd", buf, 0, time(NULL), -1);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
398 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
399
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
400 case 627: /* MSG_CLIENT_WALLOP */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
401 /* abused by opennap server maintainers to broadcast stuff */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
402 serv_got_im(gc, "wallop", buf, 0, time(NULL), -1);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
403 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
404
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
405 case 628: /* MSG_CLIENT_ANNOUNCE */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
406 serv_got_im(gc, "announce", buf, 0, time(NULL), -1);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
407 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
408
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
409 case 748: /* MSG_SERVER_GHOST */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
410 /* Looks like someone logged in as us! =-O */
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
411 gaim_notify_error(gc, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
412 _("You were disconnected from the server, because "
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
413 "you logged on from a different location"), NULL);
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
414 gaim_connection_destroy(gc);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
415 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
416
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
417 case 751: /* MSG_CLIENT_PING */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
418 buf2 = g_strdup_printf(_("%s requested a PING"), buf);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
419 serv_got_im(gc, "server", buf2, 0, time(NULL), -1);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
420 g_free(buf2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
421 /* send back a pong */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
422 /* MSG_CLIENT_PONG */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
423 nap_write_packet(gc, 752, "%s", buf);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
424 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
425
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
426 case 752: /* MSG_CLIENT_PONG */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
427 buf2 = g_strdup_printf("Received pong from %s", buf);
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
428 gaim_notify_info(gc, NULL, buf2, NULL);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
429 g_free(buf2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
430 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
431
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
432 case 824: /* MSG_CLIENT_EMOTE */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
433 res = g_strsplit(buf, " ", 3);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
434 buf2 = g_strndup(res[2]+1, strlen(res[2]) - 2); /* chomp off the surround quotes */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
435 buf3 = g_strdup_printf("/me %s", buf2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
436 g_free(buf2);
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
437 if ((c = nap_find_chat(gc, res[0]))) {
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
438 gaim_chat_write(GAIM_CHAT(c), res[1], buf3, WFLAG_NICK, time(NULL));
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
439 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
440 g_free(buf3);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
441 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
442 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
443
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
444 default:
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
445 gaim_debug(GAIM_DEBUG_MISC, "napster", "Unknown packet %hd: %s\n", command, buf);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
446 break;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 }
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
448
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
449 g_free(buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
450 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
452 /* 002 - MSG_CLIENT_LOGIN */
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
453 static void nap_login_connect(gpointer data, gint source, GaimInputCondition cond)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 {
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
455 GaimConnection *gc = data;
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
456 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
457 gchar *buf;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458
5605
4fa8ca4f4259 [gaim-migrate @ 6009]
Nathan Walp <nwalp@pidgin.im>
parents: 5604
diff changeset
459 if (!g_list_find(gaim_connections_get_all(), gc)) {
2701
8a84f2bb1716 [gaim-migrate @ 2714]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
460 close(source);
8a84f2bb1716 [gaim-migrate @ 2714]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
461 return;
8a84f2bb1716 [gaim-migrate @ 2714]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
462 }
8a84f2bb1716 [gaim-migrate @ 2714]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
463
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464 if (source < 0) {
6321
3613007cbb6e [gaim-migrate @ 6820]
Luke Schierer <lschiere@pidgin.im>
parents: 6059
diff changeset
465 gaim_connection_error(gc, _("Unable to connect"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
467 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468
4452
2afc0f845e74 [gaim-migrate @ 4727]
Sean Egan <seanegan@gmail.com>
parents: 4359
diff changeset
469 ndata->fd = source;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
471 /* Update the login progress status display */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
472 buf = g_strdup_printf("Logging in: %s", gaim_account_get_username(gc->account));
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
473 gaim_connection_update_progress(gc, buf, 2, NAPSTER_CONNECT_STEPS);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
474 g_free(buf);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
475
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
476 /* Write our signon data */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
477 nap_write_packet(gc, 2, "%s %s 0 \"gaim %s\" 0",
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
478 gaim_account_get_username(gc->account),
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
479 gaim_account_get_password(gc->account), VERSION);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
480
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
481 /* And set up the input watcher */
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
482 gc->inpa = gaim_input_add(ndata->fd, GAIM_INPUT_READ, nap_callback, gc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
483 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
484
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
485 static void nap_login(GaimAccount *account)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 {
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
487 GaimConnection *gc = gaim_account_get_connection(account);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
488
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
489 gaim_connection_update_progress(gc, _("Connecting"), 1, NAPSTER_CONNECT_STEPS);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
490
4460
23af9ba33ca4 [gaim-migrate @ 4735]
Nathan Walp <nwalp@pidgin.im>
parents: 4455
diff changeset
491 gc->proto_data = g_new0(struct nap_data, 1);
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5679
diff changeset
492 if (gaim_proxy_connect(account,
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
493 gaim_account_get_string(account, "server", NAP_SERVER),
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
494 gaim_account_get_int(account, "port", NAP_PORT),
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4460
diff changeset
495 nap_login_connect, gc) != 0) {
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
496 gaim_connection_error(gc, _("Unable to connect"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
500 static void nap_close(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
502 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
503
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 if (gc->inpa)
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
505 gaim_input_remove(gc->inpa);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
506
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
507 if (!ndata)
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
508 return;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
509
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
510 g_free(ndata->email);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
511 g_free(ndata);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
512 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
513
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
514 static const char* nap_list_icon(GaimAccount *a, struct buddy *b)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
515 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4634
diff changeset
516 return "napster";
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
517 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4793
diff changeset
519 static void nap_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne)
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4793
diff changeset
520 {
5068
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 4916
diff changeset
521 if (b->present == GAIM_BUDDY_OFFLINE)
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4793
diff changeset
522 *se = "offline";
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4793
diff changeset
523 }
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4793
diff changeset
524
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
525 static GList *nap_buddy_menu(GaimConnection *gc, const char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
526 {
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
527 GList *m = NULL;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
528 struct proto_buddy_menu *pbm;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
529
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
530 pbm = g_new0(struct proto_buddy_menu, 1);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
531 pbm->label = _("Get Info");
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
532 pbm->callback = nap_get_info;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
533 pbm->gc = gc;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
534 m = g_list_append(m, pbm);
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
535
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
536 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
537 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
538
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
539 static GList *nap_chat_info(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
540 {
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
541 GList *m = NULL;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
542 struct proto_chat_entry *pce;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
543
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
544 pce = g_new0(struct proto_chat_entry, 1);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
545 pce->label = _("Join what group:");
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
546 pce->identifier = "group";
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
547 m = g_list_append(m, pce);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
548
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
549 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
550 }
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
551
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
552 static GaimPlugin *my_protocol = NULL;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
553
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
554 static GaimPluginProtocolInfo prpl_info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
555 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
556 GAIM_PROTO_NAPSTER,
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
557 OPT_PROTO_CHAT_TOPIC,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
558 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
559 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
560 nap_list_icon,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
561 nap_list_emblems,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
562 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
563 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
564 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
565 NULL,
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
566 nap_buddy_menu,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
567 nap_chat_info,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
568 nap_login,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
569 nap_close,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
570 nap_send_im,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
571 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
572 NULL,
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
573 nap_get_info,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
574 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
575 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
576 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
577 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
578 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
579 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
580 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
581 nap_add_buddy,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
582 nap_add_buddies,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
583 nap_remove_buddy,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
584 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
585 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
586 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
587 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
588 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
589 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
590 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
591 nap_join_chat,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
592 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
593 nap_chat_leave,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
594 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
595 nap_chat_send,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
596 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
597 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
598 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
599 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
600 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
601 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
602 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
603 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
604 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
605 NULL
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
606 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
607
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
608 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
609 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
610 2, /**< api_version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
611 GAIM_PLUGIN_PROTOCOL, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
612 NULL, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
613 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
614 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
615 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
616
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
617 "prpl-napster", /**< id */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
618 "Napster", /**< name */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
619 VERSION, /**< version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
620 /** summary */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
621 N_("NAPSTER Protocol Plugin"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
622 /** description */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
623 N_("NAPSTER Protocol Plugin"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
624 NULL, /**< author */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6321
diff changeset
625 GAIM_WEBSITE, /**< homepage */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
626
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
627 NULL, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
628 NULL, /**< unload */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
629 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
630
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
631 NULL, /**< ui_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
632 &prpl_info /**< extra_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
633 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
634
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
635 static void init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
636 {
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
637 GaimAccountOption *option;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
638
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
639 option = gaim_account_option_string_new(_("Server"), "server",
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
640 NAP_SERVER);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
641 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
642 option);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
643
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
644 option = gaim_account_option_int_new(_("Port"), "port", 8888);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
645 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
646 option);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
647
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
648 my_protocol = plugin;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
649 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
650
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
651 GAIM_INIT_PLUGIN(napster, init_plugin, info);