Mercurial > pidgin
comparison src/server.c @ 1774:9d0c91c705b7
[gaim-migrate @ 1784]
Fixed a problem with away messages when you're queing received messages.
committer: Tailor Script <tailor@pidgin.im>
| author | Rob Flynn <gaim@robflynn.com> |
|---|---|
| date | Mon, 30 Apr 2001 07:00:15 +0000 |
| parents | 6d1d9e988fd4 |
| children | 9ca22174da76 |
comparison
equal
deleted
inserted
replaced
| 1773:6d1d9e988fd4 | 1774:9d0c91c705b7 |
|---|---|
| 345 } | 345 } |
| 346 | 346 |
| 347 return i; | 347 return i; |
| 348 } | 348 } |
| 349 | 349 |
| 350 struct queued_away_response *find_queued_away_response_by_name(char *name) | |
| 351 { | |
| 352 GSList *templist; | |
| 353 struct queued_away_response *qar; | |
| 354 | |
| 355 templist = away_time_queue; | |
| 356 | |
| 357 while (templist) | |
| 358 { | |
| 359 qar = (struct queued_away_response *)templist->data; | |
| 360 | |
| 361 if (!strcmp(name, qar->name)) | |
| 362 return qar; | |
| 363 | |
| 364 templist = templist->next; | |
| 365 } | |
| 366 | |
| 367 return NULL; | |
| 368 } | |
| 369 | |
| 350 void serv_got_im(struct gaim_connection *gc, char *name, char *message, int away, time_t mtime) | 370 void serv_got_im(struct gaim_connection *gc, char *name, char *message, int away, time_t mtime) |
| 351 { | 371 { |
| 352 struct conversation *cnv; | 372 struct conversation *cnv; |
| 353 int new_conv = 0; | 373 int new_conv = 0; |
| 354 int hehe = away; | 374 int hehe = away; |
| 393 | 413 |
| 394 if (gc->away) { | 414 if (gc->away) { |
| 395 if (general_options & OPT_GEN_QUEUE_WHEN_AWAY) | 415 if (general_options & OPT_GEN_QUEUE_WHEN_AWAY) |
| 396 { | 416 { |
| 397 struct queued_message *qm; | 417 struct queued_message *qm; |
| 418 struct queued_away_response *qar; | |
| 398 int row; | 419 int row; |
| 399 | 420 |
| 400 qm = (struct queued_message *)g_new0(struct queued_message, 1); | 421 qm = (struct queued_message *)g_new0(struct queued_message, 1); |
| 401 snprintf(qm->name, sizeof(qm->name), "%s", name); | 422 g_snprintf(qm->name, sizeof(qm->name), "%s", name); |
| 402 qm->message = strdup(message); | 423 qm->message = strdup(message); |
| 403 qm->gc = gc; | 424 qm->gc = gc; |
| 404 qm->tm = mtime; | 425 qm->tm = mtime; |
| 405 | 426 |
| 406 row = find_queue_row_by_name(qm->name); | 427 row = find_queue_row_by_name(qm->name); |
| 410 char number[32]; | 431 char number[32]; |
| 411 int qtotal; | 432 int qtotal; |
| 412 | 433 |
| 413 qtotal = find_queue_total_by_name(qm->name); | 434 qtotal = find_queue_total_by_name(qm->name); |
| 414 | 435 |
| 415 snprintf(number, 32, _("(%d messages)"), ++qtotal); | 436 g_snprintf(number, 32, _("(%d messages)"), ++qtotal); |
| 416 | 437 |
| 417 gtk_clist_set_text(GTK_CLIST(clistqueue), row, 1, number); | 438 gtk_clist_set_text(GTK_CLIST(clistqueue), row, 1, number); |
| 418 } | 439 } |
| 419 else | 440 else |
| 420 { | 441 { |
| 421 | 442 |
| 422 gchar *heh[2]; | 443 gchar *heh[2]; |
| 423 | 444 int tmp = 0; |
| 424 heh[0] = strdup(qm->name); | 445 |
| 425 heh[1] = strdup(_("(1 message)")); | 446 heh[0] = g_strdup(qm->name); |
| 447 heh[1] = g_strdup(_("(1 message)")); | |
| 426 gtk_clist_append(GTK_CLIST(clistqueue), heh); | 448 gtk_clist_append(GTK_CLIST(clistqueue), heh); |
| 449 | |
| 450 row = find_queue_row_by_name(qm->name); | |
| 427 | 451 |
| 428 g_free(heh[0]); | 452 g_free(heh[0]); |
| 429 g_free(heh[1]); | 453 g_free(heh[1]); |
| 430 } | 454 } |
| 431 | 455 |
| 479 if (!(general_options & OPT_GEN_NO_AUTO_RESP) && gc->away && strlen(gc->away)) { | 503 if (!(general_options & OPT_GEN_NO_AUTO_RESP) && gc->away && strlen(gc->away)) { |
| 480 time_t t; | 504 time_t t; |
| 481 char *tmpmsg; | 505 char *tmpmsg; |
| 482 struct buddy *b = find_buddy(gc, name); | 506 struct buddy *b = find_buddy(gc, name); |
| 483 char *alias = b ? b->show : name; | 507 char *alias = b ? b->show : name; |
| 508 int sawy; | |
| 509 int row; | |
| 510 struct queued_away_response *qar = NULL; | |
| 484 | 511 |
| 485 time(&t); | 512 time(&t); |
| 513 | |
| 514 if (cnv) | |
| 515 sawy = cnv->sent_away; | |
| 516 else | |
| 517 { | |
| 518 qar = find_queued_away_response_by_name(name); | |
| 519 | |
| 520 if (!qar) | |
| 521 { | |
| 522 qar = (struct queued_away_response *)g_new0(struct queued_away_response, 1); | |
| 523 | |
| 524 g_snprintf(qar->name, sizeof(qar->name), "%s", name); | |
| 525 qar->sent_away = 0; | |
| 526 | |
| 527 away_time_queue = g_slist_append(away_time_queue, qar); | |
| 528 } | |
| 529 | |
| 530 sawy = qar->sent_away; | |
| 531 } | |
| 532 | |
| 533 if ((t - sawy) < 120) | |
| 534 return; | |
| 486 | 535 |
| 487 /* apply default fonts and colors */ | 536 /* apply default fonts and colors */ |
| 488 tmpmsg = stylize(gc->away, MSG_LEN); | 537 tmpmsg = stylize(gc->away, MSG_LEN); |
| 489 serv_send_im(gc, name, away_subs(tmpmsg, alias), 1); | 538 serv_send_im(gc, name, away_subs(tmpmsg, alias), 1); |
| 490 | 539 |
| 491 if ((cnv == NULL) || (t - cnv->sent_away) < 120) | 540 if (cnv) |
| 492 return; | 541 cnv->sent_away = t; |
| 493 | 542 else if (qar) |
| 494 cnv->sent_away = t; | 543 qar->sent_away = t; |
| 495 | 544 |
| 496 if (cnv != NULL) | 545 if (cnv != NULL) |
| 497 write_to_conv(cnv, away_subs(tmpmsg, alias), WFLAG_SEND | WFLAG_AUTO, NULL, mtime); | 546 write_to_conv(cnv, away_subs(tmpmsg, alias), WFLAG_SEND | WFLAG_AUTO, NULL, mtime); |
| 498 | 547 |
| 499 g_free(tmpmsg); | 548 g_free(tmpmsg); |
