changeset 9917:e74eb0d11f86

[gaim-migrate @ 10809] view chat logs curtesy of datallah committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 31 Aug 2004 01:45:12 +0000
parents 4d17a945aab3
children c203312d8224
files ChangeLog plugins/ChangeLog.API src/gtkblist.c src/gtkconv.c src/gtkdialogs.c src/gtklog.c src/gtklog.h src/protocols/gg/gg.c src/protocols/irc/irc.c src/protocols/jabber/chat.c src/protocols/jabber/chat.h src/protocols/jabber/jabber.c src/protocols/msn/msn.c src/protocols/napster/napster.c src/protocols/novell/novell.c src/protocols/oscar/oscar.c src/protocols/silc/chat.c src/protocols/silc/silc.c src/protocols/silc/silcgaim.h src/protocols/toc/toc.c src/protocols/trepia/trepia.c src/protocols/yahoo/yahoo.c src/protocols/yahoo/yahoochat.c src/protocols/yahoo/yahoochat.h src/protocols/zephyr/zephyr.c src/prpl.h
diffstat 26 files changed, 119 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Aug 30 23:13:28 2004 +0000
+++ b/ChangeLog	Tue Aug 31 01:45:12 2004 +0000
@@ -3,6 +3,7 @@
 	New Features:
 	* Drag-and-drop buddy support for the Invite dialog (Stu Tomlinson)
 	* Drag-and-drop buddy support for the Pounce dialog (Stu Tomlinson)
+	* View Chat log available from the interface (Daniel Atallah)
 
 	Bug Fixes:
 	* Compile with gtk 2.5.x (Gary Kramlich)
--- a/plugins/ChangeLog.API	Mon Aug 30 23:13:28 2004 +0000
+++ b/plugins/ChangeLog.API	Tue Aug 31 01:45:12 2004 +0000
@@ -1,6 +1,10 @@
 Gaim: The Pimpin' Penguin IM Client that's good for the soul!
 
-version 0.82cvs:
+version 0.83:
+	Protocol Plugin API: v8
+	* Added: get_chat_name to the GaimPluginProtocolInfo struct
+
+version 0.82 (08/26/2004):
 	Gaim API:
 	* Removed: gaim_gtk_get_dispstyle(), gaim_gtk_change_text()
 	* Removed: multi.h
--- a/src/gtkblist.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/gtkblist.c	Tue Aug 31 01:45:12 2004 +0000
@@ -530,9 +530,32 @@
 	gaim_gtkpounce_dialog_show(b->account, b->name, NULL);
 }
 
-static void gtk_blist_menu_showlog_cb(GtkWidget *w, GaimBuddy *b)
+static void gtk_blist_menu_showlog_cb(GtkWidget *w, GaimBlistNode *node)
 {
-	gaim_gtk_log_show(b->name, b->account);
+	GaimLogType type;
+	GaimAccount *account;
+	char *name = NULL;
+	if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
+		GaimBuddy *b = (GaimBuddy*) node;
+		type = GAIM_LOG_IM;
+		name = g_strdup(b->name);
+		account = b->account;
+	} else if (GAIM_BLIST_NODE_IS_CHAT(node)) {
+		GaimChat *c = (GaimChat*) node;
+		GaimPluginProtocolInfo *prpl_info = NULL;
+		type = GAIM_LOG_CHAT;
+		account = c->account;
+		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(account)));
+		if (prpl_info && prpl_info->get_chat_name) {
+			name = prpl_info->get_chat_name(c->components);
+		}
+	} else
+		return;
+
+	if (name && account) {
+		gaim_gtk_log_show(type, name, account);
+		g_free(name);
+	}
 }
 
 static void gtk_blist_show_systemlog_cb()
@@ -1217,6 +1240,8 @@
 			G_CALLBACK(gtk_blist_menu_join_cb), node, 0, 0, NULL);
 	gaim_new_check_item(menu, _("Auto-Join"),
 			G_CALLBACK(gtk_blist_menu_autojoin_cb), node, autojoin);
+	gaim_new_item_from_stock(menu, _("View _Log"), NULL,
+			G_CALLBACK(gtk_blist_menu_showlog_cb), node, 0, 0, NULL);
 
 	gaim_gtk_append_blist_node_proto_menu(menu, c->account->gc, node);
 	gaim_gtk_append_blist_node_extended_menu(menu, node);
