From: <ro...@us...> - 2006-07-25 04:26:41
|
Revision: 16569 Author: roast Date: 2006-07-24 21:26:31 -0700 (Mon, 24 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16569&view=rev Log Message: ----------- accountformatted written. senderformatted in place, not done. Modified Paths: -------------- branches/soc-2006-file-loggers/src/log.c Modified: branches/soc-2006-file-loggers/src/log.c =================================================================== --- branches/soc-2006-file-loggers/src/log.c 2006-07-25 04:08:19 UTC (rev 16568) +++ branches/soc-2006-file-loggers/src/log.c 2006-07-25 04:26:31 UTC (rev 16569) @@ -1018,6 +1018,10 @@ GIOStatus iostat; GError *gerror = NULL; + char *from_normed = g_strdup(gaim_normalize(log->account, from)); + gboolean from_is_normed = (g_ascii_strcasecmp(from, from_normed) == 0); + char *from_suffix = g_strconcat(from_normed, "\" senderformatted=\"", NULL); + writebuf = g_string_new(""); /* This log is new. We could use the loggers 'new' function, but @@ -1027,6 +1031,11 @@ if (!log->logger_data) { const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO(plugin)->list_icon(log->account, NULL); + /* this is not thread-safe at all */ + char *account_normed = g_strdup(gaim_normalize(log->account, gaim_account_get_username(log->account))); + gboolean account_is_normed = (g_ascii_strcasecmp(gaim_account_get_username(log->account), account_normed)); + char *account_suffix = g_strconcat(account_suffix, "\" accountformatted=\"", NULL); + gaim_log_common_writer(log, ".chatlog"); data = log->logger_data; @@ -1037,10 +1046,11 @@ g_string_printf(writebuf, "%c%c%c" "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" - "<chat service=\"%s\" account=\"%s\" version=\"0.3.1-04\"%s>\n" + "<chat xmlns=\"http://purl.org/net/ulf/ns/0.4-02\" service=\"%s\" account=\"%s%s\"%s>\n" "\t<event time=\"%s\" type=\"logStart\" />\n", - 0xEF, 0xBB, 0xBF, - prpl, gaim_account_get_username(log->account), + 0xEF, 0xBB, 0xBF, prpl, + account_is_normed ? "" : account_suffix, + gaim_account_get_username(log->account), log->type == GAIM_LOG_SYSTEM ? "gaim:logtype=\"system\"" : "", date); iostat = g_io_channel_write_chars(data->channel, writebuf->str, -1, &written_buf, &gerror); @@ -1050,6 +1060,9 @@ gerror = NULL; } else written += written_buf; + + g_free(account_normed); + g_free(account_suffix); } /* if we can't write to the file, give up before we hurt ourselves */ @@ -1076,12 +1089,10 @@ else if (type & GAIM_MESSAGE_AUTO_RESP && (type & GAIM_MESSAGE_SEND || type & GAIM_MESSAGE_RECV)) { gboolean recv_from_self = FALSE; if (type & GAIM_MESSAGE_RECV) { - char *from_normed = g_strdup(gaim_normalize(log->account, from)); if (g_ascii_strncasecmp(from_normed, gaim_normalize(log->account, gaim_account_get_username(log->account)), strlen(from)) == 0) { recv_from_self = TRUE; - g_free(from_normed); } } @@ -1092,12 +1103,10 @@ else if (type & GAIM_MESSAGE_SEND || type & GAIM_MESSAGE_RECV) { gboolean recv_from_self = FALSE; if (type & GAIM_MESSAGE_RECV) { - char *from_normed = g_strdup(gaim_normalize(log->account, from)); if (g_ascii_strncasecmp(from_normed, gaim_normalize(log->account, gaim_account_get_username(log->account)), strlen(from)) == 0) { recv_from_self = TRUE; - g_free(from_normed); } } @@ -1148,6 +1157,8 @@ gerror = NULL; } + g_free(from_normed); + g_free(from_suffix); g_string_free(writebuf, TRUE); return written; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2006-07-26 03:01:35
|
Revision: 16575 Author: roast Date: 2006-07-25 20:01:27 -0700 (Tue, 25 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16575&view=rev Log Message: ----------- accountformatted and senderformatted done. Modified Paths: -------------- branches/soc-2006-file-loggers/src/log.c Modified: branches/soc-2006-file-loggers/src/log.c =================================================================== --- branches/soc-2006-file-loggers/src/log.c 2006-07-25 17:46:58 UTC (rev 16574) +++ branches/soc-2006-file-loggers/src/log.c 2006-07-26 03:01:27 UTC (rev 16575) @@ -1019,8 +1019,14 @@ GError *gerror = NULL; char *from_normed = g_strdup(gaim_normalize(log->account, from)); - gboolean from_is_normed = (g_ascii_strcasecmp(from, from_normed) == 0); - char *from_suffix = g_strconcat(from_normed, "\" senderformatted=\"", NULL); + char *from_attributes; + if (strncmp(from, from_normed, strlen(from)) == 0) { + // if from is already normalized; leave senderformatted out + from_attributes = g_strconcat(" sender=\"", from_normed, "\"", NULL); + } else { + // from is NOT normalized; specifying senderformatted + from_attributes = g_strconcat(" sender=\"", from_normed, "\" senderformatted=\"", from, "\"", NULL); + } writebuf = g_string_new(""); @@ -1031,10 +1037,17 @@ if (!log->logger_data) { const char *prpl = GAIM_PLUGIN_PROTOCOL_INFO(plugin)->list_icon(log->account, NULL); - /* this is not thread-safe at all */ char *account_normed = g_strdup(gaim_normalize(log->account, gaim_account_get_username(log->account))); - gboolean account_is_normed = (g_ascii_strcasecmp(gaim_account_get_username(log->account), account_normed)); - char *account_suffix = g_strconcat(account_suffix, "\" accountformatted=\"", NULL); + char *account_attributes; + if (strncmp(gaim_account_get_username(log->account), account_normed, strlen(account_normed)) == 0) { + // if account is already normalized + account_attributes = g_strconcat(" account=\"", account_normed, "\"", NULL); + } else { + // account is NOT normalized; specifying accountformatted + account_attributes = g_strconcat(" account=\"", account_normed, + "\" accountformatted=\"", + gaim_account_get_username(log->account), "\"", NULL); + } gaim_log_common_writer(log, ".chatlog"); @@ -1046,12 +1059,11 @@ g_string_printf(writebuf, "%c%c%c" "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" - "<chat xmlns=\"http://purl.org/net/ulf/ns/0.4-02\" service=\"%s\" account=\"%s%s\"%s>\n" + "<chat xmlns=\"http://purl.org/net/ulf/ns/0.4-02\" service=\"%s\"%s%s>\n" "\t<event time=\"%s\" type=\"logStart\" />\n", 0xEF, 0xBB, 0xBF, prpl, - account_is_normed ? "" : account_suffix, - gaim_account_get_username(log->account), - log->type == GAIM_LOG_SYSTEM ? "gaim:logtype=\"system\"" : "", date); + account_attributes, + log->type == GAIM_LOG_SYSTEM ? " gaim:logtype=\"system\"" : "", date); iostat = g_io_channel_write_chars(data->channel, writebuf->str, -1, &written_buf, &gerror); if (iostat == G_IO_STATUS_ERROR) { @@ -1062,7 +1074,7 @@ else written += written_buf; g_free(account_normed); - g_free(account_suffix); + g_free(account_attributes); } /* if we can't write to the file, give up before we hurt ourselves */ @@ -1072,19 +1084,19 @@ gaim_markup_html_to_xhtml(message, &msg_fixed, NULL); if (log->type == GAIM_LOG_SYSTEM) { - g_string_printf(writebuf, "\t<event time=\"%s\" sender=\"%s\" gaim:type=\"system\">%s</event>\n", date, from, msg_fixed); + g_string_printf(writebuf, "\t<event time=\"%s\"%s gaim:type=\"system\">%s</event>\n", date, from_attributes, msg_fixed); } else if (type & GAIM_MESSAGE_SYSTEM) { - g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\" gaim:type=\"system\">%s</message>\n", date, from, msg_fixed); + g_string_printf(writebuf, "\t<message time=\"%s\"%s gaim:type=\"system\">%s</message>\n", date, from_attributes, msg_fixed); } else if (type & GAIM_MESSAGE_ERROR) { - g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\" gaim:type=\"error\">%s</message>\n", date, from, msg_fixed); + g_string_printf(writebuf, "\t<message time=\"%s\"%s gaim:type=\"error\">%s</message>\n", date, from_attributes, msg_fixed); } else if (type & GAIM_MESSAGE_WHISPER) { - g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\" type=\"whisper\">%s</message>\n", date, from, msg_fixed); + g_string_printf(writebuf, "\t<message time=\"%s\"%s type=\"whisper\">%s</message>\n", date, from_attributes, msg_fixed); } else if (type & GAIM_MESSAGE_BELL) { - g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\" type=\"bell\">%s</message>\n", date, from, msg_fixed); + g_string_printf(writebuf, "\t<message time=\"%s\"%s type=\"bell\">%s</message>\n", date, from_attributes, msg_fixed); } else if (type & GAIM_MESSAGE_AUTO_RESP && (type & GAIM_MESSAGE_SEND || type & GAIM_MESSAGE_RECV)) { gboolean recv_from_self = FALSE; @@ -1096,8 +1108,8 @@ } } - g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\"%s%s auto=\"true\">%s</message>\n", - date, from, recv_from_self ? " self=\"true\"" : "", + g_string_printf(writebuf, "\t<message time=\"%s\"%s%s%s auto=\"true\">%s</message>\n", + date, from_attributes, recv_from_self ? " self=\"true\"" : "", gaim_message_is_action(msg_fixed, -1) ? " type=\"action\"": "", msg_fixed); } else if (type & GAIM_MESSAGE_SEND || type & GAIM_MESSAGE_RECV) { @@ -1110,13 +1122,13 @@ } } - g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\"%s%s>%s</message>\n", - date, from, recv_from_self ? " self=\"true\"" : "", + g_string_printf(writebuf, "\t<message time=\"%s\"%s%s%s>%s</message>\n", + date, from_attributes, recv_from_self ? " self=\"true\"" : "", gaim_message_is_action(msg_fixed, -1) ? " type=\"action\"": "", msg_fixed); } else { gaim_debug_error("log", "Unhandled message type."); - g_string_printf(writebuf, "\t<message time=\"%s\" sender=\"%s\">%s</message>\n", date, from, msg_fixed); + g_string_printf(writebuf, "\t<message time=\"%s\"%s>%s</message>\n", date, from_attributes, msg_fixed); } iostat = g_io_channel_write_chars(data->channel, writebuf->str, -1, &written_buf, &gerror); @@ -1158,7 +1170,7 @@ } g_free(from_normed); - g_free(from_suffix); + g_free(from_attributes); g_string_free(writebuf, TRUE); return written; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2006-07-26 04:05:18
|
Revision: 16577 Author: roast Date: 2006-07-25 20:32:31 -0700 (Tue, 25 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16577&view=rev Log Message: ----------- boolean for to choose to log original or corrected html Modified Paths: -------------- branches/soc-2006-file-loggers/src/log.c Modified: branches/soc-2006-file-loggers/src/log.c =================================================================== --- branches/soc-2006-file-loggers/src/log.c 2006-07-26 03:18:31 UTC (rev 16576) +++ branches/soc-2006-file-loggers/src/log.c 2006-07-26 03:32:31 UTC (rev 16577) @@ -565,6 +565,7 @@ gaim_prefs_add_bool("/core/logging/log_ims", FALSE); gaim_prefs_add_bool("/core/logging/log_chats", FALSE); gaim_prefs_add_bool("/core/logging/log_system", FALSE); + gaim_prefs_add_bool("/core/logging/log_corrected_html", TRUE); gaim_prefs_add_string("/core/logging/format", "txt"); @@ -1017,6 +1018,7 @@ GString *writebuf; GIOStatus iostat; GError *gerror = NULL; + gboolean log_corrected_html = gaim_prefs_get_bool("/core/logging/log_corrected_html"); char *from_normed = g_strdup(gaim_normalize(log->account, from)); char *from_attributes; @@ -1081,7 +1083,11 @@ if(!data->channel) return 0; - gaim_markup_html_to_xhtml(message, &msg_fixed, NULL); + if (log_corrected_html) { + gaim_markup_html_to_xhtml(message, &msg_fixed, NULL); + } else { + msg_fixed = (char *)message; + } if (log->type == GAIM_LOG_SYSTEM) { g_string_printf(writebuf, "\t<event time=\"%s\"%s gaim:type=\"system\">%s</event>\n", date, from_attributes, msg_fixed); @@ -1140,7 +1146,10 @@ else written += written_buf; g_free(date); - g_free(msg_fixed); + if (log_corrected_html) { + // free only if we need to free this + g_free(msg_fixed); + } // append suffix to file and seek back to keep a valid XML document out of the user space buffer g_string_printf(writebuf, @@ -1276,6 +1285,7 @@ GString *writebuf = g_string_new(""); GIOStatus iostat; GError *gerror = NULL; + gboolean log_corrected_html = gaim_prefs_get_bool("/core/logging/log_corrected_html"); if(!data) { const char *prpl = @@ -1321,7 +1331,12 @@ if(!data->channel) return 0; - gaim_markup_html_to_xhtml(message, &msg_fixed, NULL); + if (log_corrected_html) { + gaim_markup_html_to_xhtml(message, &msg_fixed, NULL); + } else { + msg_fixed = (char *)message; + } + date = log_get_timestamp(log, time); if(log->type == GAIM_LOG_SYSTEM) @@ -1358,7 +1373,10 @@ date, from, msg_fixed); } g_free(date); - g_free(msg_fixed); + if (log_corrected_html) { + // free only if we need to free this + g_free(msg_fixed); + } iostat = g_io_channel_write_chars(data->channel, writebuf->str, -1, &written_buf, &gerror); if (iostat == G_IO_STATUS_ERROR) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2006-07-26 04:05:19
|
Revision: 16576 Author: roast Date: 2006-07-25 20:18:31 -0700 (Tue, 25 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16576&view=rev Log Message: ----------- ULF 0.4-02, message.self->message.echo Modified Paths: -------------- branches/soc-2006-file-loggers/src/log.c Modified: branches/soc-2006-file-loggers/src/log.c =================================================================== --- branches/soc-2006-file-loggers/src/log.c 2006-07-26 03:01:27 UTC (rev 16575) +++ branches/soc-2006-file-loggers/src/log.c 2006-07-26 03:18:31 UTC (rev 16576) @@ -1109,7 +1109,7 @@ } g_string_printf(writebuf, "\t<message time=\"%s\"%s%s%s auto=\"true\">%s</message>\n", - date, from_attributes, recv_from_self ? " self=\"true\"" : "", + date, from_attributes, recv_from_self ? " echo=\"true\"" : "", gaim_message_is_action(msg_fixed, -1) ? " type=\"action\"": "", msg_fixed); } else if (type & GAIM_MESSAGE_SEND || type & GAIM_MESSAGE_RECV) { @@ -1123,7 +1123,7 @@ } g_string_printf(writebuf, "\t<message time=\"%s\"%s%s%s>%s</message>\n", - date, from_attributes, recv_from_self ? " self=\"true\"" : "", + date, from_attributes, recv_from_self ? " echo=\"true\"" : "", gaim_message_is_action(msg_fixed, -1) ? " type=\"action\"": "", msg_fixed); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ro...@us...> - 2006-08-22 16:42:21
|
Revision: 16980 Author: roast Date: 2006-08-22 09:42:14 -0700 (Tue, 22 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16980&view=rev Log Message: ----------- the beginnings of a purely signal-driven logging subsystem Modified Paths: -------------- branches/soc-2006-file-loggers/src/log.c Modified: branches/soc-2006-file-loggers/src/log.c =================================================================== --- branches/soc-2006-file-loggers/src/log.c 2006-08-22 16:13:43 UTC (rev 16979) +++ branches/soc-2006-file-loggers/src/log.c 2006-08-22 16:42:14 UTC (rev 16980) @@ -82,6 +82,11 @@ static char *txt_logger_read(GaimLog *log, GaimLogReadFlags *flags); static int txt_logger_total_size(GaimLogType type, const char *name, GaimAccount *account); +static void log_buddy_signed_on_cb(GaimBuddy *buddy); +static void log_buddy_signed_off_cb(GaimBuddy *buddy); +static void log_buddy_status_changed_cb(GaimBuddy *buddy, GaimStatus *old_status, GaimStatus *new_status); +static void log_buddy_idle_changed_cb(GaimBuddy *buddy, gboolean old_idle, gboolean new_idle); + static GaimActionData supported_actions[] = { { GAIM_ACTION_UNSET_ACTION, GAIM_ACTION_UNSET_ACTION, FALSE, NULL}, { GAIM_ACTION_UNSET_STATUS, GAIM_ACTION_UNSET_STATUS, FALSE, NULL}, @@ -701,7 +706,8 @@ void gaim_log_init(void) { - void *handle = gaim_log_get_handle(); + void *log_handle = gaim_log_get_handle(); + void *blist_handle = gaim_blist_get_handle(); gaim_prefs_add_none("/core/logging"); gaim_prefs_add_bool("/core/logging/log_ims", FALSE); @@ -758,7 +764,7 @@ old_logger_get_log_sets); gaim_log_logger_add(old_logger); - gaim_signal_register(handle, "log-timestamp", + gaim_signal_register(log_handle, "log-timestamp", #if SIZEOF_TIME_T == 4 gaim_marshal_POINTER__POINTER_INT, #elif SIZEOF_TIME_T == 8 @@ -784,6 +790,17 @@ logsize_users = g_hash_table_new_full((GHashFunc)_gaim_logsize_user_hash, (GEqualFunc)_gaim_logsize_user_equal, (GDestroyNotify)_gaim_logsize_user_free_key, NULL); + + // connect to some of our signals + // eventually can rewrite the whole logging structure to use only signals + gaim_signal_connect(blist_handle, "buddy-signed-on", log_handle, + GAIM_CALLBACK(log_buddy_signed_on_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-signed-off", log_handle, + GAIM_CALLBACK(log_buddy_signed_off_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-status-changed", log_handle, + GAIM_CALLBACK(log_buddy_status_changed_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-idle-changed", log_handle, + GAIM_CALLBACK(log_buddy_idle_changed_cb), NULL); } void @@ -1346,6 +1363,8 @@ GaimLogCommonLoggerData *data = log->logger_data; GIOStatus iostat; GError *gerror = NULL; + gboolean is_event = FALSE; /* if true, action is event. else, status */ + int i = 0; gsize written = 0; GString *writebuf = g_string_new(""); @@ -1380,13 +1399,24 @@ return 0; } + // is this action an event or status? + if (action > GAIM_ACTION_UNSET_STATUS && + action < GAIM_ACTION_UNSET_EVENT) { + is_event = FALSE; + } + else { + is_event = TRUE; + } + // create the log action if (tagdata != NULL && strlen(tagdata) > 0) { - g_string_printf(writebuf, "\t<event time=\"%s\"%s type=\"%s\">%s</event>\n", date, from_attributes, + g_string_printf(writebuf, "\t<%s time=\"%s\"%s type=\"%s\">%s</event>\n", + is_event ? "event" : "status", date, from_attributes, gaim_log_action_ulf_value(action), tagdata); } else { - g_string_printf(writebuf, "\t<event time=\"%s\"%s type=\"%s\" />\n", date, from_attributes, + g_string_printf(writebuf, "\t<%s time=\"%s\"%s type=\"%s\" />\n", + is_event ? "event" : "status", date, from_attributes, gaim_log_action_ulf_value(action)); } @@ -2321,3 +2351,101 @@ gaim_stringref_unref(data->pathref); g_slice_free(struct old_logger_data, data); } + +/* log_buddy_signed_(on|off)_cb shows that the xml_logger_write's don't get sender,senderformatted,alias,handle correct */ +static void log_buddy_signed_on_cb(GaimBuddy *buddy) { + GaimConversation *conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, buddy->account); + const char *alias = NULL; + GList *log = NULL; + + if (conv == NULL) return; + + if (buddy->alias != NULL) + alias = buddy->alias; + else if (buddy->server_alias != NULL) + alias = buddy->server_alias; + else + alias = buddy->name; + + log = conv->logs; + while (log != NULL) { + gaim_log_write_action((GaimLog *)log->data, GAIM_ACTION_STATUS_ONLINE, + alias, gaim_presence_get_login_time(buddy->presence), NULL); + log = log->next; + } +} + +static void log_buddy_signed_off_cb(GaimBuddy *buddy) { + GaimConversation *conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, buddy->account); + const char *alias = NULL; + GList *log; + + if (conv == NULL) return; + + if (buddy->alias != NULL) + alias = buddy->alias; + else if (buddy->server_alias != NULL) + alias = buddy->server_alias; + else + alias = buddy->name; + + log = conv->logs; + while (log != NULL) { + gaim_log_write_action((GaimLog *)log->data, GAIM_ACTION_STATUS_OFFLINE, + alias, time(NULL), NULL); + log = log->next; + } + +} + +/* create a gaim_log_write(_action)() call after figuring out which GaimLogs need to be written to */ +static void log_buddy_status_changed_cb(GaimBuddy *buddy, GaimStatus *old_status, GaimStatus *new_status) { + GaimConversation *conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, buddy->account); + const char *alias = NULL; + GList *log; + + if (conv == NULL) return; + + if (buddy->alias != NULL) + alias = buddy->alias; + else if (buddy->server_alias != NULL) + alias = buddy->server_alias; + else + alias = buddy->name; + + log = conv->logs; + while (log != NULL) { + log = log->next; + } +/* + gaim_debug_info("log-cb", "buddy-status-changed: buddy \"%s\" changed from \"%s\" to \"%s\"\n", + buddy->name, + gaim_status_get_name(old_status), + gaim_status_get_name(new_status)); +*/ +} + +/* create a gaim_log_write(_action)() call after figuring out which GaimLogs need to be written to */ +static void log_buddy_idle_changed_cb(GaimBuddy *buddy, gboolean old_idle, gboolean new_idle) { + GaimConversation *conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, buddy->name, buddy->account); + const char *alias = NULL; + GList *log; + + if (conv == NULL) return; + + if (buddy->alias != NULL) + alias = buddy->alias; + else if (buddy->server_alias != NULL) + alias = buddy->server_alias; + else + alias = buddy->name; + + log = conv->logs; + while (log != NULL) { + log = log->next; + } +/* + gaim_debug_info("log-cb", "buddy-idle-changed: buddy \"%s\" changed from \"%s\" to \"%s\", since %d\n", buddy->name, old_idle, new_idle, + gaim_presence_get_idle_time(buddy->presence)); +*/ +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |