Re: Thoughts on renderers and visualization



Hello,

I suck.  The patch is attached.

--Mark.


On Sat, 2004-05-15 at 12:00, Mark wrote:
> Hello,
> 
> I had taken Dan's patch against GaimLogBackend with the idea of getting
> it to support both the old and new gaim logging formats.  However, my
> time dried up due to finals and I never got around to it.  However,
> here's a patch that is all of his work applied to current CVS.  It
> doesn't support the old style gaim logs, but then again, I'm not sure
> how many people will be running dashboard and will also be running an
> old gaim.
> 
> --Mark.
> 
> 
> On Sat, 2004-05-15 at 10:43, Dan Willemsen wrote:
> > On Sat, 2004-05-15 at 00:41, Kevin Godby wrote:
> > 
> > > Ideas for further modifications:
> > >  - As an aside, the GaimLog backend needs some love.
> > >    The log file format (and location) has changed.  And I'd
> > >    love it to return more useful information (somehow).
> > 
> > Hello,
> > 
> > I wrote a patch for the new log format back in january or february. You
> > can find it here:
> > 
> > http://dan.willemsen.us/patches/dashboard-gaim.4.diff
> > 
> > I've tried to keep it current with CVS, but I'm not sure it is at the
> > moment. It also probably needs some work to handle some clues better,
> > such as a contact alias or screenname showing up in a textblock, etc,
> > but those are just improvements I'll work on later.
> > 
> > I'm pretty busy right now, 4 days of high school left, and 3 major
> > projects left to finish, so I can't review it again at the moment.
> > 
> > Dan Willemsen
> > 
> > _______________________________________________
> > Dashboard-hackers mailing list
> > Dashboard-hackers gnome org
> > http://mail.gnome.org/mailman/listinfo/dashboard-hackers
> 
> _______________________________________________
> Dashboard-hackers mailing list
> Dashboard-hackers gnome org
> http://mail.gnome.org/mailman/listinfo/dashboard-hackers
Index: backends/GaimLogBackend.cs
===================================================================
RCS file: /cvs/gnome/dashboard/backends/GaimLogBackend.cs,v
retrieving revision 1.44
diff -u -r1.44 GaimLogBackend.cs
--- a/backends/GaimLogBackend.cs	13 May 2004 05:25:02 -0000	1.44
+++ b/backends/GaimLogBackend.cs	15 May 2004 15:55:59 -0000
@@ -12,13 +12,22 @@
 namespace Dashboard {
 
 	class GaimLogBackend : BackendSimple {
-		private Hashtable BuddyIndexes = new Hashtable ();
+ 		private string gaim_icon_path = null;
+ 		private Hashtable ProtocolBuddies = new Hashtable();
+ 		private ArrayList Contacts = new ArrayList();
 
 		public override bool Startup ()
 		{
 			Name = "Instant Messenger Logs";
 
-			int convcount = LoadLogs ();
+ 			ProtocolBuddies.Add("oscar", new Hashtable());
+ 			ProtocolBuddies.Add("yahoo", new Hashtable());
+ 			ProtocolBuddies.Add("msn", new Hashtable());
+ 			ProtocolBuddies.Add("jabber", new Hashtable());
+
+ 			int convcount = GetBuddyLogs ();
+ 			if (!LoadContacts ())
+ 				return false;
 
 			Console.WriteLine ("Gaimlog backend loaded {0} conversations",
 					   convcount);
@@ -40,11 +49,31 @@
 		protected override ArrayList ProcessClueSimple (Clue clue)
 		{
 			ArrayList matches = new ArrayList();
+			ArrayList convs = new ArrayList();
 
 			GaimLogIndex idx;
 
 			try {
-				idx = (GaimLogIndex) BuddyIndexes [clue.Text.ToLower ()];
+				switch (clue.Type) {
+				case "aim_name":
+				case "icq_name":
+					idx = (GaimLogIndex) ((Hashtable) ProtocolBuddies ["oscar"]) [clue.Text.ToLower().Replace (" ", null)];
+					break;
+				case "yahoo_name":
+					idx = (GaimLogIndex) ((Hashtable) ProtocolBuddies ["yahoo"]) [clue.Text.ToLower().Replace (" ", null)];
+					break;
+				case "msn_name":
+					idx = (GaimLogIndex) ((Hashtable) ProtocolBuddies ["msn"]) [clue.Text.ToLower().Replace (" ", null)];
+					break;
+				case "jabber_name":
+					idx = (GaimLogIndex) ((Hashtable) ProtocolBuddies ["jabber"]) [clue.Text.ToLower().Replace (" ", null)];
+					break;
+				case "keyword":
+				case "word_at_point":
+				case "textblock":
+				default:
+					return null;
+				}
 			} catch {
 				Console.WriteLine ("Could not get buddy index for {0}", clue.Text);
 				return null;
@@ -53,21 +82,42 @@
 			if (idx == null)
 				return null;
 
-			idx.UpdateIndex ();
+ 			foreach (ArrayList arr in Contacts) {
+ 				if (arr.Contains (idx)) {
+ 					foreach (GaimLogIndex indx in arr) {
+ 						indx.LoadIndex ();
+ 						indx.UpdateIndex ();
+ 
+ 						for (int i = 0; i < 5 && i < indx.Conversations.Count; i++) {
+ 							GaimLogIndexEntry conv = (GaimLogIndexEntry) indx.Conversations[i];
+ 							conv.url = indx.GetConvFilePath(i);
+ 							convs.Add (conv);
+ 						}
+ 
+ 						indx.CloseIndex ();
+ 					}
+ 					break;
+ 				}
+ 			}
+ 			
+ 			if (convs.Count < 1)
+ 				return null;
+ 			
+ 			convs.Sort (new GaimLogIndexEntryComparer ());
 
 			// Generate matches
-			Hashtable BuddyProperties = GetPropertiesOfBuddy (idx.Buddyname);
+			Hashtable BuddyProperties = GetPropertiesOfBuddy (idx.Buddy);
 			string name = (string)BuddyProperties["alias"];
 			string icon = (string)BuddyProperties["icon"];
 
-			for (int i = 0; i < idx.Convs.Count && i < 5; i++) {
-				Match match = new Match ("IMLog", clue);
-
-				match ["Icon"]  = icon;
-				match ["Alias"] = name;
-				match ["Date"]  = ((GaimLogIndexEntry) idx.Convs [i]).Date;
-				match ["URL"]   = "file://" + GenerateTmpFile (idx, i);
-				match ["Title"] = String.Format ("IM Log for {0} at {1}", name, match ["date"]);
+ 			for (int i = 0; i < convs.Count && i < 5; i++) {
+  				Match match = new Match ("IMLog", clue);
+  
+ 				match ["Icon"]  = icon;
+ 				match ["Alias"] = name;
+ 				match ["Date"]  = ((GaimLogIndexEntry) convs [i]).When;
+ 				match ["Url"]   = ((GaimLogIndexEntry) convs [i]).url;
+ 				match ["Title"] = String.Format ("IM Log for {0} at {1}", name, match ["Date"]);
 
 				matches.Add (match);
 			}
@@ -75,8 +125,6 @@
 			return matches;
 		}
 
-		private string gaim_icon_path = null;
-
 		private string GetGaimIcon ()
 		{
 			if (gaim_icon_path != null)
@@ -87,50 +135,113 @@
 			int basesize = 0;
 
 			theme.AllowSvg = true;
-			
+
 			gaim_icon_path = theme.LookupIcon ("gaim", 64, icondata, out basesize);
 
 			return gaim_icon_path;
 		}
 
-		private ArrayList GetBuddyList ()
+		private int GetBuddyLogs ()
 		{
-			ArrayList Buddys = new ArrayList ();
-
 			string home_dir = Environment.GetEnvironmentVariable ("HOME");
 			string path = Path.Combine (home_dir, ".gaim/logs/");
-
-			string [] buddys;
+			DirectoryInfo log_folder = new DirectoryInfo(path);
+			int count = 0;
 
 			try {
-				buddys = Directory.GetFiles (path, "*.log");
+				DirectoryInfo[] services = log_folder.GetDirectories ();
+				foreach (DirectoryInfo service in services){
+					DirectoryInfo[] accounts = service.GetDirectories ();
+					Hashtable buddytbl;
+					
+					switch (service.Name) {
+					case "aim":
+					case "icq":
+						buddytbl = (Hashtable) ProtocolBuddies ["oscar"];
+						break;
+					case "msn":
+						buddytbl = (Hashtable) ProtocolBuddies ["msn"];
+						break;
+					case "yahoo":
+						buddytbl = (Hashtable) ProtocolBuddies ["yahoo"];
+						break;
+					case "jabber":
+						buddytbl = (Hashtable) ProtocolBuddies ["jabber"];
+						break;
+					default:
+						continue;
+					}
+					
+					foreach (DirectoryInfo account in accounts){
+						DirectoryInfo[] buddylist = account.GetDirectories ();
+						foreach (DirectoryInfo buddy in buddylist){							
+							if (!buddytbl.ContainsKey (buddy.Name)) {
+								GaimLogIndex idx = new GaimLogIndex (service.Name, buddy.Name);
+								idx.LoadIndex ();
+								idx.UpdateIndex ();
+								count += idx.Conversations.Count;
+								idx.CloseIndex ();
+								buddytbl.Add (buddy.Name,idx);
+							}
+						}
+					}
+				}
 			} catch {
-				Console.WriteLine ("GaimLog backend: No gaim logs available");
-				return Buddys;  // empty
+				Console.WriteLine ("Exception getting buddy logs!!!");
 			}
 
-			foreach (string buddy in buddys) {
-				string buddy_name = buddy.Substring (path.Length, buddy.Length - path.Length);
-				buddy_name = buddy_name.Substring (0, buddy_name.LastIndexOf ('.'));
-				Buddys.Add (buddy_name);
-			}
-
-			return Buddys;
+			return count;
 		}
-
-		private int LoadLogs ()
+		
+		private bool LoadContacts ()
 		{
-			ArrayList Buddys = GetBuddyList ();
-
-			int count = 0;
-			foreach (string buddy in Buddys) {
-				GaimLogIndex idx = new GaimLogIndex (buddy);
-				idx.UpdateIndex ();
-				BuddyIndexes.Add (buddy, idx);
-				count += idx.Convs.Count;
+			string home_dir = Environment.GetEnvironmentVariable ("HOME");
+			string path = Path.Combine (home_dir, ".gaim/blist.xml");
+			
+			try {
+				XmlDocument blist = new XmlDocument ();
+				blist.Load (path);
+				
+				XmlNodeList nodes = blist.SelectNodes ("/gaim/blist/group/contact");
+				foreach (XmlNode node in nodes) {
+					ArrayList buddies = new ArrayList ();
+					XmlNodeList xmlbuddies = node.ChildNodes;
+					foreach (XmlNode xmlbuddy in xmlbuddies) {
+						GaimLogIndex buddy;
+						
+						try {
+							switch (xmlbuddy.Attributes["proto"].Value) {
+							case "prpl-oscar":
+								buddy = (GaimLogIndex) ((Hashtable) ProtocolBuddies ["oscar"]) [xmlbuddy.SelectSingleNode ("name").InnerText.ToLower ().Replace (" ", null)];
+								break;
+							case "prpl-msn":
+								buddy = (GaimLogIndex) ((Hashtable) ProtocolBuddies ["msn"]) [xmlbuddy.SelectSingleNode ("name").InnerText.ToLower ().Replace (" ", null)];
+								break;
+							case "prpl-yahoo":
+								buddy = (GaimLogIndex) ((Hashtable) ProtocolBuddies ["yahoo"]) [xmlbuddy.SelectSingleNode ("name").InnerText.ToLower ().Replace (" ", null)];
+								break;
+							case "prpl-jabber":
+								buddy = (GaimLogIndex) ((Hashtable) ProtocolBuddies ["jabber"]) [xmlbuddy.SelectSingleNode ("name").InnerText.ToLower ().Replace (" ", null)];
+								break;
+							default:
+								buddy = null;
+								break;
+							}
+			
+							if (!buddies.Contains (buddy) && buddy != null)
+								buddies.Add (buddy);
+						} catch {}
+					}
+					
+					if (buddies.Count > 0)
+						Contacts.Add (buddies);
+				}
+			} catch {
+				Console.WriteLine ("GaimLogBackend: Exception loading contact information");
+				return false;
 			}
-
-			return count;
+			
+			return true;
 		}
 
 
@@ -178,36 +289,6 @@
 			return BuddyProperties;
 		}
 
-		private string GenerateTmpFile (GaimLogIndex idx, int conv_num)
-		{
-			string home;
-			string path;
-
-			home = Environment.GetEnvironmentVariable ("HOME");
-			path = Path.Combine (home,
-					     String.Format (".dashboard/tmp/{0}-{1}.html", idx.Buddyname, conv_num));
-
-			FileStream s;
-
-			try {
-				s = File.Open (path, FileMode.Create);
-			} catch {
-				return "";
-			}
-
-			StreamWriter sw = new StreamWriter (s);
-
-			string html = Regex.Replace (idx.GetLogEntryText (conv_num), "\n", "<br>\n");
-
-			sw.WriteLine ("<html bgcolor=#ffffff><body><h2>Conversation with {0}</h2><h3>{1}</h3>",
-				      idx.Buddyname, ((GaimLogIndexEntry) idx.Convs [conv_num]).Date);
-			sw.WriteLine (html);
-			sw.WriteLine ("</body></html>");
-			sw.Flush ();
-			sw.Close ();
-
-			return path;
-		}
 	}
 
 	//
@@ -219,100 +300,41 @@
 	//
 	// IM Log indexes are stored in files with names like:
 	//
-	//        ~/.dashboard/backend-data/gaimlog/buddyname.idx
+ 	//        ~/.dashboard/backend-data/gaimlog/service.buddyname.idx
 	//
 	// They contain lines of comma-separated data in this form:
 	//
-	//        Date,StartOffset,EndOffset
-	//
-	// Where "date" is the time string for when the conversation
-	// began, "StartOffset" is the byte offset into the log for
-	// the beginning of the conversation, and "EndOffset" is the
-	// offset into the log for the end of the conversation.
-	//
-	// The last conversation in the file will have an EndOffset of
-	// -1, since more lines may be added after it is indexed.  So
-	// "-1" means "read to the end of the file."
+ 	//        Date,Account,Type
 	//
-	// This code currently assumes that gaim's .log files are in
-	// chronological order (least to most recent).
-	//
-	class GaimLogIndexEntry {
-		public string Date;
-		public long StartOffset;
-		public long EndOffset;
-	}
+  	// Where "date" is the time string for when the conversation
+ 	// began, "account" is the account used to talk, and "type"
+ 	// is the type of file, e.g. 'txt' or 'html'
+
+ 	struct GaimLogIndexEntry {
+ 		public DateTime When;
+ 		public string Account;
+ 		public string Type;
+ 		public string url; // Just for temp use, don't use
+  	}
 
-	class LogStreamReader : StreamReader {
-		public long Offset = -1;
-
-		private StreamReader sr;
-
-		public LogStreamReader (Stream s) : base(s) {
-			sr = new StreamReader (s);
-			Offset = s.Position;
-		}
-
-		public string ReadLineOff () {
-			string s;
-			try {
-				s = sr.ReadLine ();
-			} catch {
-				s = "INVALID LINE";
-			}
-			if (s == null)
-				return s;
-
-			Offset += s.Length + 1;
-
-			return s;
-		}
-	}
 	
-	class GaimLogIndex {
-
-		// The buddy with whom all these conversations took
-		// place.
-		public string Buddyname;
-
-
-		// The list of conversations.  We sort them from most
-		// recent (Convs[0]) to least recent
-		// (Convs[Convs.Count]).
-		public ArrayList Convs = new ArrayList ();
-
-		// Whether or not we have loaded the index file.
-		private bool IndexLoaded = false;
-
-		// start of conversation
-		private const string CONV_START
-			= "---- New Conversation @ ";
-
-		// regex for finding date
-		private const string REGEX_DATE
-			= "Conversation @ (\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s+\\S+)";
-
-		private Regex dateregex;
-
-		public GaimLogIndex (string buddyname)
-		{
-			Buddyname = buddyname;
-			dateregex = new Regex (REGEX_DATE,
-					RegexOptions.IgnoreCase | RegexOptions.Compiled);
-		}
+ 	class GaimLogIndex {
+ 		public bool IndexLoaded;
+  
+ 		public string Service;
+ 		public string Buddy;
+ 		public ArrayList Conversations = new ArrayList();
+  
+ 		public GaimLogIndex (string Service, string Buddy)
+  		{
+ 			this.Service = Service;
+ 			this.Buddy = Buddy;
+  		}
 
 		private string GetIndexPath ()
 		{
 			string home_dir = Environment.GetEnvironmentVariable ("HOME");
-			string path = Path.Combine (home_dir, ".dashboard/backend-data/gaimlog/" + Buddyname + ".idx");
-
-			return path;
-		}
-
-		private string GetLogPath ()
-		{
-			string home_dir = Environment.GetEnvironmentVariable ("HOME");
-			string path = Path.Combine (home_dir, ".gaim/logs/" + Buddyname + ".log");
+ 			string path = Path.Combine (home_dir, ".dashboard/backend-data/gaimlog/" + Service + "." + Buddy + ".idx");
 
 			return path;
 		}
@@ -340,7 +362,6 @@
 
 		public bool LoadIndex ()
 		{
-
 			if (IndexLoaded)
 				return true;
 
@@ -358,13 +379,15 @@
 				string [] ary = idx_line.Split (',');
 
 				GaimLogIndexEntry conv = new GaimLogIndexEntry ();
-				conv.Date        = ary [0];
-				conv.StartOffset = Int32.Parse (ary [1]);
-				conv.EndOffset   = Int32.Parse (ary [2]);
+				conv.When	= new DateTime (Int64.Parse (ary [0]));
+				conv.Account	= ary [1];
+				conv.Type	= ary [2];
 
-				Convs.Insert (0, conv);
+				Conversations.Add (conv);
 			}
 
+			Conversations.Sort (new GaimLogIndexEntryComparer ());
+
 			s.Close ();
 
 			IndexLoaded = true;
@@ -374,145 +397,84 @@
 
 		public bool IndexUpToDate ()
 		{
-
-			if (! IndexExists ())
+			if (!IndexExists ())
 				return false;
 
-			//
-			// Load the index if it hasn't been loaded.
-			//
-			LoadIndex ();
-
-			DateTime index_changed_time = File.GetLastWriteTime (GetIndexPath ());
-			DateTime log_changed_time   = File.GetLastWriteTime (GetLogPath ());
-
-			if (DateTime.Compare (log_changed_time, index_changed_time) <= 0)
-				return true;
-
-			return false;
-		}
-
-		public long GetLastConvStartIndex ()
-		{
-			if (Convs.Count == 0)
-				return 0;
-
-			return ((GaimLogIndexEntry)Convs [0]).StartOffset;
-		}
-
-		private string ExtractDateFromLine (string logline)
-		{
-			System.Text.RegularExpressions.Match m;
-			m = dateregex.Match (logline);
-			if (m.Success) 
-				return m.Groups[1].ToString ();
-			else
-				return "NO DATE";
-		}
-
-		private bool LineMarksConversationStart (string logline)
-		{
-			// FIXME: Nasty hardcoded crap
-			if (logline.IndexOf (CONV_START) >= 0) {
-				return true;
-			}
-
-			return false;
-		}
-
-		private void CreateFirstEntry (LogStreamReader logstreamr, string date)
-		{
-			if (Convs.Count != 0) {
-				Console.WriteLine ("There is already a first entry!");
-				return;
-			}
-			
-			GaimLogIndexEntry conv = new GaimLogIndexEntry ();
-
-			conv.Date        = date;
-			conv.StartOffset = logstreamr.Offset;
-			conv.EndOffset   = -1;
-
-			Convs.Insert (0, conv);
-		}
+			string home_dir = Environment.GetEnvironmentVariable ("HOME");
+			string service_dir = Path.Combine (home_dir, ".gaim/logs/" + Service);
 
-		public string SkipHeaderText (LogStreamReader logstream)
-		{
-			string logline;
+			DateTime idx_time = File.GetLastWriteTime (GetIndexPath ());
 
-			while ((logline = logstream.ReadLineOff ()) != null) {
-				if (LineMarksConversationStart (logline))
-					return ExtractDateFromLine (logline);
+			try {
+				string[] accounts = Directory.GetDirectories (service_dir);
+				foreach (string account in accounts) {
+					string[] account_dir = Directory.GetDirectories (account, Buddy);
+					if (account_dir.Length == 1) {
+						string[] logs = Directory.GetFiles (account_dir [0]);
+						foreach (string log in logs) {
+							if (Directory.GetLastWriteTime (log) > idx_time)
+								return false;
+						}
+					}
+				}
+			} catch {
+				return false;
 			}
 
-			Console.WriteLine ("Couldn't find conversation start!");
-			return "NO DATE";
+			return true;
 		}
 
 		public bool UpdateIndex ()
 		{
-
 			if (IndexUpToDate ())
 				return true;
 
-			Console.WriteLine ("GaimLog backend: Updating conversation index for {0}", Buddyname);
+			Console.WriteLine ("GaimLog backend: Updating conversation index for {0} ({1})", Buddy, Service);
+
+			Conversations.Clear ();
 
-			//
-			// Open the logfile.
-			//
-			FileStream logstream;
+			string home_dir = Environment.GetEnvironmentVariable ("HOME");
+			DirectoryInfo service_dir = new DirectoryInfo (Path.Combine (home_dir, ".gaim/logs/" + Service));
+
+			char[] splitters = {'.','-'};
 			try {
-				logstream = File.OpenRead (GetLogPath ());
+				DirectoryInfo[] accounts = service_dir.GetDirectories ();
+				foreach (DirectoryInfo account in accounts) {
+					DirectoryInfo[] account_dir = account.GetDirectories (Buddy);
+					if (account_dir.Length == 1 && account_dir[0].Exists) {
+						FileInfo[] logs = account_dir[0].GetFiles ();
+						foreach (FileInfo log in logs) {
+							string[] ary = log.Name.Split (splitters);
+							GaimLogIndexEntry conv = new GaimLogIndexEntry ();
+							conv.When = new DateTime (Int32.Parse (ary [0]),
+										  Int32.Parse (ary [1]),
+										  Int32.Parse (ary [2]),
+										  0,0,0);
+							conv.Type = ary [4];
+							conv.Account = account.Name;
+							conv.When = conv.When.AddHours (Int32.Parse (ary [3].Substring (0,2)));
+							conv.When = conv.When.AddMinutes (Int32.Parse (ary [3].Substring (2,2)));
+							conv.When = conv.When.AddSeconds (Int32.Parse (ary [3].Substring (4,2)));
+							
+							Conversations.Add (conv);
+						}
+					}
+				}
+
+				Conversations.Sort (new GaimLogIndexEntryComparer ());
 			} catch {
+				Console.WriteLine ("GaimLog backend: Exception while finding conversations for {0} ({1})", Buddy, Service);
 				return false;
 			}
 
-			//
-			// Seek to the beginning of the last conversation.
-			//
-			logstream.Seek (GetLastConvStartIndex (), SeekOrigin.Begin);
-			LogStreamReader logstreamr = new LogStreamReader (logstream);
-
-			long current_index;
-
-			//
-			// If there is no index file, we need to skip
-			// through the header text before marking the
-			// beginning of the first conversation.
-			//
-			if (! IndexExists ()) {
-				string date = SkipHeaderText (logstreamr);
-				CreateFirstEntry (logstreamr, date);
-			}
-
-			string logline;
-			while ((logline = logstreamr.ReadLineOff ()) != null) {
-				long curr_offset;
-
-				if (! LineMarksConversationStart (logline))
-					continue;
-
-				//
-				// Mark the beginning of the new conversation.
-				//
-				GaimLogIndexEntry conv = new GaimLogIndexEntry ();
-				conv.Date = ExtractDateFromLine (logline);
-				conv.StartOffset = logstreamr.Offset;
-				conv.EndOffset   = -1;
-
-				//
-				// Drop it at the front of the array.
-				//
-				Convs.Insert (0, conv);
-			}
-
-			logstream.Close ();
-
-			//
-			// Write out a new index.
-			//
 			return SaveToDisk ();
 		}
+		
+		public void CloseIndex ()
+		{
+			Conversations = new ArrayList();
+			IndexLoaded = false;
+		}
 
 		public bool CreateIndexDirectory ()
 		{
@@ -550,16 +512,12 @@
 
 			StreamWriter sw = new StreamWriter (s);
 
-			for (int i = (Convs.Count - 1); i >= 0; i --) {
-				GaimLogIndexEntry entry = (GaimLogIndexEntry) Convs [i];
-				if (i > 0) {
-					GaimLogIndexEntry nextent = (GaimLogIndexEntry) Convs [i-1];
-					entry.EndOffset = nextent.StartOffset;
-				}
+			for (int i = (Conversations.Count - 1); i >= 0; i --) {
+				GaimLogIndexEntry entry = (GaimLogIndexEntry) Conversations [i];
 				sw.WriteLine (String.Format ("{0},{1},{2}",
-							     entry.Date,
-							     entry.StartOffset,
-							     entry.EndOffset));
+							     entry.When.Ticks,
+							     entry.Account,
+							     entry.Type));
 			}
 
 			sw.Flush ();
@@ -568,51 +526,20 @@
 			return true;
 		}
 
-		public string GetLogEntryText (int entry_idx)
+		public string GetConvFilePath (int conv)
 		{
-			GaimLogIndexEntry conv;
-			Stream s;
-
-			conv = (GaimLogIndexEntry) Convs [entry_idx];
-
-			try {
-				s = File.OpenRead (GetLogPath ());
-			} catch {
-				Console.WriteLine ("Could not open log file {0} for reading", GetLogPath ());
-				return "";
-			}
-
-			long conv_length;
-			if (conv.EndOffset != -1)
-				conv_length = conv.EndOffset - conv.StartOffset;
-			else
-				conv_length = s.Length - conv.StartOffset;
-
-			byte [] conv_text = new byte [conv_length];
-
-			s.Seek (conv.StartOffset, SeekOrigin.Begin);
-			s.Read (conv_text, 0, (int) conv_length);
-
-			s.Close ();
-
-			return Encoding.Default.GetString (conv_text, 0, (int) conv_length);
+			GaimLogIndexEntry c = (GaimLogIndexEntry) Conversations [conv];
+			string home_dir = Environment.GetEnvironmentVariable ("HOME");
+			string path = Path.Combine (home_dir, ".gaim/logs/" + Service + "/" + c.Account + "/" + Buddy);
+			path = Path.Combine (path, c.When.ToString ("yyyy-MM-dd.HHmmss") + "." + c.Type);
+			return "file://" + path;
+		}
+	}
+	
+	class GaimLogIndexEntryComparer : IComparer {
+		public int Compare (object a, object b)
+		{
+			return -1 * DateTime.Compare( ((GaimLogIndexEntry) a).When, ((GaimLogIndexEntry) b).When);
 		}
 	}
-
-
-///	class Driver {
-///		static void Main (string [] args)
-///		{
-///			GaimLog g = new GaimLog ();
-///			g.Startup ();
-//			GaimLogIndex idx = new GaimLogIndex ("robflynn43");
-//
-//			idx.UpdateIndex ();
-//
-//			for (int i = 0; i < idx.Convs.Count; i ++) {
-//				Console.WriteLine ("\nEntry #{0} ({1}):", i, ((GaimLogIndexEntry) idx.Convs [i]).Date);
-//				Console.WriteLine (idx.GetLogEntryText (i));
-//			}
-//		}
-//	}
 }
Index: renderers/IMLogMatchRenderer.cs
===================================================================
RCS file: /cvs/gnome/dashboard/renderers/IMLogMatchRenderer.cs,v
retrieving revision 1.7
diff -u -r1.7 IMLogMatchRenderer.cs
--- a/renderers/IMLogMatchRenderer.cs	4 Mar 2004 07:32:54 -0000	1.7
+++ b/renderers/IMLogMatchRenderer.cs	15 May 2004 15:56:00 -0000
@@ -27,7 +27,11 @@
 				Match m1 = (Match) a;
 				Match m2 = (Match) b;
 
-				return String.Compare ((string) m1 ["Alias"], (string) m2 ["Alias"]);
+				int res = String.Compare ((string) m1 ["Alias"], (string) m2 ["Alias"]);
+				if (res != 0)
+					return res;
+				return -1 * DateTime.Compare ((DateTime) m1 ["Date"], (DateTime) m2 ["Date"]);
+
 			}
 		}
 
@@ -85,7 +89,7 @@
 					      "    </font></td>"                                                        +
 					      "</tr>",
 					      m ["Date"],
-					      m ["URL"]);
+					      m ["Url"]);
 
 			return html;
 		}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]