--- a/src/gtkconv.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/gtkconv.c	Tue Aug 31 01:45:12 2004 +0000
@@ -935,10 +935,18 @@
 {
 	GaimConvWindow *win = (GaimConvWindow *)data;
 	GaimConversation *conv;
+	GaimLogType type;
 
 	conv = gaim_conv_window_get_active_conversation(win);
 
-	gaim_gtk_log_show((char *)gaim_conversation_get_name(conv),
+	if (gaim_conversation_get_type(conv) == GAIM_CONV_IM)
+		type = GAIM_LOG_IM;
+	else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT)
+		type = GAIM_LOG_CHAT;
+	else
+		return;
+
+	gaim_gtk_log_show(type, gaim_conversation_get_name(conv),
 					  gaim_conversation_get_account(conv));
 }
 
@@ -2752,7 +2760,7 @@
 		gtk_widget_show(gtkconv->u.chat->invite);
 
 		/* Deal with menu items */
-		gtk_widget_hide(gtkwin->menu.view_log);
+		gtk_widget_show(gtkwin->menu.view_log);
 		gtk_widget_hide(gtkwin->menu.send_file);
 		gtk_widget_hide(gtkwin->menu.add_pounce);
 		gtk_widget_hide(gtkwin->menu.get_info);
--- a/src/gtkdialogs.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/gtkdialogs.c	Tue Aug 31 01:45:12 2004 +0000
@@ -540,12 +540,13 @@
 	username = g_strdup(gaim_normalize(account,
 		gaim_request_fields_get_string(fields,  "screenname")));
 
-	if( username != NULL && *username != '\0' && account != NULL )
-		gaim_gtk_log_show( username, account );
+	if(username != NULL && *username != '\0' && account != NULL )
+		gaim_gtk_log_show(GAIM_LOG_IM, username, account);
 
 	g_free(username);
 }
 
+/* XXX this needs to deal with logs of all types, not just IM logs */
 void
 gaim_gtkdialogs_log(void)
 {
--- a/src/gtklog.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/gtklog.c	Tue Aug 31 01:45:12 2004 +0000
@@ -248,7 +248,7 @@
 	}
 }
 
-void gaim_gtk_log_show(const char *screenname, GaimAccount *account) {
+void gaim_gtk_log_show(GaimLogType type, const char *screenname, GaimAccount *account) {
 	/* if (log_viewers && g_hash_table */
 	GtkWidget *hbox, *vbox;
 	GdkPixbuf *pixbuf, *scale;
@@ -272,7 +272,7 @@
 	}
 
 	lv = g_new0(GaimGtkLogViewer, 1);
-	lv->logs = logs = gaim_log_get_logs(GAIM_LOG_IM, screenname, account);
+	lv->logs = logs = gaim_log_get_logs(type, screenname, account);
 	g_hash_table_insert(log_viewers, ht, lv);
 
 	/* Window ***********/
--- a/src/gtklog.h	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/gtklog.h	Tue Aug 31 01:45:12 2004 +0000
@@ -49,6 +49,6 @@
 
 
 
-void gaim_gtk_log_show(const char *screenname, GaimAccount *account);
+void gaim_gtk_log_show(GaimLogType type, const char *screenname, GaimAccount *account);
 
 void gaim_gtk_syslog_show();
--- a/src/protocols/gg/gg.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/gg/gg.c	Tue Aug 31 01:45:12 2004 +0000
@@ -1,6 +1,6 @@
 /*
  * gaim - Gadu-Gadu Protocol Plugin
- * $Id: gg.c 10742 2004-08-25 03:09:08Z thekingant $
+ * $Id: gg.c 10809 2004-08-31 01:45:12Z lschiere $
  *
  * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
  *
@@ -1645,6 +1645,7 @@
 	NULL,						/* warn */
 	NULL,						/* join_chat */
 	NULL,						/* reject_chat */
+	NULL,						/* get_chat_name */
 	NULL,						/* chat_invite */
 	NULL,						/* chat_leave */
 	NULL,						/* chat_whisper */
--- a/src/protocols/irc/irc.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/irc/irc.c	Tue Aug 31 01:45:12 2004 +0000
@@ -429,6 +429,10 @@
 	irc_cmd_join(irc, "join", NULL, args);
 }
 
