| 307 if (g->prpl && g->prpl->chat_send) |
307 if (g->prpl && g->prpl->chat_send) |
| 308 (*g->prpl->chat_send)(g, id, message); |
308 (*g->prpl->chat_send)(g, id, message); |
| 309 serv_touch_idle(g); |
309 serv_touch_idle(g); |
| 310 } |
310 } |
| 311 |
311 |
| |
312 int find_queue_row_by_name(char *name) |
| |
313 { |
| |
314 GSList *templist; |
| |
315 char *temp; |
| |
316 int i; |
| |
317 |
| |
318 templist = message_queue; |
| |
319 |
| |
320 for (i = 0; i < GTK_CLIST(clistqueue)->rows; i++) |
| |
321 { |
| |
322 gtk_clist_get_text(GTK_CLIST(clistqueue), i, 0, &temp); |
| |
323 |
| |
324 if (!strcmp(name, temp)) |
| |
325 return i; |
| |
326 } |
| |
327 |
| |
328 return -1; |
| |
329 } |
| |
330 |
| |
331 int find_queue_total_by_name(char *name) |
| |
332 { |
| |
333 GSList *templist; |
| |
334 int i = 0; |
| |
335 |
| |
336 templist = message_queue; |
| |
337 |
| |
338 while (templist) |
| |
339 { |
| |
340 struct queued_message *qm = (struct queued_message *)templist->data; |
| |
341 if (!strcmp(name, qm->name)) |
| |
342 i++; |
| |
343 |
| |
344 templist = templist->next; |
| |
345 } |
| |
346 |
| |
347 return i; |
| |
348 } |
| |
349 |
| 312 void serv_got_im(struct gaim_connection *gc, char *name, char *message, int away, time_t mtime) |
350 void serv_got_im(struct gaim_connection *gc, char *name, char *message, int away, time_t mtime) |
| 313 { |
351 { |
| 314 struct conversation *cnv; |
352 struct conversation *cnv; |
| 315 int new_conv = 0; |
353 int new_conv = 0; |
| 316 int hehe = away; |
354 int hehe = away; |
| 352 |
390 |
| 353 if (away) |
391 if (away) |
| 354 away = WFLAG_AUTO; |
392 away = WFLAG_AUTO; |
| 355 |
393 |
| 356 if (gc->away) { |
394 if (gc->away) { |
| 357 if (!(general_options & OPT_GEN_DISCARD_WHEN_AWAY)) { |
395 if (general_options & OPT_GEN_QUEUE_WHEN_AWAY) |
| 358 if (cnv == NULL) { |
396 { |
| 359 new_conv = 1; |
|
| 360 cnv = new_conversation(name); |
|
| 361 cnv->gc = gc; |
|
| 362 gtk_option_menu_set_history(GTK_OPTION_MENU(cnv->menu), |
|
| 363 g_slist_index(connections, gc)); |
|
| 364 update_buttons_by_protocol(cnv); |
|
| 365 } |
|
| 366 } else { |
|
| 367 return; |
|
| 368 } |
|
| 369 if (cnv != NULL) { |
|
| 370 struct queued_message *qm; |
397 struct queued_message *qm; |
| 371 if (cnv->makesound && (sound_options & OPT_SOUND_RECV)) |
398 int row; |
| 372 play_sound(RECEIVE); |
399 |
| 373 /* |
|
| 374 qm = (struct queued_message *)g_new0(struct queued_message, 1); |
400 qm = (struct queued_message *)g_new0(struct queued_message, 1); |
| 375 snprintf(qm->name, sizeof(qm->name), "%s", name); |
401 snprintf(qm->name, sizeof(qm->name), "%s", name); |
| 376 qm->message = strdup(message); |
402 qm->message = strdup(message); |
| 377 qm->gc = gc; |
403 qm->gc = gc; |
| 378 qm->tm = mtime; |
404 qm->tm = mtime; |
| 379 |
405 |
| |
406 row = find_queue_row_by_name(qm->name); |
| |
407 |
| |
408 if (row >= 0) |
| |
409 { |
| |
410 char number[32]; |
| |
411 int qtotal; |
| |
412 |
| |
413 qtotal = find_queue_total_by_name(qm->name); |
| |
414 |
| |
415 snprintf(number, 32, _("(%d messages)"), ++qtotal); |
| |
416 |
| |
417 gtk_clist_set_text(GTK_CLIST(clistqueue), row, 1, number); |
| |
418 } |
| |
419 else |
| |
420 { |
| |
421 |
| |
422 gchar *heh[2]; |
| |
423 |
| |
424 heh[0] = strdup(qm->name); |
| |
425 heh[1] = strdup(_("(1 message)")); |
| |
426 gtk_clist_append(GTK_CLIST(clistqueue), heh); |
| |
427 |
| |
428 g_free(heh[0]); |
| |
429 g_free(heh[1]); |
| |
430 } |
| |
431 |
| 380 message_queue = g_slist_append(message_queue, qm); |
432 message_queue = g_slist_append(message_queue, qm); |
| 381 */ |
433 } |
| 382 write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime); |
434 else |
| |
435 { |
| |
436 if (!(general_options & OPT_GEN_DISCARD_WHEN_AWAY)) { |
| |
437 if (cnv == NULL) { |
| |
438 new_conv = 1; |
| |
439 cnv = new_conversation(name); |
| |
440 cnv->gc = gc; |
| |
441 gtk_option_menu_set_history(GTK_OPTION_MENU(cnv->menu), |
| |
442 g_slist_index(connections, gc)); |
| |
443 update_buttons_by_protocol(cnv); |
| |
444 } |
| |
445 } else { |
| |
446 return; |
| |
447 } |
| |
448 if (cnv != NULL) { |
| |
449 if (cnv->makesound && (sound_options & OPT_SOUND_RECV)) |
| |
450 play_sound(RECEIVE); |
| |
451 |
| |
452 write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime); |
| |
453 } |
| 383 } |
454 } |
| 384 |
455 |
| 385 } else { |
456 } else { |
| 386 if (cnv == NULL) { |
457 if (cnv == NULL) { |
| 387 new_conv = 1; |
458 new_conv = 1; |
| 391 g_slist_index(connections, gc)); |
462 g_slist_index(connections, gc)); |
| 392 update_buttons_by_protocol(cnv); |
463 update_buttons_by_protocol(cnv); |
| 393 } |
464 } |
| 394 if (new_conv && (sound_options & OPT_SOUND_FIRST_RCV)) { |
465 if (new_conv && (sound_options & OPT_SOUND_FIRST_RCV)) { |
| 395 play_sound(FIRST_RECEIVE); |
466 play_sound(FIRST_RECEIVE); |
| 396 } else { |
467 } else |
| |
468 { |
| 397 if (cnv->makesound && (sound_options & OPT_SOUND_RECV)) |
469 if (cnv->makesound && (sound_options & OPT_SOUND_RECV)) |
| 398 play_sound(RECEIVE); |
470 play_sound(RECEIVE); |
| 399 } |
471 } |
| |
472 |
| 400 write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime); |
473 write_to_conv(cnv, message, away | WFLAG_RECV, NULL, mtime); |
| 401 } |
474 } |
| 402 |
475 |
| 403 |
476 |
| 404 |
477 |
| 409 struct buddy *b = find_buddy(gc, name); |
482 struct buddy *b = find_buddy(gc, name); |
| 410 char *alias = b ? b->show : name; |
483 char *alias = b ? b->show : name; |
| 411 |
484 |
| 412 time(&t); |
485 time(&t); |
| 413 |
486 |
| |
487 /* apply default fonts and colors */ |
| |
488 tmpmsg = stylize(gc->away, MSG_LEN); |
| |
489 serv_send_im(gc, name, away_subs(tmpmsg, alias), 1); |
| 414 |
490 |
| 415 if ((cnv == NULL) || (t - cnv->sent_away) < 120) |
491 if ((cnv == NULL) || (t - cnv->sent_away) < 120) |
| 416 return; |
492 return; |
| 417 |
493 |
| 418 cnv->sent_away = t; |
494 cnv->sent_away = t; |
| 419 |
495 |
| 420 /* apply default fonts and colors */ |
|
| 421 tmpmsg = stylize(gc->away, MSG_LEN); |
|
| 422 |
|
| 423 serv_send_im(gc, name, away_subs(tmpmsg, alias), 1); |
|
| 424 |
|
| 425 if (cnv != NULL) |
496 if (cnv != NULL) |
| 426 write_to_conv(cnv, away_subs(tmpmsg, alias), WFLAG_SEND | WFLAG_AUTO, NULL, mtime); |
497 write_to_conv(cnv, away_subs(tmpmsg, alias), WFLAG_SEND | WFLAG_AUTO, NULL, mtime); |
| |
498 |
| 427 g_free(tmpmsg); |
499 g_free(tmpmsg); |
| 428 } |
500 } |
| 429 } |
501 } |
| 430 |
502 |
| 431 |
503 |