Mercurial > pidgin
comparison src/server.c @ 4124:19ee0409a3d7
[gaim-migrate @ 4341]
fix segfault on returning from away with messages queued from ari. also gets
rid of some gtk1.2 code in favor of gtk2 code.
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Mon, 23 Dec 2002 23:08:14 +0000 |
| parents | ee884f1d7ae3 |
| children | d3c8d2b40494 |
comparison
equal
deleted
inserted
replaced
| 4123:1e87350cb57c | 4124:19ee0409a3d7 |
|---|---|
| 471 return val; | 471 return val; |
| 472 } | 472 } |
| 473 | 473 |
| 474 int find_queue_row_by_name(char *name) | 474 int find_queue_row_by_name(char *name) |
| 475 { | 475 { |
| 476 GSList *templist; | 476 gchar *temp; |
| 477 char *temp; | 477 gint i = 0; |
| 478 int i; | 478 gboolean valid; |
| 479 | 479 GtkTreeIter iter; |
| 480 templist = message_queue; | 480 |
| 481 | 481 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(awayqueuestore), &iter); |
| 482 for (i = 0; i < GTK_CLIST(clistqueue)->rows; i++) { | 482 while(valid) { |
| 483 gtk_clist_get_text(GTK_CLIST(clistqueue), i, 0, &temp); | 483 gtk_tree_model_get(GTK_TREE_MODEL(awayqueuestore), &iter, 0, &temp, -1); |
| 484 | 484 if(!strcmp(name, temp)) |
| 485 if (!strcmp(name, temp)) | |
| 486 return i; | 485 return i; |
| 486 g_free(temp); | |
| 487 | |
| 488 i++; | |
| 489 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(awayqueuestore), &iter); | |
| 487 } | 490 } |
| 488 | 491 |
| 489 return -1; | 492 return -1; |
| 490 } | 493 } |
| 491 | 494 |
| 621 /* either we're going to queue it or not. Because of the way awayness currently | 624 /* either we're going to queue it or not. Because of the way awayness currently |
| 622 * works, this is fucked up. it's possible for an account to be away without the | 625 * works, this is fucked up. it's possible for an account to be away without the |
| 623 * imaway dialog being shown. in fact, it's possible for *all* the accounts to be | 626 * imaway dialog being shown. in fact, it's possible for *all* the accounts to be |
| 624 * away without the imaway dialog being shown. so in order for this to be queued | 627 * away without the imaway dialog being shown. so in order for this to be queued |
| 625 * properly, we have to make sure that the imaway dialog actually exists, first. */ | 628 * properly, we have to make sure that the imaway dialog actually exists, first. */ |
| 626 if (!cnv && clistqueue && (away_options & OPT_AWAY_QUEUE)) { | 629 if (!cnv && awayqueue && (away_options & OPT_AWAY_QUEUE)) { |
| 627 /* alright, so we're going to queue it. neat, eh? :) so first we create | 630 /* alright, so we're going to queue it. neat, eh? :) so first we create |
| 628 * something to store the message, and add it to our queue. Then we update | 631 * something to store the message, and add it to our queue. Then we update |
| 629 * the away dialog to indicate that we've queued something. */ | 632 * the away dialog to indicate that we've queued something. */ |
| 630 struct queued_message *qm; | 633 struct queued_message *qm; |
| 631 struct buddy *b; | 634 GtkTreeIter iter; |
| 632 | 635 gchar path[10]; |
| 636 | |
| 633 qm = g_new0(struct queued_message, 1); | 637 qm = g_new0(struct queued_message, 1); |
| 634 g_snprintf(qm->name, sizeof(qm->name), "%s", name); | 638 g_snprintf(qm->name, sizeof(qm->name), "%s", name); |
| 635 qm->message = g_memdup(message, len == -1 ? strlen(message) + 1 : len); | 639 qm->message = g_memdup(message, len == -1 ? strlen(message) + 1 : len); |
| 636 qm->gc = gc; | 640 qm->gc = gc; |
| 637 qm->tm = mtime; | 641 qm->tm = mtime; |
| 638 qm->flags = WFLAG_RECV | away; | 642 qm->flags = WFLAG_RECV | away; |
| 639 qm->len = len; | 643 qm->len = len; |
| 640 message_queue = g_slist_append(message_queue, qm); | 644 message_queue = g_slist_append(message_queue, qm); |
| 641 | 645 |
| 642 row = find_queue_row_by_name(qm->name); | 646 row = find_queue_row_by_name(qm->name); |
| 643 | |
| 644 if (row >= 0) { | 647 if (row >= 0) { |
| 645 char number[32]; | 648 char number[32]; |
| 646 int qtotal; | 649 int qtotal; |
| 647 | 650 |
| 648 qtotal = find_queue_total_by_name(qm->name); | 651 qtotal = find_queue_total_by_name(qm->name); |
| 649 g_snprintf(number, 32, _("(%d messages)"), qtotal); | 652 g_snprintf(number, 32, _("(%d messages)"), qtotal); |
| 650 gtk_clist_set_text(GTK_CLIST(clistqueue), row, 1, number); | 653 g_snprintf(path, 10, "%d", row); |
| 654 gtk_tree_model_get_iter_from_string( | |
| 655 GTK_TREE_MODEL(awayqueuestore), &iter, path); | |
| 656 gtk_list_store_set(awayqueuestore, &iter, | |
| 657 1, number, -1); | |
| 651 } else { | 658 } else { |
| 652 gchar *heh[2]; | 659 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(awayqueuestore), |
| 653 | 660 &iter); |
| 654 heh[0] = qm->name; | 661 gtk_list_store_append(awayqueuestore, &iter); |
| 655 heh[1] = _("(1 message)"); | 662 gtk_list_store_set(awayqueuestore, &iter, |
| 656 gtk_clist_append(GTK_CLIST(clistqueue), heh); | 663 0, qm->name, |
| 664 1, _("(1 message)"), | |
| 665 -1); | |
| 657 } | 666 } |
| 658 } else { | 667 } else { |
| 659 /* ok, so we're not queuing it. well then, we'll try to handle it normally. | 668 /* ok, so we're not queuing it. well then, we'll try to handle it normally. |
| 660 * Some people think that ignoring it is a perfectly acceptible way to handle | 669 * Some people think that ignoring it is a perfectly acceptible way to handle |
| 661 * it. i think they're on crack, but hey, that's why it's optional. */ | 670 * it. i think they're on crack, but hey, that's why it's optional. */ |
| 715 qar->sent_away = t; | 724 qar->sent_away = t; |
| 716 | 725 |
| 717 /* apply default fonts and colors */ | 726 /* apply default fonts and colors */ |
| 718 tmpmsg = stylize(gc->away, MSG_LEN); | 727 tmpmsg = stylize(gc->away, MSG_LEN); |
| 719 serv_send_im(gc, name, away_subs(tmpmsg, alias), -1, IM_FLAG_AWAY); | 728 serv_send_im(gc, name, away_subs(tmpmsg, alias), -1, IM_FLAG_AWAY); |
| 720 if (!cnv && clistqueue && (away_options & OPT_AWAY_QUEUE)) { | 729 if (!cnv && awayqueue && (away_options & OPT_AWAY_QUEUE)) { |
| 721 struct queued_message *qm; | 730 struct queued_message *qm; |
| 722 qm = g_new0(struct queued_message, 1); | 731 qm = g_new0(struct queued_message, 1); |
| 723 g_snprintf(qm->name, sizeof(qm->name), "%s", name); | 732 g_snprintf(qm->name, sizeof(qm->name), "%s", name); |
| 724 qm->message = g_strdup(away_subs(tmpmsg, alias)); | 733 qm->message = g_strdup(away_subs(tmpmsg, alias)); |
| 725 qm->gc = gc; | 734 qm->gc = gc; |