+static char *irc_get_chat_name(GHashTable *data) {
+	return g_strdup(g_hash_table_lookup(data, "channel"));
+}
+
 static void irc_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) 
 {
 	struct irc_conn *irc = gc->proto_data;
@@ -613,6 +617,7 @@
 	NULL,					/* warn */
 	irc_chat_join,			/* join_chat */
 	NULL,					/* reject_chat */
+	irc_get_chat_name,		/* get_chat_name */
 	irc_chat_invite,		/* chat_invite */
 	irc_chat_leave,			/* chat_leave */
 	NULL,					/* chat_whisper */
--- a/src/protocols/jabber/chat.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/jabber/chat.c	Tue Aug 31 01:45:12 2004 +0000
@@ -177,6 +177,18 @@
 
 void jabber_chat_member_free(JabberChatMember *jcm);
 
+char *jabber_get_chat_name(GHashTable *data) {
+	char *room, *server, *chat_name = NULL;
+
+	room = g_hash_table_lookup(data, "room");
+	server = g_hash_table_lookup(data, "server");
+
+	if (room && server) {
+		chat_name = g_strdup_printf("%s@%s", room, server);
+	}
+	return chat_name;
+}
+
 void jabber_chat_join(GaimConnection *gc, GHashTable *data)
 {
 	JabberChat *chat;
--- a/src/protocols/jabber/chat.h	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/jabber/chat.h	Tue Aug 31 01:45:12 2004 +0000
@@ -52,6 +52,7 @@
 
 GList *jabber_chat_info(GaimConnection *gc);
 GHashTable *jabber_chat_info_defaults(GaimConnection *gc, const char *chat_name);
+char *jabber_get_chat_name(GHashTable *data);
 void jabber_chat_join(GaimConnection *gc, GHashTable *data);
 JabberChat *jabber_chat_find(JabberStream *js, const char *room,
 		const char *server);
--- a/src/protocols/jabber/jabber.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/jabber/jabber.c	Tue Aug 31 01:45:12 2004 +0000
@@ -1513,6 +1513,7 @@
 	NULL,							/* warn */
 	jabber_chat_join,				/* join_chat */
 	NULL,							/* reject_chat */
+	jabber_get_chat_name,			/* get_chat_name */
 	jabber_chat_invite,				/* chat_invite */
 	jabber_chat_leave,				/* chat_leave */
 	NULL,							/* chat_whisper */
--- a/src/protocols/msn/msn.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/msn/msn.c	Tue Aug 31 01:45:12 2004 +0000
@@ -1673,6 +1673,7 @@
 	NULL,					/* warn */
 	NULL,					/* join_chat */
 	NULL,					/* reject chat invite */
+	NULL,				/* get_chat_name */
 	msn_chat_invite,		/* chat_invite */
 	msn_chat_leave,			/* chat_leave */
 	NULL,					/* chat_whisper */
--- a/src/protocols/napster/napster.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/napster/napster.c	Tue Aug 31 01:45:12 2004 +0000
@@ -161,6 +161,18 @@
 	nap_write_packet(gc, 303, "%s", buddy->name);
 }
 
+static char *nap_get_chat_name(GHashTable *data) {
+	char *name = g_hash_table_lookup(data, "group");
+	
+	/* Make sure the name has a # preceding it */
+	if (name[0] != '#') {
+		return g_strdup_printf("#%s", name);
+	}
+
+	return g_strdup(name);
+	
+}
+
 /* 400 - MSG_CLIENT_JOIN */
 static void nap_join_chat(GaimConnection *gc, GHashTable *data)
 {
@@ -169,13 +181,12 @@
 	if (!data)
 		return;
 
-	name = g_hash_table_lookup(data, "group");
+	name = nap_get_chat_name(data);
 
-	/* Make sure the name has a # preceding it */
-	if (name[0] != '#')
-		nap_write_packet(gc, 400, "#%s", name);
-	else
+	if (name) {
 		nap_write_packet(gc, 400, "%s", name);
+		g_free(name);
+	}
 }
 
 /* 401 - MSG_CLIENT_PART */
@@ -594,6 +605,7 @@
 	NULL,					/* warn */
 	nap_join_chat,			/* join_chat */
 	NULL,					/* reject chat invite */
+	nap_get_chat_name,		/* get_chat_name */
 	NULL,					/* chat_invite */
 	nap_chat_leave,			/* chat_leave */
 	NULL,					/* chat_whisper */
--- a/src/protocols/novell/novell.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/novell/novell.c	Tue Aug 31 01:45:12 2004 +0000
@@ -3424,6 +3424,7 @@
 	NULL,						/* warn */
 	NULL,						/* join_chat */
 	NULL,						/* reject_chat */
+	NULL,					/* get_chat_name */
 	novell_chat_invite,			/* chat_invite */
 	novell_chat_leave,			/* chat_leave */
 	NULL,						/* chat_whisper */
--- a/src/protocols/oscar/oscar.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/oscar/oscar.c	Tue Aug 31 01:45:12 2004 +0000
@@ -6324,6 +6324,10 @@
 	return defaults;
 }
 
