changeset 7440:8c0527c91a92

[gaim-migrate @ 8045] this is all more better, but i forget what it all is. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Wed, 05 Nov 2003 23:43:53 +0000
parents 3a51b301a805
children 4304bb369240
files plugins/history.c src/gtkconv.c src/gtklog.c src/log.c src/log.h
diffstat 5 files changed, 97 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/history.c	Wed Nov 05 22:46:44 2003 +0000
+++ b/plugins/history.c	Wed Nov 05 23:43:53 2003 +0000
@@ -21,12 +21,13 @@
 static void historize(GaimConversation *c)
 {
 	GaimGtkConversation *gtkconv;
-	const char *name = gaim_conversation_get_name(c);
 	char *history = NULL;
-	int flags;
+	guint flags;
 	GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS;
 	GtkTextIter end;
-	GList *logs = gaim_log_get_logs(gaim_conversation_get_name(c), gaim_conversation_get_account(c));
+	GList *logs = gaim_log_get_logs(gaim_conversation_get_name(c),
+			gaim_conversation_get_account(c));
+
 	if (!logs)
 		return;
 	history = gaim_log_read((GaimLog*)logs->data, &flags);
--- a/src/gtkconv.c	Wed Nov 05 22:46:44 2003 +0000
+++ b/src/gtkconv.c	Wed Nov 05 23:43:53 2003 +0000
@@ -4506,7 +4506,7 @@
 	int gtk_font_options = 0;
 	GString *log_str;
 	GSList *images = NULL;
-       	char buf[BUF_LONG];
+	char buf[BUF_LONG];
 	char buf2[BUF_LONG];
 	char mdate[64];
 	char color[10];
@@ -4540,7 +4540,7 @@
 
 	if(gc)
 		sml_attrib = g_strdup_printf("sml=\"%s\"", gc->prpl->info->name);
-	
+
 	gtk_font_options ^= GTK_IMHTML_NO_COMMENTS;
 
 	if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_colors"))
@@ -4554,10 +4554,9 @@
 
 	if (!gaim_prefs_get_bool("/gaim/gtk/logging/strip_html"))
 		gtk_font_options ^= GTK_IMHTML_RETURN_LOG;
-	
+
 	if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol(conv->account)))->options &
 	    OPT_PROTO_USE_POINTSIZE) {
-		
 		gtk_font_options ^= GTK_IMHTML_USE_POINTSIZE;
 	}
 
@@ -4567,39 +4566,39 @@
 				   mdate, message);
 		else
 			g_snprintf(buf, BUF_LONG, "<B>%s</B>", message);
-		
+
 		g_snprintf(buf2, sizeof(buf2),
 			   "<!--(%s) --><B>%s</B><BR>",
 			   mdate, message);
-		
+
 		gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), buf2, 0, images);
-		
+
 		if (gaim_prefs_get_bool("/gaim/gtk/logging/strip_html")) {
 			char *t1 = gaim_markup_strip_html(buf);
-			
+
 			conv->history = g_string_append(conv->history, t1);
 			conv->history = g_string_append(conv->history, "\n");
-			
+
 			g_free(t1);
 		}
 		else {
 			conv->history = g_string_append(conv->history, buf);
 			conv->history = g_string_append(conv->history, "<BR>\n");
 		}
