comparison src/server.c @ 12116:e75ef7aa913e

[gaim-migrate @ 14416] " This patch implements a replacement for the queuing system from 1.x. It also obsoletes a previous patch [#1338873] I submitted to prioritize the unseen states in gtk conversations. The attached envelope.png is ripped from the msgunread.png already included in gaim. It should be dropped in the pixmaps directory (Makefile.am is updated accordingly in this patch). The two separate queuing preferences from 1.x, queuing messages while away and queuing all new messages (from docklet), are replaced with a single 3-way preference for conversations. The new preference is "Hide new IM conversations". This preference can be set to never, away and always. When a gtk conversation is created, it may be placed in a hidden conversation window instead of being placed normally. This decision is based upon the preference and possibly the away state of the account the conversation is being created for. This *will* effect conversations the user explicitly requests to be created, so in these cases the caller must be sure to present the conversation to the user, using gaim_gtkconv_present_conversation(). This is done already in gtkdialogs.c which handles creating conversations requested by the user from gaim proper (menus, double-clicking on budy in blist, etc.). The main advantage to not queuing messages is that the conversations exist, the message is written to the conversation (and logged if appropriate) and the unseen state is set on the conversation. This means no additional features are needed to track whether there are queued messages or not, just use the unseen state on conversations. Since conversations may not be visible (messages "queued"), gaim proper needs some notification that there are messages waiting. I opted for a menutray icon that shows up when an im conversation has an unseen message. Clicking this icon will focus (and show if hidden) the first conversation with an unseen message. This is essentially the same behavior of the docklet in cvs right now, except that the icon is only visible when there is a conversation with an unread message. The api that is added is flexible enough to allow either the docklet or the new blist menutray icon to be visible for conversations of any/all types and for unseen messages >= any state. Currently they are set to only IM conversations and only unseen states >= TEXT (system messages and no log messages will not trigger blinking the docklet or showing the blist tray icon), but these could be made preferences relatively easily in the future. Other plugins could probably benefit as well: gaim_gtk_conversations_get_first_unseen(). There is probably some limit to comment size, so I'll stop rambling now. If anyone has more questions/comments, catch me in #gaim, here or on gaim-devel." committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 16 Nov 2005 18:17:01 +0000
parents 2cbb5993c819
children 4d3119205a33
comparison
equal deleted inserted replaced
12115:e9790eb93216 12116:e75ef7aa913e
426 if (prpl_info && prpl_info->set_buddy_icon) 426 if (prpl_info && prpl_info->set_buddy_icon)
427 prpl_info->set_buddy_icon(gc, filename); 427 prpl_info->set_buddy_icon(gc, filename);
428 428
429 } 429 }
430 430
431 #if 0
432 int find_queue_row_by_name(char *name)
433 {
434 gchar *temp;
435 gint i = 0;
436 gboolean valid;
437 GtkTreeIter iter;
438
439 valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(awayqueuestore), &iter);
440 while(valid) {
441 gtk_tree_model_get(GTK_TREE_MODEL(awayqueuestore), &iter, 0, &temp, -1);
442 if(!strcmp(name, temp))
443 return i;
444 g_free(temp);
445
446 i++;
447 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(awayqueuestore), &iter);
448 }
449
450 return -1;
451 }
452
453 int find_queue_total_by_name(char *name)
454 {
455 GSList *templist;
456 int i = 0;
457
458 templist = message_queue;
459
460 while (templist) {
461 struct queued_message *qm = (struct queued_message *)templist->data;
462 if ((qm->flags & GAIM_MESSAGE_RECV) && !strcmp(name, qm->name))
463 i++;
464
465 templist = templist->next;
466 }
467
468 return i;
469 }
470 #endif
471
472 /* 431 /*
473 * woo. i'm actually going to comment this function. isn't that fun. make 432 * woo. i'm actually going to comment this function. isn't that fun. make
474 * sure to follow along, kids 433 * sure to follow along, kids
475 */ 434 */
476 void serv_got_im(GaimConnection *gc, const char *who, const char *msg, 435 void serv_got_im(GaimConnection *gc, const char *who, const char *msg,
551 GaimBuddy *b = gaim_find_buddy(gc->account, name); 510 GaimBuddy *b = gaim_find_buddy(gc->account, name);
552 const char *alias = b ? gaim_buddy_get_alias(b) : name; 511 const char *alias = b ? gaim_buddy_get_alias(b) : name;
553 struct last_auto_response *lar; 512 struct last_auto_response *lar;
554 const gchar *auto_reply_pref; 513 const gchar *auto_reply_pref;
555 const char *away_msg; 514 const char *away_msg;
556 #if 0 515
557 int row; 516 if (cnv == NULL)
558 #endif 517 cnv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name);
518
519 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, message, msgflags, mtime);
559 520
560 /* 521 /*
561 * Either we're going to queue it or not. Because of the way
562 * awayness currently works, this is fucked up. It's possible
563 * for an account to be away without the imaway dialog being
564 * shown. In fact, it's possible for *all* the accounts to be
565 * away without the imaway dialog being shown. So in order for
566 * this to be queued properly, we have to make sure that the
567 * imaway dialog actually exists, first.
568 */
569 #if 0
570 if (!cnv && awayqueue &&
571 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) {
572 /*
573 * Alright, so we're going to queue it. Neat, eh? :)
574 * So first we create something to store the message, and add
575 * it to our queue. Then we update the away dialog to indicate
576 * that we've queued something.
577 */
578 struct queued_message *qm;
579 GtkTreeIter iter;
580 gchar path[10];
581
582 qm = g_new0(struct queued_message, 1);
583 g_snprintf(qm->name, sizeof(qm->name), "%s", name);
584 if(strcmp(alias, name) != 0)
585 g_snprintf(qm->alias, sizeof(qm->alias), "(%s)", alias);
586 qm->message = g_strdup(message);
587 qm->account = gc->account;
588 qm->tm = mtime;
589 qm->flags = msgflags;
590 message_queue = g_slist_append(message_queue, qm);
591
592 row = find_queue_row_by_name(qm->name);
593 if (row >= 0) {
594 char number[32];
595 int qtotal;
596
597 qtotal = find_queue_total_by_name(qm->name);
598 g_snprintf(number, 32, ngettext("(%d message)",
599 "(%d messages)", qtotal), qtotal);
600 g_snprintf(path, 10, "%d", row);
601 gtk_tree_model_get_iter_from_string(
602 GTK_TREE_MODEL(awayqueuestore), &iter, path);
603 gtk_list_store_set(awayqueuestore, &iter,
604 2, number, -1);
605 } else {
606 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(awayqueuestore),
607 &iter);
608 gtk_list_store_append(awayqueuestore, &iter);
609 gtk_list_store_set(awayqueuestore, &iter,
610 0, qm->name,
611 1, qm->alias,
612 2, _("(1 message)"),
613 -1);
614 }
615 }
616 else
617 #endif
618 {
619 /*
620 * Make sure the conversation
621 * exists and is updated (partly handled above already), play
622 * the receive sound (sound.c will take care of not playing
623 * while away), and then write it to the convo window.
624 */
625 if (cnv == NULL)
626 cnv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name);
627
628 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, message, msgflags, mtime);
629 }
630
631 /*
632 * Regardless of whether we queue it or not, we should send an
633 * auto-response. That is, of course, unless the horse.... no wait.
634 * Don't autorespond if: 522 * Don't autorespond if:
635 * 523 *
636 * - it's not supported on this connection 524 * - it's not supported on this connection
637 * - or the away message is empty 525 * - or the away message is empty
638 * - or it's disabled 526 * - or it's disabled