+static char *oscar_get_chat_name(GHashTable *data) {
+	return g_strdup(g_hash_table_lookup(data, "room"));
+}
+
 static void oscar_join_chat(GaimConnection *gc, GHashTable *data) {
 	OscarData *od = (OscarData *)gc->proto_data;
 	aim_conn_t *cur;
@@ -7287,6 +7291,7 @@
 	oscar_warn,				/* warn */
 	oscar_join_chat,		/* join_chat */
 	NULL,					/* reject_chat */
+	oscar_get_chat_name,		/* get_chat_name */
 	oscar_chat_invite,		/* chat_invite */
 	oscar_chat_leave,		/* chat_leave */
 	NULL,					/* chat_whisper */
--- a/src/protocols/silc/chat.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/silc/chat.c	Tue Aug 31 01:45:12 2004 +0000
@@ -1016,6 +1016,11 @@
 	gaim_conv_chat_set_nick(GAIM_CONV_CHAT(convo), conn->local_entry->nickname);
 }
 
+char *silcgaim_get_chat_name(GHashTable *data)
+{
+	return g_strdup(g_hash_table_lookup(data, "channel"));
+}	
+
 void silcgaim_chat_join(GaimConnection *gc, GHashTable *data)
 {
 	SilcGaim sg = gc->proto_data;
--- a/src/protocols/silc/silc.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/silc/silc.c	Tue Aug 31 01:45:12 2004 +0000
@@ -1515,6 +1515,7 @@
 	NULL,						/* warn */
 	silcgaim_chat_join,			/* join_chat */
 	NULL,						/* reject_chat */
+	silcgaim_get_chat_name,		/* get_chat_name */
 	silcgaim_chat_invite,		/* chat_invite */
 	silcgaim_chat_leave,		/* chat_leave */
 	NULL,						/* chat_whisper */
--- a/src/protocols/silc/silcgaim.h	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/silc/silcgaim.h	Tue Aug 31 01:45:12 2004 +0000
@@ -117,6 +117,7 @@
 GHashTable *silcgaim_chat_info_defaults(GaimConnection *gc, const char *chat_name);
 GList *silcgaim_chat_menu(GaimChat *);
 void silcgaim_chat_join(GaimConnection *gc, GHashTable *data);
+char *silcgaim_get_chat_name(GHashTable *data);
 void silcgaim_chat_invite(GaimConnection *gc, int id, const char *msg,
 			  const char *name);
 void silcgaim_chat_leave(GaimConnection *gc, int id);
--- a/src/protocols/toc/toc.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/toc/toc.c	Tue Aug 31 01:45:12 2004 +0000
@@ -2140,6 +2140,7 @@
 	toc_warn,				/* warn */
 	toc_join_chat,			/* join_chat */
 	NULL,					/* reject_chat */
+	NULL,				/* get_chat_name */
 	toc_chat_invite,		/* chat_invite */
 	toc_chat_leave,			/* chat_leave */
 	toc_chat_whisper,		/* chat_whisper */
--- a/src/protocols/trepia/trepia.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/trepia/trepia.c	Tue Aug 31 01:45:12 2004 +0000
@@ -1230,6 +1230,7 @@
 	NULL,	/* warn */
 	NULL,	/* join_chat */
 	NULL,	/* reject_chat */
+	NULL,	/* get_chat_name */
 	NULL,	/* chat_invite */
 	NULL,	/* chat_leave */
 	NULL,	/* chat_whisper */
--- a/src/protocols/yahoo/yahoo.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/yahoo/yahoo.c	Tue Aug 31 01:45:12 2004 +0000
@@ -3314,6 +3314,7 @@
 	NULL, /* warn */
 	yahoo_c_join,
 	NULL, /* reject chat invite */
+	yahoo_get_chat_name,
 	yahoo_c_invite,
 	yahoo_c_leave,
 	NULL, /* chat whisper */
--- a/src/protocols/yahoo/yahoochat.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/yahoo/yahoochat.c	Tue Aug 31 01:45:12 2004 +0000
@@ -1019,6 +1019,11 @@
 	return defaults;
 }
 
