Re: Imap support in util/evolution/camel.cs



On Wed, 2004-03-03 at 17:58, Nat Friedman wrote:
> On Tue, 2004-03-02 at 20:22, Erik Bågfors wrote:
> > Hi all.
> > 
> > When on a 3.5 hours flight across half of Australia, it's a perfect time
> > to hack on dashboard.
> 
> 
> Whoa!  This is a very clean patch!  I've applied the first two, but not
> the one that hardcodes IMAP in.  We'll need camel.cs to do three things
> now:
> 
>         * Autodetect IMAP/MBOX.
>         

What about the following very ugly patches? It just checks if the path
ends in "/summary", then assumes it's a imap-summary, otherwise it
thinks it's a mbox-summary??

Feel free to tell me that this is a very stupid way of doing it :)
I'm not sure I like it.  But hey, it works :)

/Erik


Index: camel.cs
===================================================================
RCS file: /cvs/gnome/dashboard/util/evolution/camel.cs,v
retrieving revision 1.2
diff -u -r1.2 camel.cs
--- camel.cs	3 Mar 2004 07:00:54 -0000	1.2
+++ camel.cs	4 Mar 2004 10:58:42 -0000
@@ -16,6 +16,18 @@
         public class Summary { 
 	    public SummaryHeader header;
 	    public MessageInfo [] messages;
+
+	    public static Summary load(string file) 
+	    {
+		Summary s;
+		if (file.EndsWith("/summary")) { // This is probably a imap summary
+		    s = new ImapSummary(file);
+		    return s;
+		} else {
+		    s = new MBoxSummary(file);
+		    return s;
+		}
+	    }
 	}
 
 	public class MBoxSummary: Summary {
@@ -317,13 +329,11 @@
 			string file;
 			
 			if (args.Length == 0)
-			//	file = "mbox.ev-summary";
 				file = "summary";
 			else
 				file = args [0];
 			
-			//Summary s = new MBoxSummary("mbox.ev-summary");
-			Summary s = new ImapSummary(file);
+			Summary s = Summary.load(file);
 			for (int i = 0; i < s.header.count; i++) {
 			    Console.WriteLine(s.messages [i]);
 			}
Index: EvolutionMailBackend.cs
===================================================================
RCS file: /cvs/gnome/dashboard/backends/EvolutionMailBackend.cs,v
retrieving revision 1.21
diff -u -r1.21 EvolutionMailBackend.cs
--- EvolutionMailBackend.cs	4 Mar 2004 07:59:33 -0000	1.21
+++ EvolutionMailBackend.cs	4 Mar 2004 11:01:09 -0000
@@ -33,7 +33,7 @@
 				return false;
 
 			try {
-				summary = new Camel.MBoxSummary (summary_path);
+				summary = Camel.Summary.load (summary_path);
 			} catch (Exception e) {
 				Console.WriteLine ("Could not load camel summary: " + summary_path + e);
 				return false;


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