annotate src/protocols/napster/napster.c @ 8170:9d1a984681fe

[gaim-migrate @ 8883] Gary Kramlich is probably getting sick of the prefs system, but at least he made a nice interface for protocol prefs. Thanks Gary! committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 25 Jan 2004 22:15:42 +0000
parents ad5c8f01882b
children 143d0b29ba82
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>
7084
0909ebf6fb28 [gaim-migrate @ 7649]
Christian Hammond <chipx86@chipx86.com>
parents: 7062
diff changeset
5 *
2086
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 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
20 #include "internal.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
22 #include "account.h"
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
23 #include "accountopt.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
24 #include "conversation.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
25 #include "debug.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #include "multi.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
27 #include "notify.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #include "prpl.h"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include "proxy.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
30 #include "util.h"
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3593
diff changeset
31
3322
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
32 #define NAP_SERVER "64.124.41.187"
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
33 #define NAP_PORT 8888
b77edfedc39f [gaim-migrate @ 3340]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
34
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
35 #define NAPSTER_CONNECT_STEPS 2
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
36
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 GSList *nap_connections = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 struct nap_data {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 int fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 gchar *email;
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
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
44 static GaimConversation *nap_find_chat(GaimConnection *gc, const char *name)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 {
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
46 GSList *bcs = gc->buddy_chats;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
48 while (bcs) {
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
49 GaimConversation *b = bcs->data;
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
50 if (!gaim_utf8_strcasecmp(b->name, name))
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
51 return b;
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
52 bcs = bcs->next;
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
53 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
54
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
55 return NULL;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
56 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
57
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
58 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
59 {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
60 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
61 va_list ap;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
62 gchar *message;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
63 unsigned short size;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
64
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
65 va_start(ap, format);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
66 message = g_strdup_vprintf(format, ap);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
67 va_end(ap);
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 size = strlen(message);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
70 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
71
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
72 write(ndata->fd, &size, 2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
73 write(ndata->fd, &command, 2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
74 write(ndata->fd, message, size);
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 g_free(message);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
77 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
78
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
79 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
80 {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
81 gchar **res;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
82
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
83 gaim_debug(GAIM_DEBUG_MISC, "napster", "C %s\n", message);
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 res = g_strsplit(message, " ", 2);
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 if (!strcasecmp(res[0], "/ME")) { /* MSG_CLIENT_PUBLIC */
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
88 nap_write_packet(gc, 824, "%s \"%s\"", name, res[1]);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
89
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
90 } else if (!strcasecmp(res[0], "/MSG")) { /* MSG_CLIENT_PUBLIC */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
91 nap_write_packet(gc, 205, "%s", res[1]);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
92
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
93 } else if (!strcasecmp(res[0], "/JOIN")) { /* join chatroom MSG_CLIENT_JOIN */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
94 if (!res[1]) {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
95 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
96 return 1;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
97 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
98 if (res[1][0] != '#')
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
99 nap_write_packet(gc, 400, "#%s", res[1]);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
100 else
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
101 nap_write_packet(gc, 400, "%s", res[1]);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
102
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
103 } else if (!strcasecmp(res[0], "/PART")) { /* partchatroom MSG_CLIENT_PART */
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
104 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
105
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
106 } 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
107 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
108
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
109 } else if (!strcasecmp(res[0], "/WHOIS")) { /* whois request MSG_CLIENT_WHOIS */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
110 nap_write_packet(gc, 603, "%s", res[1]);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
111
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
112 } else if (!strcasecmp(res[0], "/PING")) { /* send ping MSG_CLIENT_PING */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
113 nap_write_packet(gc, 751, "%s", res[1]);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
114
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
115 } else if (!strcasecmp(res[0], "/KICK")) { /* kick asswipe MSG_CLIENT_KICK */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
116 nap_write_packet(gc, 829, "%s", res[1]);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
117
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
118 } else {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
119 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
120 return 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
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 0;
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 /* 205 - MSG_CLIENT_PRIVMSG */
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
128 static int nap_send_im(GaimConnection *gc, const char *who, const char *message, GaimConvImFlags flags)
5388
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 if ((strlen(message) < 2) || (message[0] != '/' ) || (message[1] == '/')) {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
132 /* Actually send a chat message */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
133 nap_write_packet(gc, 205, "%s %s", who, message);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
134 } else {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
135 /* user typed an IRC-style command */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
136 nap_do_irc_style(gc, message, who);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
139 return 1;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
140 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
141
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
142 /* 207 - MSG_CLIENT_ADD_HOTLIST */
6787
faa491042c66 [gaim-migrate @ 7326]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
143 static void nap_add_buddy(GaimConnection *gc, const char *name, GaimGroup *group)
5388
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 nap_write_packet(gc, 207, "%s", name);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
146 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
147
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
148 /* 208 - MSG_CLIENT_ADD_HOTLIST_SEQ */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
149 static void nap_add_buddies(GaimConnection *gc, GList *buddies)
5388
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 while (buddies) {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
152 nap_write_packet(gc, 208, "%s", (char *)buddies->data);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
153 buddies = buddies -> next;
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 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
156
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
157 /* 303 - MSG_CLIENT_REMOVE_HOTLIST */
6059
d8cd876e613e [gaim-migrate @ 6509]
Mark Doliner <mark@kingant.net>
parents: 5920
diff changeset
158 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
159 {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
160 nap_write_packet(gc, 303, "%s", name);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
161 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
162
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
163 /* 400 - MSG_CLIENT_JOIN */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
164 static void nap_join_chat(GaimConnection *gc, GHashTable *data)
5388
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 char *name;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
167
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
168 if (!data)
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
169 return;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
170
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
171 name = g_hash_table_lookup(data, "group");
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
172
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
173 /* Make sure the name has a # preceeding it */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
174 if (name[0] != '#')
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
175 nap_write_packet(gc, 400, "#%s", name);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
176 else
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
177 nap_write_packet(gc, 400, "%s", name);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
178 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
179
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
180 /* 401 - MSG_CLIENT_PART */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
181 static void nap_chat_leave(GaimConnection *gc, int id)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
182 {
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
183 GaimConversation *c = gaim_find_chat(gc, id);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
184
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
185 if (!c)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
186 return;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
187
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
188 nap_write_packet(gc, 401, "%s", c->name);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
189 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
190
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
191 /* 402 - MSG_CLIENT_PUBLIC */
6059
d8cd876e613e [gaim-migrate @ 6509]
Mark Doliner <mark@kingant.net>
parents: 5920
diff changeset
192 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
193 {
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
194 GaimConversation *c = gaim_find_chat(gc, id);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
195
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
196 if (!c)
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
197 return -EINVAL;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
198
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
199 if ((strlen(message) < 2) || (message[0] != '/' ) || (message[1] == '/')) {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
200 /* Actually send a chat message */
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
201 nap_write_packet(gc, 402, "%s %s", c->name, message);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
202 } else {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
203 /* user typed an IRC-style command */
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
204 nap_do_irc_style(gc, message, c->name);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
205 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
206
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
207 return 0;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
208 }
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 /* 603 - MSG_CLIENT_WHOIS */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
211 static void nap_get_info(GaimConnection *gc, const char *who)
5388
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 nap_write_packet(gc, 603, "%s", who);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
216 static void nap_callback(gpointer data, gint source, GaimInputCondition condition)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 {
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
218 GaimConnection *gc = data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 struct nap_data *ndata = gc->proto_data;
5679
0a0116686d51 [gaim-migrate @ 6097]
Nathan Walp <nwalp@pidgin.im>
parents: 5638
diff changeset
220 GaimConversation *c;
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
221 gchar *buf, *buf2, *buf3, **res;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 unsigned short header[2];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 int len;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 int command;
2220
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
225 int i;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
227 if (read(source, (void*)header, 4) != 4) {
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
228 gaim_connection_error(gc, _("Unable to read header from server"));
2220
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
229 return;
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
230 }
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
231
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 len = header[0];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 command = header[1];
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
234 buf = (gchar *)g_malloc((len + 1) * sizeof(gchar));
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
235 buf[len] = '\0';
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236
2220
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
237 i = 0;
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
238 do {
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
239 int tmp = read(source, buf + i, len - i);
2220
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
240 if (tmp <= 0) {
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
241 g_free(buf);
6979
bdd046deec7e [gaim-migrate @ 7535]
Mark Doliner <mark@kingant.net>
parents: 6787
diff changeset
242 buf = g_strdup_printf(_("Unable to read message from server. Command is %hd, length is %hd."), len, command);
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
243 gaim_connection_error(gc, buf);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
244 g_free(buf);
2220
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
245 return;
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
246 }
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
247 i += tmp;
8b7ba25a7ece [gaim-migrate @ 2230]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2205
diff changeset
248 } while (i != len);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
250 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
251
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
252 switch (command) {
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
253 case 000: /* MSG_SERVER_ERROR */
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
254 gaim_notify_error(gc, NULL, buf, NULL);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
255 gaim_input_remove(gc->inpa);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
256 gc->inpa = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257 close(source);
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
258 gaim_connection_destroy(gc);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
259 break;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
261 case 003: /* MSG_SERVER_EMAIL */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
262 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
263 ndata->email = g_strdup(buf);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 /* Our signon is complete */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
266 gaim_connection_set_state(gc, GAIM_CONNECTED);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 serv_finish_login(gc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
269 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
270
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
271 case 201: /* MSG_SERVER_SEARCH_RESULT */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
272 res = g_strsplit(buf, " ", 0);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
273 serv_got_update(gc, res[0], 1, 0, 0, 0, 0);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
274 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
275 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
276
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
277 case 202: /* MSG_SERVER_SEARCH_END */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
278 serv_got_update(gc, buf, 0, 0, 0, 0, 0);
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 205: /* MSG_CLIENT_PRIVMSG */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
282 res = g_strsplit(buf, " ", 2);
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6979
diff changeset
283 serv_got_im(gc, res[0], res[1], 0, time(NULL));
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
284 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
285 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
286
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
287 case 209: /* MSG_SERVER_USER_SIGNON */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
288 /* USERNAME SPEED */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
289 res = g_strsplit(buf, " ", 2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
290 serv_got_update(gc, res[0], 1, 0, 0, 0, 0);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
291 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
292 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
293
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
294 case 210: /* MSG_SERVER_USER_SIGNOFF */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
295 /* USERNAME SPEED */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
296 res = g_strsplit(buf, " ", 2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
297 serv_got_update(gc, res[0], 0, 0, 0, 0, 0);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
298 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
299 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
300
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
301 case 214: /* MSG_SERVER_STATS */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
302 res = g_strsplit(buf, " ", 3);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
303 buf2 = g_strdup_printf(_("users: %s, files: %s, size: %sGB"), res[0], res[1], res[2]);
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6979
diff changeset
304 serv_got_im(gc, "server", buf2, 0, time(NULL));
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
305 g_free(buf2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
306 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
307 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
308
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
309 case 301: /* MSG_SERVER_HOTLIST_ACK */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
310 /* Our buddy was added successfully */
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 302: /* MSG_SERVER_HOTLIST_ERROR */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
314 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
315 gaim_notify_error(gc, NULL, buf2, NULL);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
316 g_free(buf2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
317 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
318
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
319 case 316: /* MSG_SERVER_DISCONNECTING */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
320 /* we have been kicked off =^( */
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
321 gaim_notify_error(gc, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
322 _("You were disconnected from the server."), NULL);
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
323 gaim_connection_destroy(gc);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
324 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
325
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
326 case 401: /* MSG_CLIENT_PART */
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
327 c = nap_find_chat(gc, buf);
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
328 if (c)
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
329 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(c)));
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
330 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
331
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
332 case 403: /* MSG_SERVER_PUBLIC */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
333 res = g_strsplit(buf, " ", 3);
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
334 c = nap_find_chat(gc, res[0]);
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
335 if (c)
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
336 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_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
337 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
338 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
339
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
340 case 404: /* MSG_SERVER_NOSUCH */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
341 /* abused by opennap servers to broadcast stuff */
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6979
diff changeset
342 serv_got_im(gc, "server", buf, 0, time(NULL));
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
343 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
344
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
345 case 405: /* MSG_SERVER_JOIN_ACK */
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
346 c = nap_find_chat(gc, buf);
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
347 if (!c)
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
348 serv_got_joined_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(c)), buf);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
349 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
350
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
351 case 407: /* MSG_SERVER_PART */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
352 res = g_strsplit(buf, " ", 0);
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
353 c = nap_find_chat(gc, res[0]);
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
354 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(c), res[1], NULL);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
355 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
356 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
357
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
358 case 406: /* MSG_SERVER_JOIN */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
359 case 408: /* MSG_SERVER_CHANNEL_USER_LIST */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
360 res = g_strsplit(buf, " ", 4);
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
361 c = nap_find_chat(gc, res[0]);
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
362 gaim_conv_chat_add_user(GAIM_CONV_CHAT(c), res[1], NULL);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
363 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
364 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
365
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
366 case 409: /* MSG_SERVER_CHANNEL_USER_LIST_END */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
367 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
368
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
369 case 410: /* MSG_SERVER_TOPIC */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
370 /* display the topic in the channel */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
371 res = g_strsplit(buf, " ", 2);
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
372 c = nap_find_chat(gc, res[0]);
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
373 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), res[0], res[1]);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
374 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
375 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
376
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
377 case 603: /* MSG_CLIENT_WHOIS */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
378 buf2 = g_strdup_printf(_("%s requested your information"), buf);
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6979
diff changeset
379 serv_got_im(gc, "server", buf2, 0, time(NULL));
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
380 g_free(buf2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
381 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
382
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
383 case 604: /* MSG_SERVER_WHOIS_RESPONSE */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
384 /* 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
385 res = g_strsplit(buf, " ", 2);
7062
86ed8b2aa665 [gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
386 /* res[0] == username */
86ed8b2aa665 [gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
387 gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL,
86ed8b2aa665 [gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
388 res[1], NULL, NULL);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
389 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
390 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
391
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
392 case 621:
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
393 case 622: /* MSG_CLIENT_MOTD */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
394 /* also replaces MSG_SERVER_MOTD, so we should display it */
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6979
diff changeset
395 serv_got_im(gc, "motd", buf, 0, time(NULL));
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
396 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
397
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
398 case 627: /* MSG_CLIENT_WALLOP */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
399 /* abused by opennap server maintainers to broadcast stuff */
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6979
diff changeset
400 serv_got_im(gc, "wallop", buf, 0, time(NULL));
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
401 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
402
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
403 case 628: /* MSG_CLIENT_ANNOUNCE */
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6979
diff changeset
404 serv_got_im(gc, "announce", buf, 0, time(NULL));
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
405 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
406
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
407 case 748: /* MSG_SERVER_GHOST */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
408 /* Looks like someone logged in as us! =-O */
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
409 gaim_notify_error(gc, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
410 _("You were disconnected from the server, because "
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
411 "you logged on from a different location"), NULL);
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
412 gaim_connection_destroy(gc);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
413 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
414
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
415 case 751: /* MSG_CLIENT_PING */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
416 buf2 = g_strdup_printf(_("%s requested a PING"), buf);
6982
083d1e4a9c78 [gaim-migrate @ 7538]
Mark Doliner <mark@kingant.net>
parents: 6979
diff changeset
417 serv_got_im(gc, "server", buf2, 0, time(NULL));
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
418 g_free(buf2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
419 /* send back a pong */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
420 /* MSG_CLIENT_PONG */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
421 nap_write_packet(gc, 752, "%s", buf);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
422 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
423
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
424 case 752: /* MSG_CLIENT_PONG */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
425 buf2 = g_strdup_printf("Received pong from %s", buf);
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5402
diff changeset
426 gaim_notify_info(gc, NULL, buf2, NULL);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
427 g_free(buf2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
428 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
429
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
430 case 824: /* MSG_CLIENT_EMOTE */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
431 res = g_strsplit(buf, " ", 3);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
432 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
433 buf3 = g_strdup_printf("/me %s", buf2);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
434 g_free(buf2);
5402
f3cf3bff72f0 [gaim-migrate @ 5778]
Mark Doliner <mark@kingant.net>
parents: 5388
diff changeset
435 if ((c = nap_find_chat(gc, res[0]))) {
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
436 gaim_conv_chat_write(GAIM_CONV_CHAT(c), res[1], buf3, GAIM_MESSAGE_NICK, time(NULL));
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
437 }
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
438 g_free(buf3);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
439 g_strfreev(res);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
440 break;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
441
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
442 default:
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
443 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
444 break;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445 }
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
446
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
447 g_free(buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
450 /* 002 - MSG_CLIENT_LOGIN */
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
451 static void nap_login_connect(gpointer data, gint source, GaimInputCondition cond)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452 {
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
453 GaimConnection *gc = data;
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
454 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
455 gchar *buf;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456
5605
4fa8ca4f4259 [gaim-migrate @ 6009]
Nathan Walp <nwalp@pidgin.im>
parents: 5604
diff changeset
457 if (!g_list_find(gaim_connections_get_all(), gc)) {
2701
8a84f2bb1716 [gaim-migrate @ 2714]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
458 close(source);
8a84f2bb1716 [gaim-migrate @ 2714]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
459 return;
8a84f2bb1716 [gaim-migrate @ 2714]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
460 }
8a84f2bb1716 [gaim-migrate @ 2714]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
461
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
462 if (source < 0) {
7981
ad5c8f01882b [gaim-migrate @ 8658]
Luke Schierer <lschiere@pidgin.im>
parents: 7956
diff changeset
463 gaim_connection_error(gc, _("Unable to connect."));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466
4452
2afc0f845e74 [gaim-migrate @ 4727]
Sean Egan <seanegan@gmail.com>
parents: 4359
diff changeset
467 ndata->fd = source;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
469 /* Update the login progress status display */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
470 buf = g_strdup_printf("Logging in: %s", gaim_account_get_username(gc->account));
7884
71354edf06d7 [gaim-migrate @ 8538]
Mark Doliner <mark@kingant.net>
parents: 7844
diff changeset
471 gaim_connection_update_progress(gc, buf, 1, NAPSTER_CONNECT_STEPS);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
472 g_free(buf);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
473
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
474 /* Write our signon data */
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
475 nap_write_packet(gc, 2, "%s %s 0 \"gaim %s\" 0",
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
476 gaim_account_get_username(gc->account),
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
477 gaim_account_get_password(gc->account), VERSION);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
478
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479 /* And set up the input watcher */
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
480 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
481 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
482
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
483 static void nap_login(GaimAccount *account)
2086
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 GaimConnection *gc = gaim_account_get_connection(account);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
486
7884
71354edf06d7 [gaim-migrate @ 8538]
Mark Doliner <mark@kingant.net>
parents: 7844
diff changeset
487 gaim_connection_update_progress(gc, _("Connecting"), 0, NAPSTER_CONNECT_STEPS);
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
488
4460
23af9ba33ca4 [gaim-migrate @ 4735]
Nathan Walp <nwalp@pidgin.im>
parents: 4455
diff changeset
489 gc->proto_data = g_new0(struct nap_data, 1);
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5679
diff changeset
490 if (gaim_proxy_connect(account,
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
491 gaim_account_get_string(account, "server", NAP_SERVER),
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
492 gaim_account_get_int(account, "port", NAP_PORT),
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4460
diff changeset
493 nap_login_connect, gc) != 0) {
7981
ad5c8f01882b [gaim-migrate @ 8658]
Luke Schierer <lschiere@pidgin.im>
parents: 7956
diff changeset
494 gaim_connection_error(gc, _("Unable to connect."));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
495 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
496 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
498 static void nap_close(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
500 struct nap_data *ndata = (struct nap_data *)gc->proto_data;
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
501
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
502 if (gc->inpa)
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
503 gaim_input_remove(gc->inpa);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
505 if (!ndata)
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
506 return;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
507
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
508 g_free(ndata->email);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
509 g_free(ndata);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
510 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
511
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6622
diff changeset
512 static const char* nap_list_icon(GaimAccount *a, GaimBuddy *b)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
513 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4634
diff changeset
514 return "napster";
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
515 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6622
diff changeset
517 static void nap_list_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne)
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4793
diff changeset
518 {
5068
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 4916
diff changeset
519 if (b->present == GAIM_BUDDY_OFFLINE)
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4793
diff changeset
520 *se = "offline";
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4793
diff changeset
521 }
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4793
diff changeset
522
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
523 static GList *nap_buddy_menu(GaimConnection *gc, const char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
524 {
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
525 GList *m = NULL;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
526 struct proto_buddy_menu *pbm;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
527
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
528 pbm = g_new0(struct proto_buddy_menu, 1);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
529 pbm->label = _("Get Info");
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
530 pbm->callback = nap_get_info;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
531 pbm->gc = gc;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
532 m = g_list_append(m, pbm);
3572
bdd0bebd2d04 [gaim-migrate @ 3670]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
533
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
534 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
535 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
536
5604
92b2c7f461f9 [gaim-migrate @ 6008]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
537 static GList *nap_chat_info(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
538 {
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
539 GList *m = NULL;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
540 struct proto_chat_entry *pce;
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
541
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
542 pce = g_new0(struct proto_chat_entry, 1);
7844
a6298fd7ee21 [gaim-migrate @ 8498]
Mark Doliner <mark@kingant.net>
parents: 7118
diff changeset
543 pce->label = _("_Group:");
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
544 pce->identifier = "group";
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
545 m = g_list_append(m, pce);
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
546
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
547 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
548 }
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
549
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
550 static GaimPlugin *my_protocol = NULL;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
551
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
552 static GaimPluginProtocolInfo prpl_info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
553 {
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
554 OPT_PROTO_CHAT_TOPIC,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
555 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
556 NULL,
8170
9d1a984681fe [gaim-migrate @ 8883]
Nathan Walp <nwalp@pidgin.im>
parents: 7981
diff changeset
557 NULL,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
558 nap_list_icon,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
559 nap_list_emblems,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
560 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
561 NULL,
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,
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
564 nap_buddy_menu,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
565 nap_chat_info,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
566 nap_login,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
567 nap_close,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
568 nap_send_im,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
569 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
570 NULL,
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
571 nap_get_info,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
572 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
573 NULL,
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 nap_add_buddy,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
580 nap_add_buddies,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
581 nap_remove_buddy,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
582 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
583 NULL,
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 nap_join_chat,
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_chat_leave,
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_send,
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 NULL,
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 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
605
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
606 static GaimPluginInfo info =
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 2, /**< api_version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
609 GAIM_PLUGIN_PROTOCOL, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
610 NULL, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
611 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
612 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
613 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
614
5388
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
615 "prpl-napster", /**< id */
5d0df915ca09 [gaim-migrate @ 5764]
Mark Doliner <mark@kingant.net>
parents: 5234
diff changeset
616 "Napster", /**< name */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
617 VERSION, /**< version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
618 /** summary */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
619 N_("NAPSTER Protocol Plugin"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
620 /** description */
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 NULL, /**< author */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6321
diff changeset
623 GAIM_WEBSITE, /**< homepage */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
624
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
625 NULL, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
626 NULL, /**< unload */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
627 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
628
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
629 NULL, /**< ui_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
630 &prpl_info /**< extra_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
631 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
632
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
633 static void init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
634 {
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
635 GaimAccountOption *option;
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 option = gaim_account_option_string_new(_("Server"), "server",
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
638 NAP_SERVER);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
639 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
640 option);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
641
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
642 option = gaim_account_option_int_new(_("Port"), "port", 8888);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
643 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5605
diff changeset
644 option);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
645
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
646 my_protocol = plugin;
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
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
649 GAIM_INIT_PLUGIN(napster, init_plugin, info);