+char *yahoo_get_chat_name(GHashTable *data)
+{
+	return g_strdup(g_hash_table_lookup(data, "room"));
+}
+
 void yahoo_c_join(GaimConnection *gc, GHashTable *data)
 {
 	struct yahoo_data *yd;
--- a/src/protocols/yahoo/yahoochat.h	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/yahoo/yahoochat.h	Tue Aug 31 01:45:12 2004 +0000
@@ -46,6 +46,7 @@
 GList *yahoo_c_info(GaimConnection *gc);
 GHashTable *yahoo_c_info_defaults(GaimConnection *gc, const char *chat_name);
 void yahoo_c_join(GaimConnection *gc, GHashTable *data);
+char *yahoo_get_chat_name(GHashTable *data);
 void yahoo_c_invite(GaimConnection *gc, int id, const char *msg, const char *name);
 
 void yahoo_conf_leave(struct yahoo_data *yd, const char *room, const char *dn, GList *who);
--- a/src/protocols/zephyr/zephyr.c	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/protocols/zephyr/zephyr.c	Tue Aug 31 01:45:12 2004 +0000
@@ -2180,6 +2180,11 @@
 	g_free(subscribe_failed);
 }
 
+static char *zephyr_get_chat_name(GaimConnection *gc, GHashTable *data) {
+	/** XXX someone who uses zephyr should verify this */
+	return g_strdup(g_hash_table_lookup(data, "recipient"));
+}
+
 static void zephyr_join_chat(GaimConnection * gc, GHashTable * data)
 {
 	/*	ZSubscription_t sub; */
@@ -2666,6 +2671,7 @@
 	NULL,					/* warn	 -- not supported in zephyr */
 	zephyr_join_chat,			/* join_chat */
 	NULL,					/* reject_chat -- No chat invites*/
+	zephyr_get_chat_name,			/* get_chat_name */
 	NULL,					/* chat_invite -- No chat invites*/
 	zephyr_chat_leave,			/* chat_leave */
 	NULL,					/* chat_whisper -- No "whispering"*/
--- a/src/prpl.h	Mon Aug 30 23:13:28 2004 +0000
+++ b/src/prpl.h	Tue Aug 31 01:45:12 2004 +0000
@@ -255,6 +255,7 @@
 	void (*warn)(GaimConnection *, const char *who, gboolean anonymous);
 	void (*join_chat)(GaimConnection *, GHashTable *components);
 	void (*reject_chat)(GaimConnection *, GHashTable *components);
+	char *(*get_chat_name)(GHashTable *components);
 	void (*chat_invite)(GaimConnection *, int id,
 						const char *who, const char *message);
 	void (*chat_leave)(GaimConnection *, int id);
@@ -316,8 +317,8 @@
 
 /* It's not like we're going to run out of integers for this version
    number, but we only want to really change it once per release. */
-/* GAIM_PRPL_API_VERSION last changed for version: 0.82 */
-#define GAIM_PRPL_API_VERSION 7
+/* GAIM_PRPL_API_VERSION last changed for version: 0.83 */
+#define GAIM_PRPL_API_VERSION 8 
 
 #ifdef __cplusplus
 extern "C" {