Mercurial > pidgin
annotate plugins/oscar.c @ 1028:e4147c8604cc
[gaim-migrate @ 1038]
This is a little more efficient.
committer: Tailor Script <tailor@pidgin.im>
| author | Rob Flynn <gaim@robflynn.com> |
|---|---|
| date | Thu, 26 Oct 2000 11:48:42 +0000 |
| parents | 91b7377e7b45 |
| children | 8a4290984d1e |
| rev | line source |
|---|---|
| 981 | 1 /* |
| 2 * gaim | |
| 3 * | |
| 4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
| 5 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx> | |
| 6 * | |
| 7 * This program is free software; you can redistribute it and/or modify | |
| 8 * it under the terms of the GNU General Public License as published by | |
| 9 * the Free Software Foundation; either version 2 of the License, or | |
| 10 * (at your option) any later version. | |
| 11 * | |
| 12 * This program is distributed in the hope that it will be useful, | |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 * GNU General Public License for more details. | |
| 16 * | |
| 17 * You should have received a copy of the GNU General Public License | |
| 18 * along with this program; if not, write to the Free Software | |
| 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 20 * | |
| 21 */ | |
| 22 | |
| 23 #ifdef HAVE_CONFIG_H | |
| 24 #include "../config.h" | |
| 25 #endif | |
| 26 | |
| 27 | |
| 28 #include <netdb.h> | |
| 29 #include <gtk/gtk.h> | |
| 30 #include <unistd.h> | |
| 31 #include <errno.h> | |
| 32 #include <netinet/in.h> | |
| 33 #include <arpa/inet.h> | |
| 34 #include <string.h> | |
| 35 #include <stdlib.h> | |
| 36 #include <stdio.h> | |
| 37 #include <time.h> | |
| 38 #include <sys/socket.h> | |
| 39 #include <sys/stat.h> | |
| 40 #include "multi.h" | |
| 41 #include "prpl.h" | |
| 42 #include "gaim.h" | |
| 43 #include "aim.h" | |
| 44 #include "gnome_applet_mgr.h" | |
| 45 | |
| 46 #include "pixmaps/cancel.xpm" | |
| 47 #include "pixmaps/ok.xpm" | |
| 48 | |
| 49 int gaim_caps = AIM_CAPS_CHAT | AIM_CAPS_SENDFILE | AIM_CAPS_GETFILE | | |
| 50 AIM_CAPS_VOICE | AIM_CAPS_IMIMAGE | AIM_CAPS_BUDDYICON; | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
51 |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
52 struct oscar_data { |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
53 struct aim_session_t *sess; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
54 struct aim_conn_t *conn; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
55 |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
56 int cnpa; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
57 int paspa; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
58 |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
59 int create_exchange; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
60 char *create_name; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
61 |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
62 GSList *oscar_chats; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
63 }; |
| 981 | 64 |
| 65 struct chat_connection *find_oscar_chat(struct gaim_connection *gc, char *name) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
66 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; |
| 981 | 67 struct chat_connection *c = NULL; |
| 68 if (gc->protocol != PROTO_OSCAR) return NULL; | |
| 69 | |
| 70 while (g) { | |
| 71 c = (struct chat_connection *)g->data; | |
| 72 if (!strcmp(name, c->name)) | |
| 73 break; | |
| 74 g = g->next; | |
| 75 c = NULL; | |
| 76 } | |
| 77 | |
| 78 return c; | |
| 79 } | |
| 80 | |
| 81 static struct chat_connection *find_oscar_chat_by_conn(struct gaim_connection *gc, | |
| 82 struct aim_conn_t *conn) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
83 GSList *g = ((struct oscar_data *)gc->proto_data)->oscar_chats; |
| 981 | 84 struct chat_connection *c = NULL; |
| 85 | |
| 86 while (g) { | |
| 87 c = (struct chat_connection *)g->data; | |
| 88 if (c->conn == conn) | |
| 89 break; | |
| 90 g = g->next; | |
| 91 c = NULL; | |
| 92 } | |
| 93 | |
| 94 return c; | |
| 95 } | |
| 96 | |
| 97 static struct gaim_connection *find_gaim_conn_by_aim_sess(struct aim_session_t *sess) { | |
| 98 GSList *g = connections; | |
| 99 struct gaim_connection *gc = NULL; | |
| 100 | |
| 101 while (g) { | |
| 102 gc = (struct gaim_connection *)g->data; | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
103 if (sess == ((struct oscar_data *)gc->proto_data)->sess) |
| 981 | 104 break; |
| 105 g = g->next; | |
| 106 gc = NULL; | |
| 107 } | |
| 108 | |
| 109 return gc; | |
| 110 } | |
| 111 | |
| 112 static struct gaim_connection *find_gaim_conn_by_oscar_conn(struct aim_conn_t *conn) { | |
| 113 GSList *g = connections; | |
| 114 struct gaim_connection *c = NULL; | |
| 115 struct aim_conn_t *s; | |
| 116 while (g) { | |
| 117 c = (struct gaim_connection *)g->data; | |
| 118 if (c->protocol != PROTO_OSCAR) { | |
| 119 c = NULL; | |
| 120 g = g->next; | |
| 121 continue; | |
| 122 } | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
123 s = ((struct oscar_data *)c->proto_data)->sess->connlist; |
| 981 | 124 while (s) { |
| 125 if (conn == s) | |
| 126 break; | |
| 127 s = s->next; | |
| 128 } | |
| 129 if (s) break; | |
| 130 g = g->next; | |
| 131 c = NULL; | |
| 132 } | |
| 133 | |
| 134 return c; | |
| 135 } | |
| 136 | |
| 137 static int gaim_parse_auth_resp (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 138 static int gaim_parse_login (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 139 static int gaim_server_ready (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 140 static int gaim_handle_redirect (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 141 static int gaim_parse_oncoming (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 142 static int gaim_parse_offgoing (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 143 static int gaim_parse_incoming_im(struct aim_session_t *, struct command_rx_struct *, ...); | |
| 144 static int gaim_parse_misses (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 145 static int gaim_parse_user_info (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 146 static int gaim_parse_motd (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 147 static int gaim_chatnav_info (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 148 static int gaim_chat_join (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 149 static int gaim_chat_leave (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 150 static int gaim_chat_info_update (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 151 static int gaim_chat_incoming_msg(struct aim_session_t *, struct command_rx_struct *, ...); | |
| 152 static int gaim_parse_msgack (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 153 static int gaim_parse_ratechange (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 154 static int gaim_parse_evilnotify (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 155 static int gaim_bosrights (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 156 static int gaim_rateresp (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 157 static int gaim_reportinterval (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 158 static int gaim_parse_msgerr (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 159 static int gaim_parse_buddyrights(struct aim_session_t *, struct command_rx_struct *, ...); | |
| 160 static int gaim_parse_locerr (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 161 | |
| 162 static int gaim_directim_incoming(struct aim_session_t *, struct command_rx_struct *, ...); | |
| 163 static int gaim_directim_typing (struct aim_session_t *, struct command_rx_struct *, ...); | |
| 164 static int gaim_directim_initiate(struct aim_session_t *, struct command_rx_struct *, ...); | |
| 165 | |
| 166 static char *msgerrreason[] = { | |
| 167 "Invalid error", | |
| 168 "Invalid SNAC", | |
| 169 "Rate to host", | |
| 170 "Rate to client", | |
| 171 "Not logged in", | |
| 172 "Service unavailable", | |
| 173 "Service not defined", | |
| 174 "Obsolete SNAC", | |
| 175 "Not supported by host", | |
| 176 "Not supported by client", | |
| 177 "Refused by client", | |
| 178 "Reply too big", | |
| 179 "Responses lost", | |
| 180 "Request denied", | |
| 181 "Busted SNAC payload", | |
| 182 "Insufficient rights", | |
| 183 "In local permit/deny", | |
| 184 "Too evil (sender)", | |
| 185 "Too evil (receiver)", | |
| 186 "User temporarily unavailable", | |
| 187 "No match", | |
| 188 "List overflow", | |
| 189 "Request ambiguous", | |
| 190 "Queue full", | |
| 191 "Not while on AOL" | |
| 192 }; | |
| 193 static int msgerrreasonlen = 25; | |
| 194 | |
| 195 static void oscar_callback(gpointer data, gint source, | |
| 196 GdkInputCondition condition) { | |
| 197 struct aim_conn_t *conn = (struct aim_conn_t *)data; | |
| 198 struct gaim_connection *gc = find_gaim_conn_by_oscar_conn(conn); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
199 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
| 981 | 200 if (!gc) { |
| 201 /* oh boy. this is probably bad. i guess the only thing we can really do | |
| 202 * is return? */ | |
| 203 debug_print("oscar callback for closed connection.\n"); | |
| 204 return; | |
| 205 } | |
| 206 | |
| 207 if (condition & GDK_INPUT_EXCEPTION) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
208 hide_login_progress(gc, _("Disconnected.")); |
| 981 | 209 signoff(gc); |
| 210 return; | |
| 211 } | |
| 212 if (condition & GDK_INPUT_READ) { | |
| 213 if (conn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) { | |
| 214 debug_print("got information on rendezvous\n"); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
215 if (aim_handlerendconnect(odata->sess, conn) < 0) { |
| 981 | 216 debug_print(_("connection error (rend)\n")); |
| 217 } | |
| 218 } else { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
219 if (aim_get_command(odata->sess, conn) >= 0) { |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
220 aim_rxdispatch(odata->sess); |
| 981 | 221 } else { |
| 222 if (conn->type == AIM_CONN_TYPE_RENDEZVOUS && | |
| 223 conn->subtype == AIM_CONN_SUBTYPE_OFT_DIRECTIM) { | |
| 224 struct conversation *cnv = | |
| 225 find_conversation(((struct aim_directim_priv *)conn->priv)->sn); | |
| 226 debug_print("connection error for directim\n"); | |
| 227 if (cnv) { | |
| 228 make_direct(cnv, FALSE, NULL, 0); | |
| 229 } | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
230 aim_conn_kill(odata->sess, &conn); |
| 981 | 231 } else if ((conn->type == AIM_CONN_TYPE_BOS) || |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
232 !(aim_getconn_type(odata->sess, AIM_CONN_TYPE_BOS))) { |
| 981 | 233 debug_print(_("major connection error\n")); |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
234 hide_login_progress(gc, _("Disconnected.")); |
| 981 | 235 signoff(gc); |
| 236 } else if (conn->type == AIM_CONN_TYPE_CHAT) { | |
| 237 struct chat_connection *c = find_oscar_chat_by_conn(gc, conn); | |
| 238 char buf[BUF_LONG]; | |
| 239 sprintf(debug_buff, "disconnected from chat room %s\n", c->name); | |
| 240 debug_print(debug_buff); | |
| 241 c->conn = NULL; | |
| 242 if (c->inpa > -1) | |
| 243 gdk_input_remove(c->inpa); | |
| 244 c->inpa = -1; | |
| 245 c->fd = -1; | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
246 aim_conn_kill(odata->sess, &conn); |
| 981 | 247 sprintf(buf, _("You have been disconnected from chat room %s."), c->name); |
| 248 do_error_dialog(buf, _("Chat Error!")); | |
| 249 } else if (conn->type == AIM_CONN_TYPE_CHATNAV) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
250 if (odata->cnpa > -1) |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
251 gdk_input_remove(odata->cnpa); |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
252 odata->cnpa = -1; |
| 981 | 253 debug_print("removing chatnav input watcher\n"); |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
254 aim_conn_kill(odata->sess, &conn); |
| 981 | 255 } else { |
| 256 sprintf(debug_buff, "holy crap! generic connection error! %d\n", | |
| 257 conn->type); | |
| 258 debug_print(debug_buff); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
259 aim_conn_kill(odata->sess, &conn); |
| 981 | 260 } |
| 261 } | |
| 262 } | |
| 263 } | |
| 264 } | |
| 265 | |
| 266 void oscar_login(struct aim_user *user) { | |
| 267 struct aim_session_t *sess; | |
| 268 struct aim_conn_t *conn; | |
| 269 char buf[256]; | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
270 struct gaim_connection *gc = new_gaim_conn(PROTO_OSCAR, user->username, user->password); |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
271 struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1); |
| 981 | 272 |
| 273 sprintf(debug_buff, _("Logging in %s\n"), user->username); | |
| 274 debug_print(debug_buff); | |
| 275 | |
| 276 sess = g_new0(struct aim_session_t, 1); | |
| 277 aim_session_init(sess); | |
| 278 /* we need an immediate queue because we don't use a while-loop to | |
| 279 * see if things need to be sent. */ | |
| 280 sess->tx_enqueue = &aim_tx_enqueue__immediate; | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
281 odata->sess = sess; |
| 981 | 282 |
| 283 sprintf(buf, _("Looking up %s"), FAIM_LOGIN_SERVER); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
284 set_login_progress(gc, 1, buf); |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
285 /* this creates a possible race condition, but hey, what can you do */ |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
286 while (gtk_events_pending()) |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
287 gtk_main_iteration(); |
| 981 | 288 conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, FAIM_LOGIN_SERVER); |
| 289 | |
| 290 if (conn == NULL) { | |
| 291 debug_print(_("internal connection error\n")); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
292 hide_login_progress(gc, _("Unable to login to AIM")); |
| 981 | 293 destroy_gaim_conn(gc); |
| 294 return; | |
| 295 } else if (conn->fd == -1) { | |
| 296 if (conn->status & AIM_CONN_STATUS_RESOLVERR) { | |
| 297 sprintf(debug_buff, _("couldn't resolve host")); | |
| 298 debug_print(debug_buff); debug_print("\n"); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
299 hide_login_progress(gc, debug_buff); |
| 981 | 300 } else if (conn->status & AIM_CONN_STATUS_CONNERR) { |
| 301 sprintf(debug_buff, _("couldn't connect to host")); | |
| 302 debug_print(debug_buff); debug_print("\n"); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
303 hide_login_progress(gc, debug_buff); |
| 981 | 304 } |
| 305 destroy_gaim_conn(gc); | |
| 306 return; | |
| 307 } | |
| 308 g_snprintf(buf, sizeof(buf), _("Signon: %s"), gc->username); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
309 set_login_progress(gc, 2, buf); |
| 981 | 310 |
| 311 aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0); | |
| 312 aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0); | |
| 313 aim_sendconnack(sess, conn); | |
| 314 aim_request_login(sess, conn, gc->username); | |
| 315 | |
| 316 gc->inpa = gdk_input_add(conn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
| 317 oscar_callback, conn); | |
| 318 | |
| 319 sprintf(gc->user_info, "%s", user->user_info); | |
| 320 gc->options = user->options; | |
| 321 save_prefs(); /* is this necessary anymore? */ | |
| 322 | |
| 323 debug_print(_("Password sent, waiting for response\n")); | |
| 324 } | |
| 325 | |
| 326 void oscar_close(struct gaim_connection *gc) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
327 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
| 981 | 328 if (gc->protocol != PROTO_OSCAR) return; |
| 329 if (gc->inpa > 0) | |
| 330 gdk_input_remove(gc->inpa); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
331 if (odata->cnpa > 0) |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
332 gdk_input_remove(odata->cnpa); |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
333 if (odata->paspa > 0) |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
334 gdk_input_remove(odata->paspa); |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
335 aim_logoff(odata->sess); |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
336 g_free(odata->sess); |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
337 g_free(gc->proto_data); |
| 981 | 338 debug_print(_("Signed off.\n")); |
| 339 } | |
| 340 | |
| 341 int gaim_parse_auth_resp(struct aim_session_t *sess, | |
| 342 struct command_rx_struct *command, ...) { | |
| 343 struct aim_conn_t *bosconn = NULL; | |
| 344 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); | |
| 345 sprintf(debug_buff, "inside auth_resp (Screen name: %s)\n", | |
| 346 sess->logininfo.screen_name); | |
| 347 debug_print(debug_buff); | |
| 348 | |
| 349 if (sess->logininfo.errorcode) { | |
| 350 switch (sess->logininfo.errorcode) { | |
| 351 case 0x18: | |
| 352 /* connecting too frequently */ | |
| 353 do_error_dialog(_("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."), _("Gaim - Error")); | |
|
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
999
diff
changeset
|
354 plugin_event(event_error, (void *)983, 0, 0, 0); |
| 981 | 355 break; |
| 356 case 0x05: | |
| 357 /* Incorrect nick/password */ | |
| 358 do_error_dialog(_("Incorrect nickname or password."), _("Gaim - Error")); | |
|
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
999
diff
changeset
|
359 plugin_event(event_error, (void *)980, 0, 0, 0); |
| 981 | 360 break; |
| 361 case 0x1c: | |
| 362 /* client too old */ | |
| 363 do_error_dialog(_("The client version you are using is too old. Please upgrade at http://www.marko.net/gaim/"), _("Gaim - Error")); | |
|
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
999
diff
changeset
|
364 plugin_event(event_error, (void *)989, 0, 0, 0); |
| 981 | 365 break; |
| 366 } | |
| 367 sprintf(debug_buff, "Login Error Code 0x%04x\n", | |
| 368 sess->logininfo.errorcode); | |
| 369 debug_print(debug_buff); | |
| 370 sprintf(debug_buff, "Error URL: %s\n", | |
| 371 sess->logininfo.errorurl); | |
| 372 debug_print(debug_buff); | |
| 373 #ifdef USE_APPLET | |
| 374 set_user_state(offline); | |
| 375 #endif | |
| 376 gdk_input_remove(gc->inpa); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
377 hide_login_progress(gc, _("Authentication Failed")); |
| 981 | 378 signoff(gc); |
| 379 return 0; | |
| 380 } | |
| 381 | |
| 382 | |
| 383 if (sess->logininfo.email) { | |
| 384 sprintf(debug_buff, "Email: %s\n", sess->logininfo.email); | |
| 385 debug_print(debug_buff); | |
| 386 } else { | |
| 387 debug_print("Email is NULL\n"); | |
| 388 } | |
| 389 sprintf(debug_buff, "Closing auth connection...\n"); | |
| 390 debug_print(debug_buff); | |
| 391 gdk_input_remove(gc->inpa); | |
| 392 aim_conn_kill(sess, &command->conn); | |
| 393 | |
| 394 bosconn = aim_newconn(sess, AIM_CONN_TYPE_BOS, sess->logininfo.BOSIP); | |
| 395 if (bosconn == NULL) { | |
| 396 #ifdef USE_APPLET | |
| 397 set_user_state(offline); | |
| 398 #endif | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
399 hide_login_progress(gc, _("Internal Error")); |
| 981 | 400 destroy_gaim_conn(gc); |
| 401 return -1; | |
| 402 } else if (bosconn->status != 0) { | |
| 403 #ifdef USE_APPLET | |
| 404 set_user_state(offline); | |
| 405 #endif | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
406 hide_login_progress(gc, _("Could Not Connect")); |
| 981 | 407 destroy_gaim_conn(gc); |
| 408 return -1; | |
| 409 } | |
| 410 | |
| 411 aim_conn_addhandler(sess, bosconn, 0x0009, 0x0003, gaim_bosrights, 0); | |
| 412 aim_conn_addhandler(sess, bosconn, 0x0001, 0x0007, gaim_rateresp, 0); /* rate info */ | |
| 413 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_ACK, AIM_CB_ACK_ACK, NULL, 0); | |
| 414 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_SERVERREADY, gaim_server_ready, 0); | |
| 415 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATEINFO, NULL, 0); | |
| 416 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_REDIRECT, gaim_handle_redirect, 0); | |
| 417 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_STS, AIM_CB_STS_SETREPORTINTERVAL, gaim_reportinterval, 0); | |
| 418 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_RIGHTSINFO, gaim_parse_buddyrights, 0); | |
| 419 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING, gaim_parse_oncoming, 0); | |
| 420 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING, gaim_parse_offgoing, 0); | |
| 421 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_INCOMING, gaim_parse_incoming_im, 0); | |
| 422 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_ERROR, gaim_parse_locerr, 0); | |
| 423 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_MISSEDCALL, gaim_parse_misses, 0); | |
| 424 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_RATECHANGE, gaim_parse_ratechange, 0); | |
| 425 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_EVIL, gaim_parse_evilnotify, 0); | |
| 426 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ERROR, gaim_parse_msgerr, 0); | |
| 427 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO, gaim_parse_user_info, 0); | |
| 428 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_MSG, AIM_CB_MSG_ACK, gaim_parse_msgack, 0); | |
| 429 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_CTN, AIM_CB_CTN_DEFAULT, aim_parse_unknown, 0); | |
| 430 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEFAULT, aim_parse_unknown, 0); | |
| 431 aim_conn_addhandler(sess, bosconn, AIM_CB_FAM_GEN, AIM_CB_GEN_MOTD, gaim_parse_motd, 0); | |
| 432 | |
| 433 aim_auth_sendcookie(sess, bosconn, sess->logininfo.cookie); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
434 ((struct oscar_data *)gc->proto_data)->conn = bosconn; |
| 981 | 435 gc->inpa = gdk_input_add(bosconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, |
| 436 oscar_callback, bosconn); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
437 set_login_progress(gc, 4, _("Connection established, cookie sent")); |
| 981 | 438 return 1; |
| 439 } | |
| 440 | |
| 441 int gaim_parse_login(struct aim_session_t *sess, | |
| 442 struct command_rx_struct *command, ...) { | |
| 443 struct client_info_s info = {"AOL Instant Messenger (SM), version 4.1.2010/WIN32", 4, 30, 3141, "us", "en", 0x0004, 0x0001, 0x055}; | |
| 444 char *key; | |
| 445 va_list ap; | |
| 446 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); | |
| 447 | |
| 448 va_start(ap, command); | |
| 449 key = va_arg(ap, char *); | |
| 450 va_end(ap); | |
| 451 | |
| 452 aim_send_login(sess, command->conn, gc->username, gc->password, &info, key); | |
| 453 return 1; | |
| 454 } | |
| 455 | |
| 456 int gaim_server_ready(struct aim_session_t *sess, | |
| 457 struct command_rx_struct *command, ...) { | |
| 458 static int id = 1; | |
| 459 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); | |
| 460 switch (command->conn->type) { | |
| 461 case AIM_CONN_TYPE_BOS: | |
| 462 aim_setversions(sess, command->conn); | |
| 463 aim_bos_reqrate(sess, command->conn); /* request rate info */ | |
| 464 debug_print("done with BOS ServerReady\n"); | |
| 465 break; | |
| 466 case AIM_CONN_TYPE_CHATNAV: | |
| 467 debug_print("chatnav: got server ready\n"); | |
| 468 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); | |
| 469 aim_bos_reqrate(sess, command->conn); | |
| 470 aim_bos_ackrateresp(sess, command->conn); | |
| 471 aim_chatnav_clientready(sess, command->conn); | |
| 472 aim_chatnav_reqrights(sess, command->conn); | |
| 473 break; | |
| 474 case AIM_CONN_TYPE_CHAT: | |
| 475 debug_print("chat: got server ready\n"); | |
| 476 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); | |
| 477 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); | |
| 478 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); | |
| 479 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); | |
| 480 aim_bos_reqrate(sess, command->conn); | |
| 481 aim_bos_ackrateresp(sess, command->conn); | |
| 482 aim_chat_clientready(sess, command->conn); | |
| 483 serv_got_joined_chat(gc, id++, aim_chat_getname(command->conn)); | |
| 484 break; | |
| 485 case AIM_CONN_TYPE_RENDEZVOUS: | |
| 486 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_directim_incoming, 0); | |
| 487 break; | |
| 488 default: /* huh? */ | |
| 489 sprintf(debug_buff, "server ready: got unexpected connection type %04x\n", command->conn->type); | |
| 490 debug_print(debug_buff); | |
| 491 break; | |
| 492 } | |
| 493 return 1; | |
| 494 } | |
| 495 | |
| 496 int gaim_handle_redirect(struct aim_session_t *sess, | |
| 497 struct command_rx_struct *command, ...) { | |
| 498 va_list ap; | |
| 499 int serviceid; | |
| 500 char *ip; | |
| 501 unsigned char *cookie; | |
| 502 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
503 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
| 981 | 504 |
| 505 va_start(ap, command); | |
| 506 serviceid = va_arg(ap, int); | |
| 507 ip = va_arg(ap, char *); | |
| 508 cookie = va_arg(ap, unsigned char *); | |
| 509 | |
| 510 switch(serviceid) { | |
| 511 case 0x7: /* Authorizer */ | |
| 512 debug_print("Reconnecting with authorizor...\n"); | |
| 513 { | |
| 514 struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip); | |
| 515 if (tstconn == NULL || tstconn->status >= AIM_CONN_STATUS_RESOLVERR) | |
| 516 debug_print("unable to reconnect with authorizer\n"); | |
| 517 else { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
518 odata->paspa = gdk_input_add(tstconn->fd, |
| 981 | 519 GDK_INPUT_READ | GDK_INPUT_EXCEPTION, |
| 520 oscar_callback, tstconn); | |
| 521 aim_auth_sendcookie(sess, tstconn, cookie); | |
| 522 } | |
| 523 } | |
| 524 break; | |
| 525 case 0xd: /* ChatNav */ | |
| 526 { | |
| 527 struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, ip); | |
| 528 if (tstconn == NULL || tstconn->status >= AIM_CONN_STATUS_RESOLVERR) { | |
| 529 debug_print("unable to connect to chatnav server\n"); | |
| 530 return 1; | |
| 531 } | |
| 532 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); | |
| 533 aim_auth_sendcookie(sess, tstconn, cookie); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
534 odata->cnpa = gdk_input_add(tstconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, |
| 981 | 535 oscar_callback, tstconn); |
| 536 } | |
| 537 debug_print("chatnav: connected\n"); | |
| 538 break; | |
| 539 case 0xe: /* Chat */ | |
| 540 { | |
| 541 struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip); | |
| 542 char *roomname = va_arg(ap, char *); | |
| 543 struct chat_connection *ccon; | |
| 544 if (tstconn == NULL || tstconn->status >= AIM_CONN_STATUS_RESOLVERR) { | |
| 545 debug_print("unable to connect to chat server\n"); | |
| 546 return 1; | |
| 547 } | |
| 548 sprintf(debug_buff, "Connected to chat room %s\n", roomname); | |
| 549 debug_print(debug_buff); | |
| 550 | |
| 551 ccon = g_new0(struct chat_connection, 1); | |
| 552 ccon->conn = tstconn; | |
| 553 ccon->fd = tstconn->fd; | |
| 554 ccon->name = g_strdup(roomname); | |
| 555 | |
| 556 ccon->inpa = gdk_input_add(tstconn->fd, | |
| 557 GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
| 558 oscar_callback, tstconn); | |
| 559 | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
560 odata->oscar_chats = g_slist_append(odata->oscar_chats, ccon); |
| 981 | 561 |
| 562 aim_chat_attachname(tstconn, roomname); | |
| 563 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); | |
| 564 aim_auth_sendcookie(sess, tstconn, cookie); | |
| 565 } | |
| 566 break; | |
| 567 default: /* huh? */ | |
| 568 sprintf(debug_buff, "got redirect for unknown service 0x%04x\n", | |
| 569 serviceid); | |
| 570 debug_print(debug_buff); | |
| 571 break; | |
| 572 } | |
| 573 | |
| 574 va_end(ap); | |
| 575 | |
| 576 return 1; | |
| 577 } | |
| 578 | |
| 579 int gaim_parse_oncoming(struct aim_session_t *sess, | |
| 580 struct command_rx_struct *command, ...) { | |
| 581 struct aim_userinfo_s *info; | |
| 582 time_t time_idle; | |
| 583 int type = 0; | |
| 584 | |
| 585 va_list ap; | |
| 586 va_start(ap, command); | |
| 587 info = va_arg(ap, struct aim_userinfo_s *); | |
| 588 va_end(ap); | |
| 589 | |
| 590 if (info->flags & AIM_FLAG_UNCONFIRMED) | |
| 591 type |= UC_UNCONFIRMED; | |
| 592 else if (info->flags & AIM_FLAG_ADMINISTRATOR) | |
| 593 type |= UC_ADMIN; | |
| 594 else if (info->flags & AIM_FLAG_AOL) | |
| 595 type |= UC_AOL; | |
| 596 else if (info->flags & AIM_FLAG_FREE) | |
| 597 type |= UC_NORMAL; | |
| 598 if (info->flags & AIM_FLAG_AWAY) | |
| 599 type |= UC_UNAVAILABLE; | |
| 600 | |
| 601 if (info->idletime) { | |
| 602 time(&time_idle); | |
| 603 time_idle -= info->idletime*60; | |
| 604 } else | |
| 605 time_idle = 0; | |
| 606 | |
| 607 serv_got_update(info->sn, 1, info->warnlevel/10, info->onlinesince, | |
| 608 time_idle, type, info->capabilities); | |
| 609 | |
| 610 return 1; | |
| 611 } | |
| 612 | |
| 613 int gaim_parse_offgoing(struct aim_session_t *sess, | |
| 614 struct command_rx_struct *command, ...) { | |
| 615 char *sn; | |
| 616 va_list ap; | |
| 617 | |
| 618 va_start(ap, command); | |
| 619 sn = va_arg(ap, char *); | |
| 620 va_end(ap); | |
| 621 | |
| 622 serv_got_update(sn, 0, 0, 0, 0, 0, 0); | |
| 623 | |
| 624 return 1; | |
| 625 } | |
| 626 | |
| 627 static void accept_directim(GtkWidget *w, GtkWidget *m) | |
| 628 { | |
| 629 struct aim_conn_t *newconn; | |
| 630 struct aim_directim_priv *priv; | |
| 631 struct gaim_connection *gc; | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
632 struct oscar_data *odata; |
| 981 | 633 int watcher; |
| 634 | |
| 635 priv = (struct aim_directim_priv *)gtk_object_get_user_data(GTK_OBJECT(m)); | |
| 636 gc = (struct gaim_connection *)gtk_object_get_user_data(GTK_OBJECT(w)); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
637 odata = (struct oscar_data *)gc->proto_data; |
| 981 | 638 gtk_widget_destroy(m); |
| 639 | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
640 if (!(newconn = aim_directim_connect(odata->sess, odata->conn, priv))) { |
| 981 | 641 debug_print("imimage: could not connect\n"); |
| 642 return; | |
| 643 } | |
| 644 | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
645 aim_conn_addhandler(odata->sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_directim_incoming, 0); |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
646 aim_conn_addhandler(odata->sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_directim_typing, 0); |
| 981 | 647 |
| 648 watcher = gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
| 649 oscar_callback, newconn); | |
| 650 | |
| 651 sprintf(debug_buff, "DirectIM: connected to %s\n", priv->sn); | |
| 652 debug_print(debug_buff); | |
| 653 | |
| 654 serv_got_imimage(gc, priv->sn, priv->cookie, priv->ip, newconn, watcher); | |
| 655 | |
| 656 g_free(priv); | |
| 657 } | |
| 658 | |
| 659 static void cancel_directim(GtkWidget *w, GtkWidget *m) | |
| 660 { | |
| 661 gtk_widget_destroy(m); | |
| 662 } | |
| 663 | |
| 664 static void directim_dialog(struct gaim_connection *gc, struct aim_directim_priv *priv) | |
| 665 { | |
| 666 GtkWidget *window; | |
| 667 GtkWidget *vbox; | |
| 668 GtkWidget *hbox; | |
| 669 GtkWidget *label; | |
| 670 GtkWidget *yes; | |
| 671 GtkWidget *no; | |
| 672 char buf[BUF_LONG]; | |
| 673 | |
| 674 window = gtk_window_new(GTK_WINDOW_DIALOG); | |
| 675 gtk_window_set_title(GTK_WINDOW(window), _("Accept Direct IM?")); | |
| 676 gtk_window_set_wmclass(GTK_WINDOW(window), "directim", "Gaim"); | |
| 677 gtk_widget_realize(window); | |
| 678 aol_icon(window->window); | |
| 679 gtk_object_set_user_data(GTK_OBJECT(window), (void *)priv); | |
| 680 | |
| 681 vbox = gtk_vbox_new(TRUE, 5); | |
| 682 gtk_container_add(GTK_CONTAINER(window), vbox); | |
| 683 gtk_widget_show(vbox); | |
| 684 | |
| 685 sprintf(buf, _("%s has requested to directly connect to your computer. " | |
| 686 "Do you accept?"), priv->sn); | |
| 687 label = gtk_label_new(buf); | |
| 688 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5); | |
| 689 gtk_widget_show(label); | |
| 690 | |
| 691 hbox = gtk_hbox_new(TRUE, 10); | |
| 692 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
| 693 gtk_widget_show(hbox); | |
| 694 | |
| 695 yes = picture_button(window, _("Accept"), ok_xpm); | |
| 696 gtk_box_pack_start(GTK_BOX(hbox), yes, FALSE, FALSE, 5); | |
| 697 gtk_object_set_user_data(GTK_OBJECT(yes), gc); | |
| 698 | |
| 699 no = picture_button(window, _("Cancel"), cancel_xpm); | |
| 700 gtk_box_pack_end(GTK_BOX(hbox), no, FALSE, FALSE, 5); | |
| 701 | |
| 702 gtk_signal_connect(GTK_OBJECT(yes), "clicked", | |
| 703 GTK_SIGNAL_FUNC(accept_directim), window); | |
| 704 gtk_signal_connect(GTK_OBJECT(no), "clicked", | |
| 705 GTK_SIGNAL_FUNC(cancel_directim), window); | |
| 706 | |
| 707 gtk_widget_show(window); | |
| 708 } | |
| 709 | |
| 710 int gaim_parse_incoming_im(struct aim_session_t *sess, | |
| 711 struct command_rx_struct *command, ...) { | |
| 712 int channel; | |
| 713 va_list ap; | |
| 714 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); | |
| 715 | |
| 716 va_start(ap, command); | |
| 717 channel = va_arg(ap, int); | |
| 718 | |
| 719 /* channel 1: standard message */ | |
| 720 if (channel == 1) { | |
| 721 struct aim_userinfo_s *userinfo; | |
| 722 char *msg = NULL; | |
| 723 char *tmp = g_malloc(BUF_LONG); | |
| 724 u_int icbmflags = 0; | |
| 725 u_short flag1, flag2; | |
| 726 | |
| 727 userinfo = va_arg(ap, struct aim_userinfo_s *); | |
| 728 msg = va_arg(ap, char *); | |
| 729 icbmflags = va_arg(ap, u_int); | |
| 730 flag1 = (u_short)va_arg(ap, u_int); | |
| 731 flag2 = (u_short)va_arg(ap, u_int); | |
| 732 va_end(ap); | |
| 733 | |
| 734 g_snprintf(tmp, BUF_LONG, "%s", msg); | |
| 735 serv_got_im(gc, userinfo->sn, tmp, icbmflags & AIM_IMFLAGS_AWAY); | |
| 736 g_free(tmp); | |
| 737 } else if (channel == 2) { | |
| 738 struct aim_userinfo_s *userinfo; | |
| 739 int rendtype = va_arg(ap, int); | |
| 740 if (rendtype & AIM_CAPS_CHAT) { | |
| 741 char *msg, *encoding, *lang; | |
| 742 struct aim_chat_roominfo *roominfo; | |
| 743 | |
| 744 userinfo = va_arg(ap, struct aim_userinfo_s *); | |
| 745 roominfo = va_arg(ap, struct aim_chat_roominfo *); | |
| 746 msg = va_arg(ap, char *); | |
| 747 encoding = va_arg(ap, char *); | |
| 748 lang = va_arg(ap, char *); | |
| 749 va_end(ap); | |
| 750 | |
| 751 serv_got_chat_invite(gc, | |
| 752 roominfo->name, | |
| 753 roominfo->exchange, | |
| 754 userinfo->sn, | |
| 755 msg); | |
| 756 } else if (rendtype & AIM_CAPS_SENDFILE) { | |
| 757 /* libfaim won't tell us that we got this just yet */ | |
| 758 } else if (rendtype & AIM_CAPS_GETFILE) { | |
| 759 /* nor will it tell us this. but it's still there */ | |
| 760 } else if (rendtype & AIM_CAPS_VOICE) { | |
| 761 /* this one libfaim tells us unuseful info about */ | |
| 762 } else if (rendtype & AIM_CAPS_BUDDYICON) { | |
| 763 /* bah */ | |
| 764 } else if (rendtype & AIM_CAPS_IMIMAGE) { | |
| 765 /* DirectIM stuff */ | |
| 766 struct aim_directim_priv *priv, *priv2; | |
| 767 | |
| 768 userinfo = va_arg(ap, struct aim_userinfo_s *); | |
| 769 priv = va_arg(ap, struct aim_directim_priv *); | |
| 770 va_end(ap); | |
| 771 | |
| 772 sprintf(debug_buff, "DirectIM request from %s (%s)\n", userinfo->sn, priv->ip); | |
| 773 debug_print(debug_buff); | |
| 774 | |
| 775 priv2 = g_new0(struct aim_directim_priv, 1); | |
| 776 strcpy(priv2->cookie, priv->cookie); | |
| 777 strcpy(priv2->sn, priv->sn); | |
| 778 strcpy(priv2->ip, priv->ip); | |
| 779 directim_dialog(gc, priv2); | |
| 780 } else { | |
| 781 sprintf(debug_buff, "Unknown rendtype %d\n", rendtype); | |
| 782 debug_print(debug_buff); | |
| 783 } | |
| 784 } | |
| 785 | |
| 786 return 1; | |
| 787 } | |
| 788 | |
| 789 int gaim_parse_misses(struct aim_session_t *sess, | |
| 790 struct command_rx_struct *command, ...) { | |
| 791 va_list ap; | |
| 792 u_short chan, nummissed, reason; | |
| 793 struct aim_userinfo_s *userinfo; | |
| 794 char buf[1024]; | |
| 795 | |
| 796 va_start(ap, command); | |
| 797 chan = (u_short)va_arg(ap, u_int); | |
| 798 userinfo = va_arg(ap, struct aim_userinfo_s *); | |
| 799 nummissed = (u_short)va_arg(ap, u_int); | |
| 800 reason = (u_short)va_arg(ap, u_int); | |
| 801 va_end(ap); | |
| 802 | |
| 803 switch(reason) { | |
| 804 case 1: | |
| 805 /* message too large */ | |
| 806 sprintf(buf, _("You missed a message from %s because it was too large."), userinfo->sn); | |
| 807 do_error_dialog(buf, _("Gaim - Error")); | |
|
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
999
diff
changeset
|
808 plugin_event(event_error, (void *)961, 0, 0, 0); |
| 981 | 809 break; |
| 810 default: | |
| 811 sprintf(buf, _("You missed a message from %s for unknown reasons."), userinfo->sn); | |
| 812 do_error_dialog(buf, _("Gaim - Error")); | |
|
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
999
diff
changeset
|
813 plugin_event(event_error, (void *)970, 0, 0, 0); |
| 981 | 814 break; |
| 815 } | |
| 816 | |
| 817 return 1; | |
| 818 } | |
| 819 | |
| 820 int gaim_parse_msgerr(struct aim_session_t *sess, | |
| 821 struct command_rx_struct *command, ...) { | |
| 822 va_list ap; | |
| 823 char *destn; | |
| 824 u_short reason; | |
| 825 char buf[1024]; | |
| 826 | |
| 827 va_start(ap, command); | |
| 828 destn = va_arg(ap, char *); | |
| 829 reason = (u_short)va_arg(ap, u_int); | |
| 830 va_end(ap); | |
| 831 | |
| 832 sprintf(buf, _("Your message to %s did not get sent: %s"), destn, | |
| 833 (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown")); | |
| 834 do_error_dialog(buf, _("Gaim - Error")); | |
| 835 | |
| 836 return 1; | |
| 837 } | |
| 838 | |
| 839 int gaim_parse_locerr(struct aim_session_t *sess, | |
| 840 struct command_rx_struct *command, ...) { | |
| 841 va_list ap; | |
| 842 char *destn; | |
| 843 u_short reason; | |
| 844 char buf[1024]; | |
| 845 | |
| 846 va_start(ap, command); | |
| 847 destn = va_arg(ap, char *); | |
| 848 reason = (u_short)va_arg(ap, u_int); | |
| 849 va_end(ap); | |
| 850 | |
| 851 sprintf(buf, _("User information for %s unavailable: %s"), destn, | |
| 852 (reason < msgerrreasonlen) ? msgerrreason[reason] : _("Reason unknown")); | |
| 853 do_error_dialog(buf, _("Gaim - Error")); | |
| 854 | |
| 855 return 1; | |
| 856 } | |
| 857 | |
| 858 int gaim_parse_user_info(struct aim_session_t *sess, | |
| 859 struct command_rx_struct *command, ...) { | |
| 860 struct aim_userinfo_s *info; | |
| 861 char *prof_enc = NULL, *prof = NULL; | |
| 862 u_short infotype; | |
| 863 char buf[BUF_LONG]; | |
| 864 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); | |
| 865 va_list ap; | |
| 866 | |
| 867 va_start(ap, command); | |
| 868 info = va_arg(ap, struct aim_userinfo_s *); | |
| 869 prof_enc = va_arg(ap, char *); | |
| 870 prof = va_arg(ap, char *); | |
| 871 infotype = (u_short)va_arg(ap, u_int); | |
| 872 va_end(ap); | |
| 873 | |
| 874 if (prof == NULL || !strlen(prof)) { | |
| 875 /* no info/away message */ | |
| 876 char buf[1024]; | |
| 877 sprintf(buf, _("%s has no info/away message."), info->sn); | |
| 878 do_error_dialog(buf, _("Gaim - Error")); | |
|
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
999
diff
changeset
|
879 plugin_event(event_error, (void *)977, 0, 0, 0); |
| 981 | 880 return 1; |
| 881 } | |
| 882 | |
| 883 snprintf(buf, sizeof buf, _("Username : <B>%s</B>\n<BR>" | |
| 884 "Warning Level : <B>%d %%</B>\n<BR>" | |
| 885 "Online Since : <B>%s</B><BR>" | |
| 886 "Idle Minutes : <B>%d</B>\n<BR><HR><BR>" | |
| 887 "%s\n"), | |
| 888 info->sn, | |
| 889 info->warnlevel/10, | |
| 890 asctime(localtime(&info->onlinesince)), | |
| 891 info->idletime, | |
| 892 infotype == AIM_GETINFO_GENERALINFO ? prof : | |
| 893 away_subs(prof, gc->username)); | |
| 894 g_show_info_text(away_subs(buf, gc->username)); | |
| 895 | |
| 896 return 1; | |
| 897 } | |
| 898 | |
| 899 int gaim_parse_motd(struct aim_session_t *sess, | |
| 900 struct command_rx_struct *command, ...) { | |
| 901 char *msg; | |
| 902 u_short id; | |
| 903 va_list ap; | |
| 904 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); | |
| 905 | |
| 906 va_start(ap, command); | |
| 907 id = (u_short)va_arg(ap, u_int); | |
| 908 msg = va_arg(ap, char *); | |
| 909 va_end(ap); | |
| 910 | |
| 911 sprintf(debug_buff, "MOTD: %s (%d)\n", msg, id); | |
| 912 debug_print(debug_buff); | |
| 913 sprintf(debug_buff, "Gaim %s / Libfaim %s\n", | |
| 914 VERSION, aim_getbuildstring()); | |
| 915 debug_print(debug_buff); | |
| 916 if (id != 4) | |
| 917 do_error_dialog(_("Your connection may be lost."), | |
| 918 _("AOL error")); | |
| 919 | |
| 920 if (gc->keepalive < 0) | |
| 921 update_keepalive(gc, gc->keepalive); | |
| 922 | |
| 923 return 1; | |
| 924 } | |
| 925 | |
| 926 int gaim_chatnav_info(struct aim_session_t *sess, | |
| 927 struct command_rx_struct *command, ...) { | |
| 928 va_list ap; | |
| 929 u_short type; | |
| 930 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
931 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
| 981 | 932 |
| 933 va_start(ap, command); | |
| 934 type = (u_short)va_arg(ap, u_int); | |
| 935 | |
| 936 switch(type) { | |
| 937 case 0x0002: { | |
| 938 int maxrooms; | |
| 939 struct aim_chat_exchangeinfo *exchanges; | |
| 940 int exchangecount, i = 0; | |
| 941 | |
| 942 maxrooms = (u_char)va_arg(ap, u_int); | |
| 943 exchangecount = va_arg(ap, int); | |
| 944 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
| 945 va_end(ap); | |
| 946 | |
| 947 debug_print("chat info: Chat Rights:\n"); | |
| 948 sprintf(debug_buff, "chat info: \tMax Concurrent Rooms: %d\n", maxrooms); | |
| 949 debug_print(debug_buff); | |
| 950 sprintf(debug_buff, "chat info: \tExchange List: (%d total)\n", exchangecount); | |
| 951 debug_print(debug_buff); | |
| 952 while (i < exchangecount) { | |
| 953 sprintf(debug_buff, "chat info: \t\t%x: %s (%s/%s)\n", | |
| 954 exchanges[i].number, | |
| 955 exchanges[i].name, | |
| 956 exchanges[i].charset1, | |
| 957 exchanges[i].lang1); | |
| 958 debug_print(debug_buff); | |
| 959 i++; | |
| 960 } | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
961 if (odata->create_exchange) { |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
962 sprintf(debug_buff, "creating room %s\n", odata->create_name); |
| 981 | 963 debug_print(debug_buff); |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
964 aim_chatnav_createroom(sess, command->conn, odata->create_name, |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
965 odata->create_exchange); |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
966 odata->create_exchange = 0; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
967 g_free(odata->create_name); |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
968 odata->create_name = NULL; |
| 981 | 969 } |
| 970 } | |
| 971 break; | |
| 972 case 0x0008: { | |
| 973 char *fqcn, *name, *ck; | |
| 974 u_short instance, flags, maxmsglen, maxoccupancy, unknown; | |
| 975 unsigned char createperms; | |
| 976 unsigned long createtime; | |
| 977 | |
| 978 fqcn = va_arg(ap, char *); | |
| 979 instance = (u_short)va_arg(ap, u_int); | |
| 980 flags = (u_short)va_arg(ap, u_int); | |
| 981 createtime = va_arg(ap, unsigned long); | |
| 982 maxmsglen = (u_short)va_arg(ap, u_int); | |
| 983 maxoccupancy = (u_short)va_arg(ap, u_int); | |
| 984 createperms = (unsigned char)va_arg(ap, int); | |
| 985 unknown = (u_short)va_arg(ap, u_int); | |
| 986 name = va_arg(ap, char *); | |
| 987 ck = va_arg(ap, char *); | |
| 988 va_end(ap); | |
| 989 | |
| 990 sprintf(debug_buff, "created room: %s %d %d %lu %d %d %d %d %s %s\n", fqcn, instance, flags, createtime, maxmsglen, maxoccupancy, createperms, unknown, name, ck); | |
| 991 debug_print(debug_buff); | |
| 992 if (flags & 0x4) { | |
| 993 sprintf(debug_buff, "joining %s on exchange 5\n", name); | |
| 994 debug_print(debug_buff); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
995 aim_chat_join(odata->sess, odata->conn, 5, ck); |
| 981 | 996 } else |
| 997 sprintf(debug_buff, "joining %s on exchange 4\n", name);{ | |
| 998 debug_print(debug_buff); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
999 aim_chat_join(odata->sess, odata->conn, 4, ck); |
| 981 | 1000 } |
| 1001 } | |
| 1002 break; | |
| 1003 default: | |
| 1004 va_end(ap); | |
| 1005 sprintf(debug_buff, "chatnav info: unknown type (%04x)\n", type); | |
| 1006 debug_print(debug_buff); | |
| 1007 break; | |
| 1008 } | |
| 1009 return 1; | |
| 1010 } | |
| 1011 | |
| 1012 int gaim_chat_join(struct aim_session_t *sess, | |
| 1013 struct command_rx_struct *command, ...) { | |
| 1014 va_list ap; | |
| 1015 int count, i = 0; | |
| 1016 struct aim_userinfo_s *info; | |
| 1017 struct gaim_connection *g = find_gaim_conn_by_aim_sess(sess); | |
| 1018 | |
| 1019 GSList *bcs = g->buddy_chats; | |
| 1020 struct conversation *b = NULL; | |
| 1021 | |
| 1022 va_start(ap, command); | |
| 1023 count = va_arg(ap, int); | |
| 1024 info = va_arg(ap, struct aim_userinfo_s *); | |
| 1025 va_end(ap); | |
| 1026 | |
| 1027 while(bcs) { | |
| 1028 b = (struct conversation *)bcs->data; | |
| 1029 if (!strcasecmp(b->name, (char *)command->conn->priv)) | |
| 1030 break; | |
| 1031 bcs = bcs->next; | |
| 1032 b = NULL; | |
| 1033 } | |
| 1034 if (!b) | |
| 1035 return 1; | |
| 1036 | |
| 1037 while (i < count) | |
| 1038 add_chat_buddy(b, info[i++].sn); | |
| 1039 | |
| 1040 return 1; | |
| 1041 } | |
| 1042 | |
| 1043 int gaim_chat_leave(struct aim_session_t *sess, | |
| 1044 struct command_rx_struct *command, ...) { | |
| 1045 va_list ap; | |
| 1046 int count, i = 0; | |
| 1047 struct aim_userinfo_s *info; | |
| 1048 struct gaim_connection *g = find_gaim_conn_by_aim_sess(sess); | |
| 1049 | |
| 1050 GSList *bcs = g->buddy_chats; | |
| 1051 struct conversation *b = NULL; | |
| 1052 | |
| 1053 va_start(ap, command); | |
| 1054 count = va_arg(ap, int); | |
| 1055 info = va_arg(ap, struct aim_userinfo_s *); | |
| 1056 va_end(ap); | |
| 1057 | |
| 1058 while(bcs) { | |
| 1059 b = (struct conversation *)bcs->data; | |
| 1060 if (!strcasecmp(b->name, (char *)command->conn->priv)) | |
| 1061 break; | |
| 1062 bcs = bcs->next; | |
| 1063 b = NULL; | |
| 1064 } | |
| 1065 if (!b) | |
| 1066 return 1; | |
| 1067 | |
| 1068 while (i < count) | |
| 1069 remove_chat_buddy(b, info[i++].sn); | |
| 1070 | |
| 1071 return 1; | |
| 1072 } | |
| 1073 | |
| 1074 int gaim_chat_info_update(struct aim_session_t *sess, | |
| 1075 struct command_rx_struct *command, ...) { | |
| 1076 debug_print("inside chat_info_update\n"); | |
| 1077 return 1; | |
| 1078 } | |
| 1079 | |
| 1080 int gaim_chat_incoming_msg(struct aim_session_t *sess, | |
| 1081 struct command_rx_struct *command, ...) { | |
| 1082 va_list ap; | |
| 1083 struct aim_userinfo_s *info; | |
| 1084 char *msg; | |
| 1085 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); | |
| 1086 | |
| 1087 GSList *bcs = gc->buddy_chats; | |
| 1088 struct conversation *b = NULL; | |
| 1089 | |
| 1090 va_start(ap, command); | |
| 1091 info = va_arg(ap, struct aim_userinfo_s *); | |
| 1092 msg = va_arg(ap, char *); | |
| 1093 | |
| 1094 while(bcs) { | |
| 1095 b = (struct conversation *)bcs->data; | |
| 1096 if (!strcasecmp(b->name, (char *)command->conn->priv)) | |
| 1097 break; | |
| 1098 bcs = bcs->next; | |
| 1099 b = NULL; | |
| 1100 } | |
| 1101 if (!b) | |
| 1102 return 0; | |
| 1103 | |
| 1104 serv_got_chat_in(gc, b->id, info->sn, 0, msg); | |
| 1105 | |
| 1106 return 1; | |
| 1107 } | |
| 1108 | |
| 1109 /* | |
| 1110 * Recieved in response to an IM sent with the AIM_IMFLAGS_ACK option. | |
| 1111 */ | |
| 1112 int gaim_parse_msgack(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
| 1113 va_list ap; | |
| 1114 u_short type; | |
| 1115 char *sn = NULL; | |
| 1116 | |
| 1117 va_start(ap, command); | |
| 1118 type = (u_short)va_arg(ap, u_int); | |
| 1119 sn = va_arg(ap, char *); | |
| 1120 va_end(ap); | |
| 1121 | |
| 1122 sprintf(debug_buff, "Sent message to %s.\n", sn); | |
| 1123 debug_print(debug_buff); | |
| 1124 | |
| 1125 return 1; | |
| 1126 } | |
| 1127 | |
| 1128 int gaim_parse_ratechange(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
| 1129 va_list ap; | |
| 1130 unsigned long newrate; | |
| 1131 | |
| 1132 va_start(ap, command); | |
| 1133 newrate = va_arg(ap, unsigned long); | |
| 1134 va_end(ap); | |
| 1135 | |
| 1136 sprintf(debug_buff, "ratechange: %lu\n", newrate); | |
| 1137 debug_print(debug_buff); | |
| 1138 | |
| 1139 return 1; | |
| 1140 } | |
| 1141 | |
| 1142 int gaim_parse_evilnotify(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
| 1143 va_list ap; | |
| 1144 char *sn; | |
| 1145 | |
| 1146 va_start(ap, command); | |
| 1147 sn = va_arg(ap, char *); | |
| 1148 va_end(ap); | |
| 1149 | |
| 1150 serv_got_eviled(sn, 0); | |
| 1151 | |
| 1152 return 1; | |
| 1153 } | |
| 1154 | |
| 1155 int gaim_rateresp(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
| 1156 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); | |
| 1157 switch (command->conn->type) { | |
| 1158 case AIM_CONN_TYPE_BOS: | |
| 1159 aim_bos_ackrateresp(sess, command->conn); | |
| 1160 aim_bos_reqpersonalinfo(sess, command->conn); | |
| 1161 aim_bos_reqlocaterights(sess, command->conn); | |
| 1162 aim_bos_setprofile(sess, command->conn, gc->user_info, NULL, gaim_caps); | |
| 1163 aim_bos_reqbuddyrights(sess, command->conn); | |
| 1164 | |
| 1165 if (mainwindow) | |
| 1166 gtk_widget_hide(mainwindow); | |
| 1167 show_buddy_list(); | |
| 1168 | |
| 1169 #ifdef USE_APPLET | |
| 1170 if (general_options & OPT_GEN_APP_BUDDY_SHOW) { | |
| 1171 refresh_buddy_window(); | |
| 1172 createOnlinePopup(); | |
| 1173 applet_buddy_show = TRUE; | |
| 1174 } else { | |
| 1175 gtk_widget_hide(blist); | |
| 1176 applet_buddy_show = FALSE; | |
| 1177 } | |
| 1178 set_user_state(online); | |
| 1179 #else | |
| 1180 refresh_buddy_window(); | |
| 1181 #endif | |
| 1182 | |
| 1183 serv_finish_login(gc); | |
| 1184 gaim_setup(gc); | |
| 1185 | |
| 1186 if (bud_list_cache_exists(gc)) | |
| 1187 do_import(NULL, gc); | |
| 1188 | |
| 1189 debug_print("buddy list loaded\n"); | |
| 1190 | |
| 1191 setup_buddy_chats(); | |
| 1192 | |
| 1193 aim_addicbmparam(sess, command->conn); | |
| 1194 aim_bos_reqicbmparaminfo(sess, command->conn); | |
| 1195 | |
| 1196 aim_bos_reqrights(sess, command->conn); | |
| 1197 aim_bos_setgroupperm(sess, command->conn, AIM_FLAG_ALLUSERS); | |
| 1198 aim_bos_setprivacyflags(sess, command->conn, AIM_PRIVFLAGS_ALLOWIDLE | | |
| 1199 AIM_PRIVFLAGS_ALLOWMEMBERSINCE); | |
| 1200 | |
| 1201 break; | |
| 1202 default: | |
| 1203 sprintf(debug_buff, "got rate response for unhandled connection type %04x\n", | |
| 1204 command->conn->type); | |
| 1205 debug_print(debug_buff); | |
| 1206 break; | |
| 1207 } | |
| 1208 | |
| 1209 return 1; | |
| 1210 } | |
| 1211 | |
| 1212 int gaim_reportinterval(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
| 1213 if (command->data) { | |
| 1214 sprintf(debug_buff, "minimum report interval: %d (seconds?)\n", aimutil_get16(command->data+10)); | |
| 1215 debug_print(debug_buff); | |
| 1216 } else | |
| 1217 debug_print("NULL minimum report interval!\n"); | |
| 1218 return 1; | |
| 1219 } | |
| 1220 | |
| 1221 int gaim_parse_buddyrights(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
| 1222 va_list ap; | |
| 1223 u_short maxbuddies, maxwatchers; | |
| 1224 | |
| 1225 va_start(ap, command); | |
| 1226 maxbuddies = (u_short)va_arg(ap, u_int); | |
| 1227 maxwatchers = (u_short)va_arg(ap, u_int); | |
| 1228 va_end(ap); | |
| 1229 | |
| 1230 sprintf(debug_buff, "buddy list rights: Max buddies = %d / Max watchers = %d\n", maxbuddies, maxwatchers); | |
| 1231 debug_print(debug_buff); | |
| 1232 | |
| 1233 return 1; | |
| 1234 } | |
| 1235 | |
| 1236 int gaim_bosrights(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
| 1237 u_short maxpermits, maxdenies; | |
| 1238 va_list ap; | |
| 1239 | |
| 1240 va_start(ap, command); | |
| 1241 maxpermits = (u_short)va_arg(ap, u_int); | |
| 1242 maxdenies = (u_short)va_arg(ap, u_int); | |
| 1243 va_end(ap); | |
| 1244 | |
| 1245 sprintf(debug_buff, "BOS rights: Max permit = %d / Max deny = %d\n", maxpermits, maxdenies); | |
| 1246 debug_print(debug_buff); | |
| 1247 | |
| 1248 aim_bos_clientready(sess, command->conn); | |
| 1249 | |
| 1250 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV); | |
| 1251 | |
| 1252 return 1; | |
| 1253 } | |
| 1254 | |
| 1255 int gaim_directim_incoming(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
| 1256 va_list ap; | |
| 1257 char *sn = NULL, *msg = NULL; | |
| 1258 struct aim_conn_t *conn; | |
| 1259 struct gaim_connection *gc = find_gaim_conn_by_aim_sess(sess); | |
| 1260 | |
| 1261 va_start(ap, command); | |
| 1262 conn = va_arg(ap, struct aim_conn_t *); | |
| 1263 sn = va_arg(ap, char *); | |
| 1264 msg = va_arg(ap, char *); | |
| 1265 va_end(ap); | |
| 1266 | |
| 1267 sprintf(debug_buff, "Got DirectIM message from %s\n", sn); | |
| 1268 debug_print(debug_buff); | |
| 1269 | |
| 1270 serv_got_im(gc, sn, msg, 0); | |
| 1271 | |
| 1272 return 1; | |
| 1273 } | |
| 1274 | |
| 1275 /* this is such a f*cked up function */ | |
| 1276 int gaim_directim_initiate(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
| 1277 va_list ap; | |
| 1278 struct aim_directim_priv *priv; | |
| 1279 struct aim_conn_t *newconn; | |
| 1280 struct conversation *cnv; | |
| 1281 int watcher; | |
| 1282 | |
| 1283 va_start(ap, command); | |
| 1284 newconn = va_arg(ap, struct aim_conn_t *); | |
| 1285 va_end(ap); | |
| 1286 | |
| 1287 priv = (struct aim_directim_priv *)newconn->priv; | |
| 1288 | |
| 1289 sprintf(debug_buff, "DirectIM: initiate success to %s\n", priv->sn); | |
| 1290 debug_print(debug_buff); | |
| 1291 | |
| 1292 cnv = find_conversation(priv->sn); | |
| 1293 gdk_input_remove(cnv->watcher); | |
| 1294 watcher = gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, | |
| 1295 oscar_callback, newconn); | |
| 1296 make_direct(cnv, TRUE, newconn, watcher); | |
| 1297 | |
| 1298 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING, gaim_directim_incoming, 0); | |
| 1299 aim_conn_addhandler(sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMTYPING, gaim_directim_typing, 0); | |
| 1300 | |
| 1301 return 1; | |
| 1302 } | |
| 1303 | |
| 1304 int gaim_directim_typing(struct aim_session_t *sess, struct command_rx_struct *command, ...) { | |
| 1305 va_list ap; | |
| 1306 char *sn; | |
| 1307 | |
| 1308 va_start(ap, command); | |
| 1309 sn = va_arg(ap, char *); | |
| 1310 va_end(ap); | |
| 1311 | |
| 1312 /* I had to leave this. It's just too funny. It reminds me of my sister. */ | |
| 1313 sprintf(debug_buff, "ohmigod! %s has started typing (DirectIM). He's going to send you a message! *squeal*\n", sn); | |
| 1314 debug_print(debug_buff); | |
| 1315 | |
| 1316 return 1; | |
| 1317 } | |
| 1318 | |
| 1319 void oscar_do_directim(struct gaim_connection *gc, char *name) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1320 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1321 struct aim_conn_t *newconn = aim_directim_initiate(odata->sess, odata->conn, NULL, name); |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1322 struct conversation *cnv = find_conversation(name); /* this will never be null because |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1323 it just got set up */ |
| 981 | 1324 cnv->conn = newconn; |
| 1325 cnv->watcher = gdk_input_add(newconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, oscar_callback, newconn); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1326 aim_conn_addhandler(odata->sess, newconn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINITIATE, gaim_directim_initiate, 0); |
| 981 | 1327 } |
| 1328 | |
| 1329 static void oscar_keepalive(struct gaim_connection *gc) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1330 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1331 aim_flap_nop(odata->sess, odata->conn); |
| 981 | 1332 } |
| 1333 | |
| 1334 static char *oscar_name() { | |
| 1335 return "Oscar"; | |
| 1336 } | |
| 1337 | |
| 1338 static void oscar_send_im(struct gaim_connection *gc, char *name, char *message, int away) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1339 struct oscar_data *odata = (struct oscar_data *)gc->proto_data; |
| 981 | 1340 struct conversation *cnv = find_conversation(name); |
| 1341 if (cnv && cnv->is_direct) { | |
| 1342 debug_printf("Sending DirectIM to %s\n", name); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1343 aim_send_im_direct(odata->sess, cnv->conn, message); |
| 981 | 1344 } else { |
| 1345 if (away) | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1346 aim_send_im(odata->sess, odata->conn, name, AIM_IMFLAGS_AWAY, message); |
| 981 | 1347 else |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1348 aim_send_im(odata->sess, odata->conn, name, AIM_IMFLAGS_ACK, message); |
| 981 | 1349 } |
| 1350 } | |
| 1351 | |
| 1352 static void oscar_get_info(struct gaim_connection *g, char *name) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1353 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1354 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_GENERALINFO); |
| 981 | 1355 } |
| 1356 | |
| 1357 static void oscar_get_away_msg(struct gaim_connection *g, char *name) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1358 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1359 aim_getinfo(odata->sess, odata->conn, name, AIM_GETINFO_AWAYMESSAGE); |
| 981 | 1360 } |
| 1361 | |
| 1362 static void oscar_set_dir(struct gaim_connection *g, char *first, char *middle, char *last, | |
| 1363 char *maiden, char *city, char *state, char *country, int web) { | |
| 1364 /* FIXME : some of these things are wrong, but i'm lazy */ | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1365 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1366 aim_setdirectoryinfo(odata->sess, odata->conn, first, middle, last, |
| 981 | 1367 maiden, NULL, NULL, city, state, NULL, 0, web); |
| 1368 } | |
| 1369 | |
| 1370 | |
| 1371 static void oscar_set_idle(struct gaim_connection *g, int time) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1372 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1373 aim_bos_setidle(odata->sess, odata->conn, time); |
| 981 | 1374 } |
| 1375 | |
| 1376 static void oscar_set_info(struct gaim_connection *g, char *info) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1377 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
| 981 | 1378 if (awaymessage) |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1379 aim_bos_setprofile(odata->sess, odata->conn, info, |
| 981 | 1380 awaymessage->message, gaim_caps); |
| 1381 else | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1382 aim_bos_setprofile(odata->sess, odata->conn, info, |
| 981 | 1383 NULL, gaim_caps); |
| 1384 } | |
| 1385 | |
| 1386 static void oscar_set_away(struct gaim_connection *g, char *message) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1387 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1388 aim_bos_setprofile(odata->sess, odata->conn, g->user_info, message, gaim_caps); |
| 981 | 1389 } |
| 1390 | |
| 1391 static void oscar_warn(struct gaim_connection *g, char *name, int anon) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1392 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1393 aim_send_warning(odata->sess, odata->conn, name, anon); |
| 981 | 1394 } |
| 1395 | |
| 1396 static void oscar_dir_search(struct gaim_connection *g, char *first, char *middle, char *last, | |
| 1397 char *maiden, char *city, char *state, char *country, char *email) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1398 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
| 981 | 1399 if (strlen(email)) |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1400 aim_usersearch_address(odata->sess, odata->conn, email); |
| 981 | 1401 } |
| 1402 | |
| 1403 static void oscar_add_buddy(struct gaim_connection *g, char *name) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1404 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1405 aim_add_buddy(odata->sess, odata->conn, name); |
| 981 | 1406 } |
| 1407 | |
| 1408 static void oscar_add_buddies(struct gaim_connection *g, GList *buddies) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1409 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
| 981 | 1410 char buf[MSG_LEN]; |
| 1411 int n = 0; | |
| 1412 while (buddies) { | |
| 1413 if (n > MSG_LEN - 18) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1414 aim_bos_setbuddylist(odata->sess, odata->conn, buf); |
| 981 | 1415 n = 0; |
| 1416 } | |
| 1417 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", (char *)buddies->data); | |
| 1418 buddies = buddies->next; | |
| 1419 } | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1420 aim_bos_setbuddylist(odata->sess, odata->conn, buf); |
| 981 | 1421 } |
| 1422 | |
| 1423 static void oscar_remove_buddy(struct gaim_connection *g, char *name) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1424 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1425 aim_remove_buddy(odata->sess, odata->conn, name); |
| 981 | 1426 } |
| 1427 | |
| 1428 static void oscar_join_chat(struct gaim_connection *g, int exchange, char *name) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1429 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
| 981 | 1430 struct aim_conn_t *cur = NULL; |
| 1431 sprintf(debug_buff, "Attempting to join chat room %s.\n", name); | |
| 1432 debug_print(debug_buff); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1433 if ((cur = aim_getconn_type(odata->sess, AIM_CONN_TYPE_CHATNAV))) { |
| 981 | 1434 debug_print("chatnav exists, creating room\n"); |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1435 aim_chatnav_createroom(odata->sess, cur, name, exchange); |
| 981 | 1436 } else { |
| 1437 /* this gets tricky */ | |
| 1438 debug_print("chatnav does not exist, opening chatnav\n"); | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1439 odata->create_exchange = exchange; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1440 odata->create_name = g_strdup(name); |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1441 aim_bos_reqservice(odata->sess, odata->conn, AIM_CONN_TYPE_CHATNAV); |
| 981 | 1442 } |
| 1443 } | |
| 1444 | |
| 1445 static void oscar_chat_invite(struct gaim_connection *g, int id, char *message, char *name) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1446 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
| 981 | 1447 GSList *bcs = g->buddy_chats; |
| 1448 struct conversation *b = NULL; | |
| 1449 | |
| 1450 while (bcs) { | |
| 1451 b = (struct conversation *)bcs->data; | |
| 1452 if (id == b->id) | |
| 1453 break; | |
| 1454 bcs = bcs->next; | |
| 1455 b = NULL; | |
| 1456 } | |
| 1457 | |
| 1458 if (!b) | |
| 1459 return; | |
| 1460 | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1461 aim_chat_invite(odata->sess, odata->conn, name, |
| 981 | 1462 message ? message : "", 0x4, b->name, 0x0); |
| 1463 } | |
| 1464 | |
| 1465 static void oscar_chat_leave(struct gaim_connection *g, int id) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1466 struct oscar_data *odata = g ? (struct oscar_data *)g->proto_data : NULL; |
| 981 | 1467 GSList *bcs = g->buddy_chats; |
| 1468 struct conversation *b = NULL; | |
| 1469 struct chat_connection *c = NULL; | |
| 1470 int count = 0; | |
| 1471 | |
| 1472 while (bcs) { | |
| 1473 count++; | |
| 1474 b = (struct conversation *)bcs->data; | |
| 1475 if (id == b->id) | |
| 1476 break; | |
| 1477 bcs = bcs->next; | |
| 1478 b = NULL; | |
| 1479 } | |
| 1480 | |
| 1481 if (!b) | |
| 1482 return; | |
| 1483 | |
| 1484 sprintf(debug_buff, "Attempting to leave room %s (currently in %d rooms)\n", | |
| 1485 b->name, count); | |
| 1486 debug_print(debug_buff); | |
| 1487 | |
| 1488 c = find_oscar_chat(g, b->name); | |
| 1489 if (c != NULL) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1490 if (odata) |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1491 odata->oscar_chats = g_slist_remove(odata->oscar_chats, c); |
| 981 | 1492 gdk_input_remove(c->inpa); |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1493 if (g && odata->sess) |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1494 aim_conn_kill(odata->sess, &c->conn); |
| 981 | 1495 g_free(c->name); |
| 1496 g_free(c); | |
| 1497 } | |
| 1498 /* we do this because with Oscar it doesn't tell us we left */ | |
| 1499 serv_got_chat_left(g, b->id); | |
| 1500 } | |
| 1501 | |
| 1502 static void oscar_chat_whisper(struct gaim_connection *g, int id, char *who, char *message) { | |
| 1503 do_error_dialog("Sorry, Oscar doesn't whisper. Send an IM. (The last message was not received.)", | |
| 1504 "Gaim - Chat"); | |
| 1505 } | |
| 1506 | |
| 1507 static void oscar_chat_send(struct gaim_connection *g, int id, char *message) { | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1508 struct oscar_data *odata = (struct oscar_data *)g->proto_data; |
| 981 | 1509 struct aim_conn_t *cn; |
| 1510 GSList *bcs = g->buddy_chats; | |
| 1511 struct conversation *b = NULL; | |
| 1512 | |
| 1513 while (bcs) { | |
| 1514 b = (struct conversation *)bcs->data; | |
| 1515 if (id == b->id) | |
| 1516 break; | |
| 1517 bcs = bcs->next; | |
| 1518 b = NULL; | |
| 1519 } | |
| 1520 if (!b) | |
| 1521 return; | |
| 1522 | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1523 cn = aim_chat_getconn(odata->sess, b->name); |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1524 aim_chat_send_im(odata->sess, cn, message); |
| 981 | 1525 } |
| 1526 | |
|
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
999
diff
changeset
|
1527 void oscar_init(struct prpl *ret) { |
| 981 | 1528 ret->protocol = PROTO_OSCAR; |
| 1529 ret->name = oscar_name; | |
| 1530 ret->login = oscar_login; | |
| 1531 ret->close = oscar_close; | |
| 1532 ret->send_im = oscar_send_im; | |
| 1533 ret->set_info = oscar_set_info; | |
| 1534 ret->get_info = oscar_get_info; | |
| 1535 ret->set_away = oscar_set_away; | |
| 1536 ret->get_away_msg = oscar_get_away_msg; | |
| 1537 ret->set_dir = oscar_set_dir; | |
| 1538 ret->get_dir = NULL; /* Oscar really doesn't have this */ | |
| 1539 ret->dir_search = oscar_dir_search; | |
| 1540 ret->set_idle = oscar_set_idle; | |
| 1541 ret->change_passwd = NULL; /* Oscar doesn't have this either */ | |
| 1542 ret->add_buddy = oscar_add_buddy; | |
| 1543 ret->add_buddies = oscar_add_buddies; | |
| 1544 ret->remove_buddy = oscar_remove_buddy; | |
| 1545 ret->add_permit = NULL; /* Oscar's permit/deny stuff is messed up */ | |
| 1546 ret->add_deny = NULL; /* at least, i can't figure it out :-P */ | |
| 1547 ret->warn = oscar_warn; | |
| 1548 ret->accept_chat = NULL; /* oscar doesn't have accept, it just joins */ | |
| 1549 ret->join_chat = oscar_join_chat; | |
| 1550 ret->chat_invite = oscar_chat_invite; | |
| 1551 ret->chat_leave = oscar_chat_leave; | |
| 1552 ret->chat_whisper = oscar_chat_whisper; | |
| 1553 ret->chat_send = oscar_chat_send; | |
| 1554 ret->keepalive = oscar_keepalive; | |
| 1555 } | |
| 1556 | |
|
999
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1557 char *name() { |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1558 return "Oscar"; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1559 } |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1560 |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1561 char *description() { |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1562 return "Allows gaim to use the Oscar protocol"; |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1563 } |
|
0b5db8cdd30f
[gaim-migrate @ 1009]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
981
diff
changeset
|
1564 |
| 981 | 1565 int gaim_plugin_init(void *handle) { |
|
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
999
diff
changeset
|
1566 load_protocol(oscar_init); |
| 981 | 1567 return 0; |
| 1568 } |
