--- beagled/ThunderbirdQueryable/ThunderbirdIndexableGenerator.cs	2006-04-12 17:26:11.000000000 +0200
+++ beagled/ThunderbirdQueryable/ThunderbirdIndexableGenerator.cs	2006-04-12 17:31:56.000000000 +0200
@@ -45,9 +45,7 @@
 		private bool full_index = false;
 		private string current_mork_file = null;
 		private IEnumerator mail_enumerator = null; // used with database
-		
-		private string current_mailbox = null;
-		
+
 		private Inotify.Watch inotify_watch = null;
 		private FileSystemWatcher filesystem_watch = null;
 		
@@ -135,7 +133,7 @@
 				if (message == null)
 					message = indexer.PartialMessage (mail);
 				
-				Indexable indexable = indexer.MorkMailToIndexable (account, mail, message, current_mailbox);
+				Indexable indexable = indexer.MorkMailToIndexable (account, mail, message, GetCurrentMailbox());
 
 				return indexable;
 			} finally {
@@ -175,10 +173,8 @@
 				mail_enumerator = null;
 				return;
 			}
-				
-			// Save mailbox name
-			current_mailbox = Path.GetFileNameWithoutExtension (database.Filename);
-			Logger.Log.Debug ("Switched mailbox to " +  current_mailbox + " (" + account.Name +")");
+
+			Logger.Log.Debug ("Switched mailbox to " +  GetCurrentMailbox () + " (" + account.Name +")");
 
 			// If full_index is set to true, that means all mails are stored on the harddrive and
 			// mails are to be fully indexed
@@ -187,6 +183,34 @@
 			mail_enumerator = database.GetEnumerator ();
 		}
 		
+		public string GetCurrentMailbox ()
+		{
+			string mailbox = null;
+			
+			if (Path.GetExtension (database.Filename) != ".msf")
+				return mailbox;
+			
+			switch (account.Type) {
+			case AccountType.Pop3:
+			case AccountType.Invalid:
+				mailbox = database.Filename.Substring (account.Directory.Length+1);
+				mailbox = indexer.GetMailboxFile (mailbox);
+				break;
+			case AccountType.Imap:
+				if (Path.GetFileName (database.Filename) == "INBOX.msf")
+					mailbox = ".INBOX";
+				else {
+					mailbox = database.Filename.Substring (account.Directory.Length+1);
+					mailbox = indexer.GetMailboxFile (mailbox);
+					mailbox = "." + mailbox.Replace (".sbd/", ".");	
+				}
+				
+				break;
+			}
+			
+			return mailbox;
+		}
+		
 		public void Subscribe ()
 		{
 			if (Inotify.Enabled && inotify_watch == null) {			
@@ -263,14 +287,12 @@
 						string srcpath,
 						Inotify.EventType type)
 		{
-			if (full_index)
-				CheckEvent (Path.Combine (path, subItem));
+			CheckEvent (Path.Combine (path, subItem));
 		}
 		
 		private void OnFileSystemWatcher (object o, FileSystemEventArgs args)
 		{
-			if (full_index)
-				CheckEvent (args.FullPath);
+			CheckEvent (args.FullPath);
 		}
 
 		public string StatusName {
@@ -278,3 +300,4 @@
 		}
 	}
 }
+

--- beagled/ThunderbirdQueryable/ThunderbirdIndexer.cs	2006-04-12 17:26:11.000000000 +0200
+++ beagled/ThunderbirdQueryable/ThunderbirdIndexer.cs	2006-04-12 17:32:02.000000000 +0200
@@ -112,25 +112,24 @@
 			task.Tag = tag;
 			queryable.ThisScheduler.Add (task);
 		}
-		
-		// FIXME: Fix imap uri scheme
+
 		public static Uri NewMailUri (ThunderbirdAccount account, string mailbox, string id)
 		{
-			string uri_string = string.Empty;
+			Uri uri = null;
 			
 			switch (account.Type) {
 				case AccountType.Pop3:
 				case AccountType.Invalid:
-					uri_string ="mailbox://" + account.Directory + "/" + 
-						mailbox + "?number=" + Convert.ToInt32 (id, 16);
+					uri = new Uri ("mailbox://" + account.Directory + "/" + 
+						mailbox + "?number=" + Convert.ToInt32 (id, 16), true);
 					break;
 				case AccountType.Imap:
-					uri_string = "imap://" + account.Name + ":" + account.Port +
-						"/fetch>EUID>" + mailbox + @">" + Convert.ToInt32 (id, 16);
+					uri = new Uri ("imap://" + account.Name + ":" + account.Port +
+						@"/fetch%3EUID%3E" + mailbox + @"%3E" + Convert.ToInt32 (id, 16));
 					break;
 			}
 
-			return new Uri (uri_string);
+			return uri;
 		}
 		
 		// Partially stolen from the Evolution backend
@@ -203,3 +202,4 @@
 		}
 	}
 }
+

--- search/Tiles/MailAttachment.cs	2006-04-12 17:25:45.000000000 +0200
+++ search/Tiles/MailAttachment.cs	2006-04-12 17:39:20.000000000 +0200
@@ -64,19 +64,32 @@
 			else
 				return hit ["parent:" + name];
 		}
+		
+		public static string GetCommand(string client)
+		{
+			string command = null;
+			
+			if (client == "evolution")
+				command = "evolution";
+			else if (client == "thunderbird")
+				command = "thunderbird-bin";
+			
+			return command;
+		}
 
 		public override void Open ()
 		{
 			string uri_str;
+			string command = GetCommand (GetHitProperty (Hit, "fixme:client"));
 
-			if (GetHitProperty (Hit, "fixme:client") != "evolution") {
+			if (command == null) {
 				OpenFromMime (Hit);
 				return;
 			}
 
 			Process p = new Process ();
 			p.StartInfo.UseShellExecute = false;
-			p.StartInfo.FileName = "evolution";
+			p.StartInfo.FileName = command;
 
 			if (Hit.ParentUriAsString != null)
 				uri_str = Hit.ParentUriAsString;

--- search/Tiles/MailMessage.cs	2006-04-12 17:26:11.000000000 +0200
+++ search/Tiles/MailMessage.cs	2006-04-12 17:39:20.000000000 +0200
@@ -102,7 +102,7 @@
 			if (client == "evolution")
 				command = "evolution";
 			else if (client == "thunderbird")
-				command = "thunderbird";
+				command = "thunderbird-bin";
 			
 			return command;
 		}
@@ -137,8 +137,7 @@
 
 		public void SendInMail ()
 		{
-			string command = GetCommand (Hit.GetFirstProperty ("fixme:client"));
-			if (command == null)
+			if (Hit.GetFirstProperty ("fixme:client") != "evolution")
 				return;
 			
 			Process p = new Process ();
