diff src/server.c @ 4767:f6d83e81d45a

[gaim-migrate @ 5085] This brings back: - Sounds - "SeanEgn logged in." messages - Plugin and perl events - Raise Buddy list on events - I think that's all. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Fri, 14 Mar 2003 08:10:17 +0000
parents a979ce8ec806
children c4c28874ecd3
line wrap: on
line diff
--- a/src/server.c	Fri Mar 14 07:04:46 2003 +0000
+++ b/src/server.c	Fri Mar 14 08:10:17 2003 +0000
@@ -35,6 +35,7 @@
 #include "prpl.h"
 #include "multi.h"
 #include "gaim.h"
+#include "sound.h"
 
 #include "pixmaps/cancel.xpm"
 #include "pixmaps/tb_search.xpm"
@@ -899,22 +900,58 @@
 
 	gaim_blist_update_buddy_status(b, type);
 	
-	gaim_blist_update_buddy_presence(b, loggedin);
 
 	if (loggedin) {
-		if (!b->present) {
-			//b->present = 1;
+		if (!b->present == 1) {
+			struct gaim_conversation *c = gaim_find_conversation(b->name);
+			if (c) {
+				char *tmp = g_strdup_printf(_("%s logged in."), gaim_get_buddy_alias(b));
+				gaim_conversation_write(c, NULL, tmp, -1,
+							WFLAG_SYSTEM, time(NULL));
+				g_free(tmp);
+			} else if (awayqueue && find_queue_total_by_name(b->name)) {
+				struct queued_message *qm = g_new0(struct queued_message, 1);
+				g_snprintf(qm->name, sizeof(qm->name), "%s", b->name);
+				qm->message = g_strdup_printf(_("%s logged in."),
+							      gaim_get_buddy_alias(b));
+				qm->account = gc->account;
+				qm->tm = time(NULL);
+				qm->flags = WFLAG_SYSTEM;
+				qm->len = -1;
+				message_queue = g_slist_append(message_queue, qm);
+			}
+			gaim_sound_play_event(GAIM_SOUND_BUDDY_ARRIVE);
 			do_pounce(gc, b->name, OPT_POUNCE_SIGNON);
 			plugin_event(event_buddy_signon, gc, b->name);
 			system_log(log_signon, gc, b, OPT_LOG_BUDDY_SIGNON);
 		}
 	} else {
-		if (b->present) {
+		if (b->present == 1) {
+			struct gaim_conversation *c = gaim_find_conversation(b->name);
+			if (c) {
+				char *tmp = g_strdup_printf(_("%s logged out."), gaim_get_buddy_alias(b));
+				gaim_conversation_write(c, NULL, tmp, -1,
+							WFLAG_SYSTEM, time(NULL));
+				g_free(tmp);
+			} else if (awayqueue && find_queue_total_by_name(b->name)) {
+				struct queued_message *qm = g_new0(struct queued_message, 1);
+				g_snprintf(qm->name, sizeof(qm->name), "%s", b->name);
+				qm->message = g_strdup_printf(_("%s logged out."),
+							      gaim_get_buddy_alias(b));
+				qm->account = gc->account;
+				qm->tm = time(NULL);
+				qm->flags = WFLAG_SYSTEM;
+				qm->len = -1;
+				message_queue = g_slist_append(message_queue, qm);
+			}
+			gaim_sound_play_event(GAIM_SOUND_BUDDY_LEAVE);
 			plugin_event(event_buddy_signoff, gc, b->name);
 			system_log(log_signoff, gc, b, OPT_LOG_BUDDY_SIGNON);
 		}
-		b->present = 0;
-	}
+	}	
+	
+	gaim_blist_update_buddy_presence(b, loggedin);
+
 }