[Tkabber-dev] r846 - in trunk/tkabber: . plugins/chat plugins/general

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Dec 26 19:03:13 MSK 2006


Author: sergei
Date: 2006-12-26 19:03:11 +0300 (Tue, 26 Dec 2006)
New Revision: 846

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/plugins/chat/logger.tcl
   trunk/tkabber/plugins/general/message_archive.tcl
Log:
	* plugins/chat/logger.tcl, plugins/general/message_archive.tcl:
	  Specially process message_archive when converting logs. Changed
	  message archive file format to make it more reliable.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2006-12-26 14:10:17 UTC (rev 845)
+++ trunk/tkabber/ChangeLog	2006-12-26 16:03:11 UTC (rev 846)
@@ -16,6 +16,10 @@
 	  which is set to normalized name of ~/.tkabber. This should help
 	  with file operations in Windows.
 
+	* plugins/chat/logger.tcl, plugins/general/message_archive.tcl:
+	  Specially process message_archive when converting logs. Changed
+	  message archive file format to make it more reliable.
+
 2006-12-25  Sergei Golovan  <sgolovan at nes.ru>
 
 	* plugins/general/session.tcl: Renamed session to state (only in

Modified: trunk/tkabber/plugins/chat/logger.tcl
===================================================================
--- trunk/tkabber/plugins/chat/logger.tcl	2006-12-26 14:10:17 UTC (rev 845)
+++ trunk/tkabber/plugins/chat/logger.tcl	2006-12-26 16:03:11 UTC (rev 846)
@@ -731,8 +731,14 @@
 
     # Process all files in log dir itself
     foreach filepath [glob -nocomplain -type f -directory $dirfrom *] {
-	convert_root_log $t $dirfrom $dirto \
-			 [file tail $filepath] $JID([file tail $filepath])
+	if {[file tail $filepath] == "message_archive"} {
+	    convert_subdir_log $t $filepath \
+				  [file join $dirto [file tail $filepath]] \
+				  message_archive ""
+	} else {
+	    convert_root_log $t $dirfrom $dirto \
+			     [file tail $filepath] $JID([file tail $filepath])
+	}
     }
 
     # Storing version for possible future conversions

Modified: trunk/tkabber/plugins/general/message_archive.tcl
===================================================================
--- trunk/tkabber/plugins/general/message_archive.tcl	2006-12-26 14:10:17 UTC (rev 845)
+++ trunk/tkabber/plugins/general/message_archive.tcl	2006-12-26 16:03:11 UTC (rev 846)
@@ -16,6 +16,20 @@
     variable messages
 }
 
+#############################################################################
+
+proc ::message_archive::str_to_log {str} {
+    return [string map {\\ \\\\ \r \\r \n \\n} $str]
+}
+
+#############################################################################
+
+proc ::message_archive::log_to_str {str} {
+    return [string map {\\\\ \\ \\r \r \\n \n} $str]
+}
+
+#############################################################################
+
 proc ::message_archive::log_message {from to subject body x} {
     variable archive_file
 
@@ -31,7 +45,7 @@
 
     set fd [open $archive_file a]
     fconfigure $fd -encoding utf-8
-    puts $fd [list [list timestamp $ts id $ts[random 10000] from $from to $to subject $subject body $body]]
+    puts $fd [str_to_log [list timestamp $ts id $ts[random 10000] from $from to $to subject $subject body $body]]
     close $fd
 }
 
@@ -139,17 +153,17 @@
 	return
     }
 
-    set fd [open $archive_file r]
-    fconfigure $fd -encoding utf-8
-    set hist [read $fd]
-    close $fd
-
     foreach i {N timestamp dir fromto subject} {
 	$l column configure $i -width [string length [$l column cget $i -label]]
     }
-    foreach vars $hist {
-	fill_row $l $vars
+
+    set hist {}
+    set fd [open $archive_file r]
+    fconfigure $fd -encoding utf-8
+    while {[gets $fd line] > 0} {
+	catch {fill_row $l [log_to_str $line]}
     }
+    close $fd
 }
 
 proc ::message_archive::fill_row {l var} {



More information about the Tkabber-dev mailing list