-		
+
 	} else if (flags & GAIM_MESSAGE_NO_LOG) {
 		g_snprintf(buf, BUF_LONG,
 			   "<B><FONT COLOR=\"#777777\">%s</FONT></B><BR>",
 			   message);
-		
+
 		gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), buf, 0, images);
 	}
 	else {
 		char *new_message = g_memdup(message, length);
-		
+
 		if (flags & GAIM_MESSAGE_WHISPER) {
 			str = g_malloc(1024);
-			
+
 			/* If we're whispering, it's not an autoresponse. */
 			if (meify(new_message, length)) {
 				g_snprintf(str, 1024, "***%s", who);
@@ -4609,16 +4608,16 @@
 				g_snprintf(str, 1024, "*%s*:", who);
 				strcpy(color, "#00FF00");
 			}
-		} 
+		}
 		else {
 			if (meify(new_message, length)) {
 				str = g_malloc(1024);
-				
+
 				if (flags & GAIM_MESSAGE_AUTO_RESP)
 					g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, who);
 				else
 					g_snprintf(str, 1024, "***%s", who);
-				
+
 				if (flags & GAIM_MESSAGE_NICK)
 					strcpy(color, "#AF7F00");
 				else
@@ -4636,12 +4635,12 @@
 					if (flags & GAIM_MESSAGE_COLORIZE) {
 						const char *u;
 						int m = 0;
-						
+
 						for (u = who; *u != '\0'; u++)
 							m += *u;
-						
+
 						m = m % NUM_NICK_COLORS;
-						
+
 						strcpy(color, nick_colors[m]);
 					}
 					else
@@ -4651,7 +4650,7 @@
 					strcpy(color, "#16569E");
 			}
 		}
-		
+
 		if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps"))
 			g_snprintf(buf, BUF_LONG,
 				   "<FONT COLOR=\"%s\" %s>(%s) "
@@ -4661,12 +4660,12 @@
 			g_snprintf(buf, BUF_LONG,
 				   "<FONT COLOR=\"%s\" %s><B>%s</B></FONT> ", color,
 				   sml_attrib ? sml_attrib : "", str);
-		
+
 		g_snprintf(buf2, BUF_LONG,
 			   "<FONT COLOR=\"%s\" %s><!--(%s) -->"
 			   "<B>%s</B></FONT> ",
 			   color, sml_attrib ? sml_attrib : "", mdate, str);
-		
+
 		g_free(str);
 
 		gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml), buf2, 0, images);
@@ -4676,33 +4675,34 @@
 			char *post = "</font>";
 			int pre_len = strlen(pre);
 			int post_len = strlen(post);
-			
+
 			with_font_tag = g_malloc(length + pre_len + post_len + 1);
-			
+
 			strcpy(with_font_tag, pre);
 			memcpy(with_font_tag + pre_len, new_message, length);
 			strcpy(with_font_tag + pre_len + length, post);
-			
+
 			length += pre_len + post_len;
 			g_free(pre);
 		}
 		else
 			with_font_tag = g_memdup(new_message, length);
-		
+
 		log_str = gtk_imhtml_append_text_with_images(GTK_IMHTML(gtkconv->imhtml),
 							 with_font_tag, gtk_font_options, images);
-		
+
 		gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0);
-		
+
 		/*conv->history = g_string_append(conv->history, t1);
 		conv->history = g_string_append(conv->history, t2);
 		conv->history = g_string_append(conv->history, "\n");
-			
+
 		g_free(t1);
 		g_free(t2); */
-	}	
-	
-	g_free(with_font_tag);
+
+		g_free(with_font_tag);
+	}
+
 
 	if(sml_attrib)
 		g_free(sml_attrib);
--- a/src/gtklog.c	Wed Nov 05 22:46:44 2003 +0000
+++ b/src/gtklog.c	Wed Nov 05 23:43:53 2003 +0000
@@ -38,17 +38,25 @@
 	GaimAccount *account;
 };
 
-static guint log_viewer_hash(const struct log_viewer_hash_t *viewer)
+static guint log_viewer_hash(gconstpointer data)
 {
+	const struct log_viewer_hash_t *viewer = data;
 	return g_str_hash(viewer->screenname) + g_str_hash(gaim_account_get_username(viewer->account));
-	
+
 }
 
-static gint log_viewer_equal(const struct log_viewer_hash_t *a, const struct log_viewer_hash_t *b)
+static gint log_viewer_equal(gconstpointer y, gconstpointer z)
 {
+	const struct log_viewer_hash_t *a, *b;
 	int ret;
-	char *normal = g_strdup(gaim_normalize(a->account, a->screenname));
-	ret = (a->account == b->account) && !strcmp(normal, gaim_normalize(b->account, b->screenname));
+	char *normal;
+
+	a = y;
+	b = z;
+
+	normal = g_strdup(gaim_normalize(a->account, a->screenname));
+	ret = (a->account == b->account) &&
+		!strcmp(normal, gaim_normalize(b->account, b->screenname));
 	g_free(normal);
 	return ret;
 }
@@ -96,7 +104,7 @@
      /* Logs are made from trees in real life. 
         This is a tree made from logs */
 {
-	char *title[64];
+	char title[64];
 	GtkTreeIter iter;
 	GList *logs = lv->logs;
 	while (logs) {
--- a/src/log.c	Wed Nov 05 22:46:44 2003 +0000
+++ b/src/log.c	Wed Nov 05 23:43:53 2003 +0000
@@ -42,8 +42,8 @@
 	log->account = account;
 	log->time = time;
 	log->logger = gaim_log_logger_get();
-	if (log->logger && log->logger->new)
-		log->logger->new(log);
+	if (log->logger && log->logger->create)
+		log->logger->create(log);
 	return log;
 }
 
@@ -99,14 +99,14 @@
 }
 
 
