Mercurial > pidgin
comparison src/server.c @ 981:7e231bc0018a
[gaim-migrate @ 991]
I think I need a Pepsi.
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Fri, 13 Oct 2000 07:24:40 +0000 |
| parents | 82c5865f7cfe |
| children | ca8f1d02630a |
comparison
equal
deleted
inserted
replaced
| 980:82c5865f7cfe | 981:7e231bc0018a |
|---|---|
| 30 #include <sys/time.h> | 30 #include <sys/time.h> |
| 31 #include <unistd.h> | 31 #include <unistd.h> |
| 32 #include <gtk/gtk.h> | 32 #include <gtk/gtk.h> |
| 33 #include <aim.h> | 33 #include <aim.h> |
| 34 extern int gaim_caps; | 34 extern int gaim_caps; |
| 35 #include "prpl.h" | |
| 35 #include "multi.h" | 36 #include "multi.h" |
| 36 #include "gaim.h" | 37 #include "gaim.h" |
| 37 | 38 |
| 38 #include "pixmaps/ok.xpm" | 39 #include "pixmaps/ok.xpm" |
| 39 #include "pixmaps/cancel.xpm" | 40 #include "pixmaps/cancel.xpm" |
| 40 | 41 |
| 41 int correction_time = 0; | 42 int correction_time = 0; |
| 42 | 43 |
| 43 void serv_login(struct aim_user *user) | 44 void serv_login(struct aim_user *user) |
| 44 { | 45 { |
| 45 if (user->protocol == PROTO_TOC) { | 46 struct prpl *p = find_prpl(user->protocol); |
| 46 toc_login(user); | 47 if (p && p->login) { |
| 47 } else if (user->protocol == PROTO_OSCAR) { | 48 debug_printf("Logging in using %s\n", (*p->name)()); |
| 48 debug_print("Logging in using Oscar. Expect problems.\n"); | 49 (*p->login)(user); |
| 49 oscar_login(user); | |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 void serv_close(struct gaim_connection *gc) | 53 void serv_close(struct gaim_connection *gc) |
| 54 { | 54 { |
| 55 if (gc->protocol == PROTO_TOC) | 55 if (gc->prpl && gc->prpl->close) |
| 56 toc_close(gc); | 56 (*gc->prpl->close)(gc); |
| 57 else if (gc->protocol == PROTO_OSCAR) | |
| 58 oscar_close(gc); | |
| 59 | 57 |
| 60 account_offline(gc); | 58 account_offline(gc); |
| 61 destroy_gaim_conn(gc); | 59 destroy_gaim_conn(gc); |
| 62 | 60 |
| 63 if (connections) return; | 61 if (connections) return; |
| 131 | 129 |
| 132 | 130 |
| 133 | 131 |
| 134 void serv_send_im(struct gaim_connection *gc, char *name, char *message, int away) | 132 void serv_send_im(struct gaim_connection *gc, char *name, char *message, int away) |
| 135 { | 133 { |
| 136 struct conversation *cnv = find_conversation(name); | 134 if (gc->prpl && gc->prpl->send_im) |
| 137 if (cnv && cnv->is_direct && (gc->protocol == PROTO_OSCAR)) { | 135 (*gc->prpl->send_im)(gc, name, message, away); |
| 138 debug_printf("Sending DirectIM to %s\n", name); | 136 |
| 139 aim_send_im_direct(gc->oscar_sess, cnv->conn, message); | |
| 140 } else { | |
| 141 if (gc->protocol == PROTO_TOC) { | |
| 142 char buf[MSG_LEN - 7]; | |
| 143 | |
| 144 escape_text(message); | |
| 145 g_snprintf(buf, MSG_LEN - 8, "toc_send_im %s \"%s\"%s", normalize(name), | |
| 146 message, ((away) ? " auto" : "")); | |
| 147 sflap_send(gc, buf, -1, TYPE_DATA); | |
| 148 } else if (gc->protocol == PROTO_OSCAR) { | |
| 149 if (away) | |
| 150 aim_send_im(gc->oscar_sess, gc->oscar_conn, | |
| 151 name, AIM_IMFLAGS_AWAY, message); | |
| 152 else | |
| 153 aim_send_im(gc->oscar_sess, gc->oscar_conn, | |
| 154 name, AIM_IMFLAGS_ACK, message); | |
| 155 } | |
| 156 } | |
| 157 if (!away) | 137 if (!away) |
| 158 serv_touch_idle(gc); | 138 serv_touch_idle(gc); |
| 159 } | 139 } |
| 160 | 140 |
| 161 void serv_get_info(char *name) | 141 void serv_get_info(char *name) |
| 162 { | 142 { |
| 163 /* FIXME: getting someone's info? how do you decide something like that? I think that | 143 /* FIXME: getting someone's info? how do you decide something like that? I think that |
| 164 * the buddy list/UI needs to be really changed before this gets fixed*/ | 144 * the buddy list/UI needs to be really changed before this gets fixed*/ |
| 165 struct gaim_connection *g = connections->data; | 145 struct gaim_connection *g = connections->data; |
| 166 if (g->protocol == PROTO_TOC) { | 146 |
| 167 char buf[MSG_LEN]; | 147 if (g->prpl && g->prpl->get_info) |
| 168 g_snprintf(buf, MSG_LEN, "toc_get_info %s", normalize(name)); | 148 (*g->prpl->get_info)(g, name); |
| 169 sflap_send(g, buf, -1, TYPE_DATA); | |
| 170 } else if (g->protocol == PROTO_OSCAR) { | |
| 171 aim_getinfo(g->oscar_sess, g->oscar_conn, name, AIM_GETINFO_GENERALINFO); | |
| 172 } | |
| 173 } | 149 } |
| 174 | 150 |
| 175 void serv_get_away_msg(char *name) | 151 void serv_get_away_msg(char *name) |
| 176 { | 152 { |
| 177 /* FIXME: see the serv_get_info comment above :-P */ | 153 /* FIXME: see the serv_get_info comment above :-P */ |
| 178 struct gaim_connection *g = connections->data; | 154 struct gaim_connection *g = connections->data; |
| 179 if (g->protocol == PROTO_TOC) { | 155 |
| 180 /* HAHA! TOC doesn't have this yet */ | 156 if (g->prpl && g->prpl->get_info) |
| 181 } else if (g->protocol == PROTO_OSCAR) { | 157 (*g->prpl->get_info)(g, name); |
| 182 aim_getinfo(g->oscar_sess, g->oscar_conn, name, AIM_GETINFO_AWAYMESSAGE); | |
| 183 } | |
| 184 } | 158 } |
| 185 | 159 |
| 186 void serv_get_dir(char *name) | 160 void serv_get_dir(char *name) |
| 187 { | 161 { |
| 188 /* FIXME: see the serv_get_info comment above :-P */ | 162 /* FIXME: see the serv_get_info comment above :-P */ |
| 189 struct gaim_connection *g = connections->data; | 163 struct gaim_connection *g = connections->data; |
| 190 if (g->protocol == PROTO_TOC) { | 164 |
| 191 char buf[MSG_LEN]; | 165 if (g->prpl && g->prpl->get_dir) |
| 192 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", normalize(name)); | 166 (*g->prpl->get_dir)(g, name); |
| 193 sflap_send(g, buf, -1, TYPE_DATA); | |
| 194 } | |
| 195 } | 167 } |
| 196 | 168 |
| 197 void serv_set_dir(char *first, char *middle, char *last, char *maiden, | 169 void serv_set_dir(char *first, char *middle, char *last, char *maiden, |
| 198 char *city, char *state, char *country, int web) | 170 char *city, char *state, char *country, int web) |
| 199 { | 171 { |
| 200 /* FIXME */ | 172 /* FIXME */ |
| 201 struct gaim_connection *g = connections->data; | 173 struct gaim_connection *g = connections->data; |
| 202 if (g->protocol == PROTO_TOC) { | 174 |
| 203 char buf2[BUF_LEN*4], buf[BUF_LEN]; | 175 if (g->prpl && g->prpl->set_dir) |
| 204 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, | 176 (*g->prpl->set_dir)(g, first, middle, last, maiden, city, state, country, web); |
| 205 middle, last, maiden, city, state, country, | |
| 206 (web == 1) ? "Y" : ""); | |
| 207 escape_text(buf2); | |
| 208 g_snprintf(buf, sizeof(buf), "toc_set_dir %s", buf2); | |
| 209 sflap_send(g, buf, -1, TYPE_DATA); | |
| 210 } else if (g->protocol == PROTO_OSCAR) { | |
| 211 /* FIXME : some of these things are wrong, but i'm lazy */ | |
| 212 aim_setdirectoryinfo(g->oscar_sess, g->oscar_conn, first, middle, last, | |
| 213 maiden, NULL, NULL, city, state, NULL, 0, web); | |
| 214 } | |
| 215 } | 177 } |
| 216 | 178 |
| 217 void serv_dir_search(char *first, char *middle, char *last, char *maiden, | 179 void serv_dir_search(char *first, char *middle, char *last, char *maiden, |
| 218 char *city, char *state, char *country, char *email) | 180 char *city, char *state, char *country, char *email) |
| 219 { | 181 { |
| 220 /* FIXME */ | 182 /* FIXME */ |
| 221 struct gaim_connection *g = connections->data; | 183 struct gaim_connection *g = connections->data; |
| 222 if (g->protocol == PROTO_TOC) { | 184 |
| 223 char buf[BUF_LONG]; | 185 if (g->prpl && g->prpl->dir_search) |
| 224 g_snprintf(buf, sizeof(buf)/2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, last, maiden, city, state, country, email); | 186 (*g->prpl->dir_search)(g, first, middle, last, maiden, city, state, country, email); |
| 225 sprintf(debug_buff,"Searching for: %s,%s,%s,%s,%s,%s,%s\n", first, middle, last, maiden, city, state, country); | |
| 226 debug_print(debug_buff); | |
| 227 sflap_send(g, buf, -1, TYPE_DATA); | |
| 228 } else if (g->protocol == PROTO_OSCAR) { | |
| 229 if (strlen(email)) | |
| 230 aim_usersearch_address(g->oscar_sess, g->oscar_conn, email); | |
| 231 } | |
| 232 } | 187 } |
| 233 | 188 |
| 234 | 189 |
| 235 void serv_set_away(char *message) | 190 void serv_set_away(char *message) |
| 236 { | 191 { |
| 238 GSList *c = connections; | 193 GSList *c = connections; |
| 239 struct gaim_connection *g; | 194 struct gaim_connection *g; |
| 240 | 195 |
| 241 while (c) { | 196 while (c) { |
| 242 g = (struct gaim_connection *)c->data; | 197 g = (struct gaim_connection *)c->data; |
| 243 if (g->protocol == PROTO_TOC) { | 198 if (g->prpl && g->prpl->set_away) |
| 244 char buf[MSG_LEN]; | 199 (*g->prpl->set_away)(g, message); |
| 245 if (message) { | |
| 246 escape_text(message); | |
| 247 g_snprintf(buf, MSG_LEN, "toc_set_away \"%s\"", message); | |
| 248 } else | |
| 249 g_snprintf(buf, MSG_LEN, "toc_set_away \"\""); | |
| 250 sflap_send(g, buf, -1, TYPE_DATA); | |
| 251 } else if (g->protocol == PROTO_OSCAR) { | |
| 252 aim_bos_setprofile(g->oscar_sess, g->oscar_conn, g->user_info, message, gaim_caps); | |
| 253 } | |
| 254 c = c->next; | 200 c = c->next; |
| 255 } | 201 } |
| 256 } | 202 } |
| 257 | 203 |
| 258 void serv_set_info(struct gaim_connection *g, char *info) | 204 void serv_set_info(struct gaim_connection *g, char *info) |
| 259 { | 205 { |
| 260 if (g->protocol == PROTO_TOC) { | 206 if (g->prpl && g->prpl->set_info) |
| 261 char buf[MSG_LEN]; | 207 (*g->prpl->set_info)(g, info); |
| 262 escape_text(info); | |
| 263 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", info); | |
| 264 sflap_send(g, buf, -1, TYPE_DATA); | |
| 265 } else if (g->protocol == PROTO_OSCAR) { | |
| 266 if (awaymessage) | |
| 267 aim_bos_setprofile(g->oscar_sess, g->oscar_conn, info, | |
| 268 awaymessage->message, gaim_caps); | |
| 269 else | |
| 270 aim_bos_setprofile(g->oscar_sess, g->oscar_conn, info, | |
| 271 NULL, gaim_caps); | |
| 272 } | |
| 273 } | 208 } |
| 274 | 209 |
| 275 void serv_change_passwd(struct gaim_connection *g, char *orig, char *new) { | 210 void serv_change_passwd(struct gaim_connection *g, char *orig, char *new) { |
| 276 if (g->protocol == PROTO_TOC) { | 211 if (g->prpl && g->prpl->change_passwd) |
| 277 char *buf = g_malloc(BUF_LONG); | 212 (*g->prpl->change_passwd)(g, orig, new); |
| 278 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); | |
| 279 sflap_send(g, buf, strlen(buf), TYPE_DATA); | |
| 280 g_free(buf); | |
| 281 } else if (g->protocol == PROTO_OSCAR) { | |
| 282 /* Oscar change_passwd FIXME */ | |
| 283 } | |
| 284 } | 213 } |
| 285 | 214 |
| 286 void serv_add_buddy(char *name) | 215 void serv_add_buddy(char *name) |
| 287 { | 216 { |
| 288 /* FIXME: this will need to be changed. for now all buddies will be added to | 217 /* FIXME: this will need to be changed. for now all buddies will be added to |
| 290 GSList *c = connections; | 219 GSList *c = connections; |
| 291 struct gaim_connection *g; | 220 struct gaim_connection *g; |
| 292 | 221 |
| 293 while (c) { | 222 while (c) { |
| 294 g = (struct gaim_connection *)c->data; | 223 g = (struct gaim_connection *)c->data; |
| 295 if (g->protocol == PROTO_TOC) { | 224 if (g->prpl && g->prpl->add_buddy) |
| 296 char buf[1024]; | 225 (*g->prpl->add_buddy)(g, name); |
| 297 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name)); | |
| 298 sflap_send(g, buf, -1, TYPE_DATA); | |
| 299 } else if (g->protocol == PROTO_OSCAR) { | |
| 300 aim_add_buddy(g->oscar_sess, g->oscar_conn, name); | |
| 301 } | |
| 302 c = c->next; | 226 c = c->next; |
| 303 } | 227 } |
| 304 } | 228 } |
| 305 | 229 |
| 306 void serv_add_buddies(GList *buddies) | 230 void serv_add_buddies(GList *buddies) |
| 309 GSList *c = connections; | 233 GSList *c = connections; |
| 310 struct gaim_connection *g; | 234 struct gaim_connection *g; |
| 311 | 235 |
| 312 while (c) { | 236 while (c) { |
| 313 g = (struct gaim_connection *)c->data; | 237 g = (struct gaim_connection *)c->data; |
| 314 if (g->protocol == PROTO_TOC) { | 238 if (g->prpl && g->prpl->add_buddies) |
| 315 char buf[MSG_LEN]; | 239 (*g->prpl->add_buddies)(g, buddies); |
| 316 int n, num = 0; | |
| 317 | |
| 318 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | |
| 319 while(buddies) { | |
| 320 /* i don't know why we choose 8, it just seems good */ | |
| 321 if (strlen(normalize(buddies->data)) > MSG_LEN - n - 8) { | |
| 322 sflap_send(g, buf, -1, TYPE_DATA); | |
| 323 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | |
| 324 num = 0; | |
| 325 } | |
| 326 ++num; | |
| 327 n += g_snprintf(buf + n, sizeof(buf)-n, " %s", normalize(buddies->data)); | |
| 328 buddies = buddies->next; | |
| 329 } | |
| 330 sflap_send(g, buf, -1, TYPE_DATA); | |
| 331 } else if (g->protocol == PROTO_OSCAR) { | |
| 332 char buf[MSG_LEN]; | |
| 333 int n = 0; | |
| 334 while(buddies) { | |
| 335 if (n > MSG_LEN - 18) { | |
| 336 aim_bos_setbuddylist(g->oscar_sess, g->oscar_conn, buf); | |
| 337 n = 0; | |
| 338 } | |
| 339 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", | |
| 340 (char *)buddies->data); | |
| 341 buddies = buddies->next; | |
| 342 } | |
| 343 aim_bos_setbuddylist(g->oscar_sess, g->oscar_conn, buf); | |
| 344 } | |
| 345 c = c->next; | 240 c = c->next; |
| 346 } | 241 } |
| 347 } | 242 } |
| 348 | 243 |
| 349 | 244 |
| 353 GSList *c = connections; | 248 GSList *c = connections; |
| 354 struct gaim_connection *g; | 249 struct gaim_connection *g; |
| 355 | 250 |
| 356 while (c) { | 251 while (c) { |
| 357 g = (struct gaim_connection *)c->data; | 252 g = (struct gaim_connection *)c->data; |
| 358 if (g->protocol == PROTO_TOC) { | 253 if (g->prpl && g->prpl->remove_buddy) |
| 359 char buf[1024]; | 254 (*g->prpl->remove_buddy)(g, name); |
| 360 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name)); | |
| 361 sflap_send(g, buf, -1, TYPE_DATA); | |
| 362 } else if (g->protocol == PROTO_OSCAR) { | |
| 363 aim_remove_buddy(g->oscar_sess, g->oscar_conn, name); | |
| 364 } | |
| 365 c = c->next; | 255 c = c->next; |
| 366 } | 256 } |
| 367 } | 257 } |
| 368 | 258 |
| 369 void serv_add_permit(char *name) | 259 void serv_add_permit(char *name) |
| 479 } | 369 } |
| 480 } | 370 } |
| 481 | 371 |
| 482 void serv_set_idle(struct gaim_connection *g, int time) | 372 void serv_set_idle(struct gaim_connection *g, int time) |
| 483 { | 373 { |
| 484 if (g->protocol == PROTO_TOC) { | 374 if (g->prpl && g->prpl->set_idle) |
| 485 char buf[256]; | 375 (*g->prpl->set_idle)(g, time); |
| 486 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); | |
| 487 sflap_send(g, buf, -1, TYPE_DATA); | |
| 488 } else if (g->protocol == PROTO_OSCAR) { | |
| 489 aim_bos_setidle(g->oscar_sess, g->oscar_conn, time); | |
| 490 } | |
| 491 } | 376 } |
| 492 | 377 |
| 493 | 378 |
| 494 void serv_warn(struct gaim_connection *g, char *name, int anon) | 379 void serv_warn(struct gaim_connection *g, char *name, int anon) |
| 495 { | 380 { |
| 496 if (g->protocol == PROTO_TOC) { | 381 if (g->prpl && g->prpl->warn) |
| 497 char *send = g_malloc(256); | 382 (*g->prpl->warn)(g, name, anon); |
| 498 g_snprintf(send, 255, "toc_evil %s %s", name, | |
| 499 ((anon) ? "anon" : "norm")); | |
| 500 sflap_send(g, send, -1, TYPE_DATA); | |
| 501 g_free(send); | |
| 502 } else if (g->protocol == PROTO_OSCAR) { | |
| 503 aim_send_warning(g->oscar_sess, g->oscar_conn, name, anon); | |
| 504 } | |
| 505 } | 383 } |
| 506 | 384 |
| 507 void serv_build_config(char *buf, int len, gboolean show) { | 385 void serv_build_config(char *buf, int len, gboolean show) { |
| 508 toc_build_config(buf, len, show); | 386 toc_build_config(buf, len, show); |
| 509 } | 387 } |
| 525 } | 403 } |
| 526 | 404 |
| 527 | 405 |
| 528 void serv_accept_chat(struct gaim_connection *g, int i) | 406 void serv_accept_chat(struct gaim_connection *g, int i) |
| 529 { | 407 { |
| 530 if (g->protocol == PROTO_TOC) { | 408 if (g->prpl && g->prpl->accept_chat) |
| 531 char *buf = g_malloc(256); | 409 (*g->prpl->accept_chat)(g, i); |
| 532 g_snprintf(buf, 255, "toc_chat_accept %d", i); | |
| 533 sflap_send(g, buf, -1, TYPE_DATA); | |
| 534 g_free(buf); | |
| 535 } else if (g->protocol == PROTO_OSCAR) { | |
| 536 /* this should never get called because libfaim doesn't use the id | |
| 537 * (i'm not even sure Oscar does). go through serv_join_chat instead */ | |
| 538 } | |
| 539 } | 410 } |
| 540 | 411 |
| 541 void serv_join_chat(struct gaim_connection *g, int exchange, char *name) | 412 void serv_join_chat(struct gaim_connection *g, int exchange, char *name) |
| 542 { | 413 { |
| 543 if (g->protocol == PROTO_TOC) { | 414 if (g->prpl && g->prpl->join_chat) |
| 544 char buf[BUF_LONG]; | 415 (*g->prpl->join_chat)(g, exchange, name); |
| 545 g_snprintf(buf, sizeof(buf)/2, "toc_chat_join %d \"%s\"", exchange, name); | |
| 546 sflap_send(g, buf, -1, TYPE_DATA); | |
| 547 } else if (g->protocol == PROTO_OSCAR) { | |
| 548 struct aim_conn_t *cur = NULL; | |
| 549 sprintf(debug_buff, "Attempting to join chat room %s.\n", name); | |
| 550 debug_print(debug_buff); | |
| 551 if ((cur = aim_getconn_type(g->oscar_sess, AIM_CONN_TYPE_CHATNAV))) { | |
| 552 debug_print("chatnav exists, creating room\n"); | |
| 553 aim_chatnav_createroom(g->oscar_sess, cur, name, exchange); | |
| 554 } else { | |
| 555 /* this gets tricky */ | |
| 556 debug_print("chatnav does not exist, opening chatnav\n"); | |
| 557 g->create_exchange = exchange; | |
| 558 g->create_name = g_strdup(name); | |
| 559 aim_bos_reqservice(g->oscar_sess, g->oscar_conn, AIM_CONN_TYPE_CHATNAV); | |
| 560 } | |
| 561 } | |
| 562 } | 416 } |
| 563 | 417 |
| 564 void serv_chat_invite(struct gaim_connection *g, int id, char *message, char *name) | 418 void serv_chat_invite(struct gaim_connection *g, int id, char *message, char *name) |
| 565 { | 419 { |
| 566 if (g->protocol == PROTO_TOC) { | 420 if (g->prpl && g->prpl->chat_invite) |
| 567 char buf[BUF_LONG]; | 421 (*g->prpl->chat_invite)(g, id, message, name); |
| 568 g_snprintf(buf, sizeof(buf)/2, "toc_chat_invite %d \"%s\" %s", id, message, normalize(name)); | |
| 569 sflap_send(g, buf, -1, TYPE_DATA); | |
| 570 } else if (g->protocol == PROTO_OSCAR) { | |
| 571 GSList *bcs = g->buddy_chats; | |
| 572 struct conversation *b = NULL; | |
| 573 | |
| 574 while (bcs) { | |
| 575 b = (struct conversation *)bcs->data; | |
| 576 if (id == b->id) | |
| 577 break; | |
| 578 bcs = bcs->next; | |
| 579 b = NULL; | |
| 580 } | |
| 581 | |
| 582 if (!b) | |
| 583 return; | |
| 584 | |
| 585 aim_chat_invite(g->oscar_sess, g->oscar_conn, name, | |
| 586 message ? message : "", 0x4, b->name, 0x0); | |
| 587 } | |
| 588 } | 422 } |
| 589 | 423 |
| 590 void serv_chat_leave(struct gaim_connection *g, int id) | 424 void serv_chat_leave(struct gaim_connection *g, int id) |
| 591 { | 425 { |
| 592 if (g->protocol == PROTO_TOC) { | 426 if (g->prpl && g->prpl->chat_leave) |
| 593 char *buf = g_malloc(256); | 427 (*g->prpl->chat_leave)(g, id); |
| 594 g_snprintf(buf, 255, "toc_chat_leave %d", id); | |
| 595 sflap_send(g, buf, -1, TYPE_DATA); | |
| 596 g_free(buf); | |
| 597 } else if (g->protocol == PROTO_OSCAR) { | |
| 598 GSList *bcs = g->buddy_chats; | |
| 599 struct conversation *b = NULL; | |
| 600 struct chat_connection *c = NULL; | |
| 601 int count = 0; | |
| 602 | |
| 603 while (bcs) { | |
| 604 count++; | |
| 605 b = (struct conversation *)bcs->data; | |
| 606 if (id == b->id) | |
| 607 break; | |
| 608 bcs = bcs->next; | |
| 609 b = NULL; | |
| 610 } | |
| 611 | |
| 612 if (!b) | |
| 613 return; | |
| 614 | |
| 615 sprintf(debug_buff, "Attempting to leave room %s (currently in %d rooms)\n", | |
| 616 b->name, count); | |
| 617 debug_print(debug_buff); | |
| 618 | |
| 619 c = find_oscar_chat(g, b->name); | |
| 620 if (c != NULL) { | |
| 621 g->oscar_chats = g_slist_remove(g->oscar_chats, c); | |
| 622 gdk_input_remove(c->inpa); | |
| 623 if (g && g->oscar_sess) | |
| 624 aim_conn_kill(g->oscar_sess, &c->conn); | |
| 625 g_free(c->name); | |
| 626 g_free(c); | |
| 627 } | |
| 628 /* we do this because with Oscar it doesn't tell us we left */ | |
| 629 serv_got_chat_left(g, b->id); | |
| 630 } | |
| 631 } | 428 } |
| 632 | 429 |
| 633 void serv_chat_whisper(struct gaim_connection *g, int id, char *who, char *message) | 430 void serv_chat_whisper(struct gaim_connection *g, int id, char *who, char *message) |
| 634 { | 431 { |
| 635 if (g->protocol == PROTO_TOC) { | 432 if (g->prpl && g->prpl->chat_whisper) |
| 636 char buf2[MSG_LEN]; | 433 (*g->prpl->chat_whisper)(g, id, who, message); |
| 637 g_snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, who, message); | |
| 638 sflap_send(g, buf2, -1, TYPE_DATA); | |
| 639 } else if (g->protocol == PROTO_OSCAR) { | |
| 640 do_error_dialog("Sorry, Oscar doesn't whisper. Send an IM. (The last message was not received.)", | |
| 641 "Gaim - Chat"); | |
| 642 } | |
| 643 } | 434 } |
| 644 | 435 |
| 645 void serv_chat_send(struct gaim_connection *g, int id, char *message) | 436 void serv_chat_send(struct gaim_connection *g, int id, char *message) |
| 646 { | 437 { |
| 647 if (g->protocol == PROTO_TOC) { | 438 if (g->prpl && g->prpl->chat_send) |
| 648 char buf[MSG_LEN]; | 439 (*g->prpl->chat_send)(g, id, message); |
| 649 escape_text(message); | |
| 650 g_snprintf(buf, sizeof(buf), "toc_chat_send %d \"%s\"",id, message); | |
| 651 sflap_send(g, buf, -1, TYPE_DATA); | |
| 652 } else if (g->protocol == PROTO_OSCAR) { | |
| 653 struct aim_conn_t *cn; | |
| 654 GSList *bcs = g->buddy_chats; | |
| 655 struct conversation *b = NULL; | |
| 656 | |
| 657 while (bcs) { | |
| 658 b = (struct conversation *)bcs->data; | |
| 659 if (id == b->id) | |
| 660 break; | |
| 661 bcs = bcs->next; | |
| 662 b = NULL; | |
| 663 } | |
| 664 if (!b) | |
| 665 return; | |
| 666 | |
| 667 cn = aim_chat_getconn(g->oscar_sess, b->name); | |
| 668 aim_chat_send_im(g->oscar_sess, cn, message); | |
| 669 } | |
| 670 serv_touch_idle(g); | 440 serv_touch_idle(g); |
| 671 } | 441 } |
| 672 | 442 |
| 673 | 443 |
| 674 | 444 |
| 756 is_idle = -1; | 526 is_idle = -1; |
| 757 | 527 |
| 758 /* apply default fonts and colors */ | 528 /* apply default fonts and colors */ |
| 759 tmpmsg = stylize(awaymessage->message, MSG_LEN); | 529 tmpmsg = stylize(awaymessage->message, MSG_LEN); |
| 760 | 530 |
| 531 /* PRPL */ | |
| 761 if (gc->protocol == PROTO_TOC) { | 532 if (gc->protocol == PROTO_TOC) { |
| 762 escape_text(tmpmsg); | 533 escape_text(tmpmsg); |
| 763 escape_message(tmpmsg); | 534 escape_message(tmpmsg); |
| 764 } | 535 } |
| 765 serv_send_im(gc, name, away_subs(tmpmsg, alias), 1); | 536 serv_send_im(gc, name, away_subs(tmpmsg, alias), 1); |
| 1086 if (!cnv) cnv = new_conversation(name); | 857 if (!cnv) cnv = new_conversation(name); |
| 1087 | 858 |
| 1088 if (cnv->gc->protocol == PROTO_TOC) { | 859 if (cnv->gc->protocol == PROTO_TOC) { |
| 1089 /* Direct IM TOC FIXME */ | 860 /* Direct IM TOC FIXME */ |
| 1090 } else if (cnv->gc->protocol == PROTO_OSCAR) { | 861 } else if (cnv->gc->protocol == PROTO_OSCAR) { |
| 862 /* PRPL | |
| 1091 oscar_do_directim(cnv->gc, name); | 863 oscar_do_directim(cnv->gc, name); |
| 864 */ | |
| 1092 } | 865 } |
| 1093 } | 866 } |
| 1094 | 867 |
| 1095 void serv_got_imimage(struct gaim_connection *gc, char *name, char *cookie, char *ip, | 868 void serv_got_imimage(struct gaim_connection *gc, char *name, char *cookie, char *ip, |
| 1096 struct aim_conn_t *conn, int watcher) | 869 struct aim_conn_t *conn, int watcher) |
| 1101 struct conversation *cnv = find_conversation(name); | 874 struct conversation *cnv = find_conversation(name); |
| 1102 if (!cnv) cnv = new_conversation(name); | 875 if (!cnv) cnv = new_conversation(name); |
| 1103 make_direct(cnv, TRUE, conn, watcher); | 876 make_direct(cnv, TRUE, conn, watcher); |
| 1104 } | 877 } |
| 1105 } | 878 } |
| 879 | |
| 880 void send_keepalive(gpointer d) { | |
| 881 struct gaim_connection *gc = (struct gaim_connection *)d; | |
| 882 debug_print("sending oscar NOP\n"); | |
| 883 if (gc->prpl && gc->prpl->keepalive) | |
| 884 (*gc->prpl->keepalive)(gc); | |
| 885 } | |
| 886 | |
| 887 void update_keepalive(struct gaim_connection *gc, gboolean on) { | |
| 888 if (on && gc->keepalive < 0 && blist) { | |
| 889 debug_print("allowing NOP\n"); | |
| 890 gc->keepalive = gtk_timeout_add(60000, (GtkFunction)send_keepalive, gc); | |
| 891 } else if (!on && gc->keepalive > -1) { | |
| 892 debug_print("removing NOP\n"); | |
| 893 gtk_timeout_remove(gc->keepalive); | |
| 894 gc->keepalive = -1; | |
| 895 } | |
| 896 } |