-GaimLogLogger *gaim_log_logger_new(void(*new)(GaimLog *),
+GaimLogLogger *gaim_log_logger_new(void(*create)(GaimLog *),
 				   void(*write)(GaimLog *, GaimMessageFlags, const char *,
 						time_t, const char *),
 				   void(*finalize)(GaimLog *), GList*(*list)(const char*, GaimAccount*),
 				   char*(*read)(GaimLog*, GaimLogReadFlags*))
 {
 	GaimLogLogger *logger = g_new0(GaimLogLogger, 1);
-	logger->new = new;
+	logger->create = create;
 	logger->write = write;
 	logger->finalize = finalize;
 	logger->list = list;
--- a/src/log.h	Wed Nov 05 22:46:44 2003 +0000
+++ b/src/log.h	Wed Nov 05 23:43:53 2003 +0000
@@ -5,7 +5,7 @@
  * gaim
  *
  * Copyright (C) 2003 Douglas E. Egan
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -56,26 +56,26 @@
 struct _GaimLogLogger {
 	char *name;               /**< The logger's name */
 	char *id;                 /**< an identifier to refer to this logger */
-	
-	/** This gets called when the log is first created.  
+
+	/** This gets called when the log is first created.
 	    I don't think this is actually needed. */
-	void(*new)(GaimLog *log);            
-	
+	void(*create)(GaimLog *log);
+
 	/** This is used to write to the log file */
-	void(*write)(GaimLog *log, 
-		     GaimMessageFlags type,  
+	void(*write)(GaimLog *log,
+		     GaimMessageFlags type,
 		     const char *from,
 		     time_t time,
 		     const char *message);
 
 	/** Called when the log is destroyed */
 	void (*finalize)(GaimLog *log);
-	
+
 	/** This function returns a sorted GList of available GaimLogs */
 	GList *(*list)(const char *name, GaimAccount *account);
-	
-	/** Given one of the logs returned by the logger's list function, this returns
-	 * the contents of the log in GtkIMHtml markup */
+
+	/** Given one of the logs returned by the logger's list function,
+	 * this returns the contents of the log in GtkIMHtml markup */
 	char *(*read)(GaimLog *log, GaimLogReadFlags *flags);
 };
 
@@ -84,12 +84,13 @@
  */
 struct _GaimLog {
 	GaimLogType type;                     /**< The type of log this is */
-	
 	char *name;                           /**< The name of this log */
-	GaimAccount *account;                 /**< The account this log is taking place on */
-	time_t time;                          /**< The time this conversation started */
-
-	GaimLogLogger *logger;                /**< The logging mechanism this log is to use */
+	GaimAccount *account;                 /**< The account this log is taking
+											   place on */
+	time_t time;                          /**< The time this conversation
+											   started */
+	GaimLogLogger *logger;                /**< The logging mechanism this log
+											   is to use */
 	void *logger_data;                    /**< Data used by the log logger */
 };
 
@@ -101,38 +102,41 @@
 	/***************************************
 	 ** LOG FUNCTIONS **********************
 	 ***************************************/
-	
+
 	/**
 	 * Creates a new log
 	 *
 	 * @param type        The type of log this is.
-	 * @param name        The name of this conversation (Screenname, chat name, etc.)
+	 * @param name        The name of this conversation (Screenname, chat name,
+	 *                    etc.)
 	 * @param account     The account the conversation is occuring on
 	 * @param time        The time this conversation started
 	 * @return            The new log
-	 */	
-	GaimLog *gaim_log_new(GaimLogType type, const char *name, GaimAccount *account, time_t time);
+	 */
+	GaimLog *gaim_log_new(GaimLogType type, const char *name,
+			GaimAccount *account, time_t time);
 
 	/**
 	 * Frees a log
 	 *
 	 * @param log         The log to destroy
-	 */ 
+	 */
 	void gaim_log_free(GaimLog *log);
-	
+
 	/**
 	 * Writes to a log file
 	 *
 	 * @param log          The log to write to
 	 * @param type         The type of message being logged
-	 * @param from         Whom this message is coming from, or NULL for system messages
+	 * @param from         Whom this message is coming from, or NULL for
+	 *                     system messages
 	 * @param time         A timestamp in UNIX time
 	 * @param message      The message to log
 	 */
 	void gaim_log_write(GaimLog *log,
-			    GaimMessageFlags type, 
-			    const char *from, 
-			    time_t time, 
+			    GaimMessageFlags type,
+			    const char *from,
+			    time_t time,
 			    const char *message);
 
 	/**
@@ -151,12 +155,12 @@
 	 * @return                    A sorted list of GaimLogs
 	 */
 	GList *gaim_log_get_logs(const char *name, GaimAccount *account);
-	
+
 
 	/******************************************
 	 ** LOGGER FUNCTIONS **********************
 	 ******************************************/
-	
+
 	/**
 	 * Creates a new logger
 	 *
@@ -164,18 +168,19 @@
 	 * @param write        The logger's write function
 	 * @return             The new logger
 	 */
-	GaimLogLogger *gaim_log_logger_new(void(*new)(GaimLog *),
+	GaimLogLogger *gaim_log_logger_new(void(*create)(GaimLog *),
 					   void(*write)(GaimLog *, GaimMessageFlags,
 							const char *, time_t, const char *),
-					   void(*finalize)(GaimLog *), GList*(*list)(const char*, GaimAccount*),
+					   void(*finalize)(GaimLog *),
+					   GList*(*list)(const char*, GaimAccount*),
 					   char*(*read)(GaimLog*, GaimLogReadFlags*));
 	/**
 	 * Frees a logger
-	 * 
+	 *
 	 * @param logger       The logger to free
 	 */
 	void gaim_log_logger_free(GaimLogLogger *logger);
-	
+
 	/**
 	 * Adds a new logger
 	 *
@@ -198,17 +203,18 @@
 	 * @param logger       The logger to set
 	 */
 	void gaim_log_logger_set (GaimLogLogger *logger);
-	
+
 	/**
-	 * 
+	 *
 	 * Returns the current logger
 	 *
 	 * @return logger      The current logger
 	 */
 	GaimLogLogger *gaim_log_logger_get (void);
-	
+
 	/**
-	 * Returns a GList containing the IDs and Names of the registered log loggers.
+	 * Returns a GList containing the IDs and Names of the registered log
+	 * loggers.
 	 *
 	 * @return The list of IDs and names.
 	 */
@@ -221,6 +227,6 @@
 #ifdef __cplusplus
 }
 #endif
-	
+
 #endif /* _GAIM_LOG_H_ */