beagle r4663 - in trunk/beagle: . beagled/xemail-net beagled/xemail-net/src beagled/xemail-net/upstream-patches



Author: dbera
Date: Mon Apr  7 02:35:06 2008
New Revision: 4663
URL: http://svn.gnome.org/viewvc/beagle?rev=4663&view=rev

Log:
Forgot to add the xemail files needed for the GMail backend.


Added:
   trunk/beagle/beagled/xemail-net/
   trunk/beagle/beagled/xemail-net/README
   trunk/beagle/beagled/xemail-net/src/
   trunk/beagle/beagled/xemail-net/src/AssemblyInfo.cs.in
   trunk/beagle/beagled/xemail-net/src/Attachment.cs   (contents, props changed)
   trunk/beagle/beagled/xemail-net/src/AttachmentCollections.cs   (contents, props changed)
   trunk/beagle/beagled/xemail-net/src/Flag.cs   (contents, props changed)
   trunk/beagle/beagled/xemail-net/src/FlagCollection.cs   (contents, props changed)
   trunk/beagle/beagled/xemail-net/src/HMACMD5.cs   (contents, props changed)
   trunk/beagle/beagled/xemail-net/src/ImapClient.cs   (contents, props changed)
   trunk/beagle/beagled/xemail-net/src/Mail.cs   (contents, props changed)
   trunk/beagle/beagled/xemail-net/src/MailCollection.cs   (contents, props changed)
   trunk/beagle/beagled/xemail-net/src/Mailbox.cs   (contents, props changed)
   trunk/beagle/beagled/xemail-net/src/MailboxCollection.cs   (contents, props changed)
   trunk/beagle/beagled/xemail-net/src/Makefile.am
   trunk/beagle/beagled/xemail-net/src/MessageSet.cs   (contents, props changed)
   trunk/beagle/beagled/xemail-net/src/Namespace.cs   (contents, props changed)
   trunk/beagle/beagled/xemail-net/src/Quota.cs   (contents, props changed)
   trunk/beagle/beagled/xemail-net/src/xemail.snk   (contents, props changed)
   trunk/beagle/beagled/xemail-net/upstream-patches/
   trunk/beagle/beagled/xemail-net/upstream-patches/01.patch
Modified:
   trunk/beagle/COPYING

Modified: trunk/beagle/COPYING
==============================================================================
--- trunk/beagle/COPYING	(original)
+++ trunk/beagle/COPYING	Mon Apr  7 02:35:06 2008
@@ -14,6 +14,7 @@
 	* jslib - Mozilla Public License v1.1
 	* xdgmime - Academic Free License v2.0 or GNU LGPL v2
 	* LZMA SDK - GNU LGPL v2
+	* xemail-net - GNU LGPL v2
 
 -----------------------------------------------------------------------------
 

Added: trunk/beagle/beagled/xemail-net/README
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/README	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,33 @@
+Please consider this library are unstable so do not install it in the GAC,
+
+Warning : there's many changes in version 0.2 :
+Namespace change to System.Net.Imap
+Many classes change.
+
+Unix 
+--------
+to build and install :
+sh autogen.sh
+make
+and as root:
+make install
+
+to use it in a project : `pkg-config --libs xemail-net`
+
+Windows
+----------
+i wrote a build.bat but it's never been tested !
+Let me know if it works.
+I also add a MONO define FLAG to prevent MONO Requirement but this disble SSL support.
+
+
+To consult documentation :
+monodoc --edit doc
+
+all feedbacks are welcome :)
+
+
+Note : 
+
+for Ssl connection : all are accepted.
+

Added: trunk/beagle/beagled/xemail-net/src/AssemblyInfo.cs.in
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/AssemblyInfo.cs.in	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,7 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyVersion("@VERSION@")]
+[assembly: AssemblyTitle ("xemail-net")]
+[assembly: AssemblyDescription ("xemail-net - Imap Library")]
+[assembly: AssemblyCopyright ("Copyright (c) 2005-2006 Cyrille Colin")]

Added: trunk/beagle/beagled/xemail-net/src/Attachment.cs
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/Attachment.cs	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,74 @@
+/*
+ * Attachment.cs
+ * Copyright (C) 2006 COLIN Cyrille.
+ *
+ */
+
+using System;
+using System.IO;
+using System.Text.RegularExpressions;
+using System.Collections;
+
+namespace System.Net.Imap {
+  public class Attachment {
+      private string      _header = String.Empty;
+    private byte[]      _content = new byte[0];
+    private bool      _onserver;
+    public Attachment() {}
+    public string FileName {
+         get { return GetHeader("filename=");}
+      }
+    private string Charset {
+         get { return GetHeader("charset=");}
+        }
+    private string ContentDisposition {
+         get { return GetHeader("Content-Disposition: ");}
+        }
+    public string ContentEncoding {
+         get { return GetHeader("Content-Transfer-Encoding: ");}
+        }
+    public string ContentType {
+         get { return GetHeader("Content-Type: ");}
+      }
+    public bool IsAttachment {
+      get {
+        return (ContentDisposition.ToLower() == "attachment" || ContentDisposition.ToLower() == "inline")?true:false;
+      }
+    }
+    public void Save (string path) {
+      if (File.Exists(path+this.FileName)) {
+          }
+          FileStream fs = new FileStream(path+this.FileName, FileMode.Create);
+          BinaryWriter w = new BinaryWriter(fs);
+      if(ContentEncoding == "base64") {
+              w.Write(Convert.FromBase64String(System.Text.Encoding.ASCII.GetString(_content)));
+      } else {
+        w.Write(_content);
+      }
+          w.Close();
+          fs.Close();
+    }
+    public byte[] Content {
+         set { this._content = value;}
+         get { return this._content;}
+      }
+    public string Header {
+         set { this._header = value;}
+         get { return this._header;}
+      }
+    public bool OnServer {
+         set { this._onserver = value;}
+         get { return this._onserver;}
+    }
+    private string GetHeader(string header) {
+            Match m;
+            m = Regex.Match(this._header,header+"[\"]?(.*?)[\"]?(\\r\\n|;)",RegexOptions.Multiline);
+            if(m.Groups.Count > 1) {
+                return m.Groups[1].ToString();
+            } else {
+                return String.Empty;
+            }
+        }
+
+  }
+}

Added: trunk/beagle/beagled/xemail-net/src/AttachmentCollections.cs
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/AttachmentCollections.cs	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,17 @@
+/*
+ * AttachmentCollection.cs
+ * Copyright (C) 2006 COLIN Cyrille.
+ *
+ */
+
+using System;
+using System.Collections;
+
+namespace System.Net.Imap {
+
+  public class AttachmentCollection:System.Collections.CollectionBase {
+
+
+  }
+
+}

Added: trunk/beagle/beagled/xemail-net/src/Flag.cs
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/Flag.cs	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,27 @@
+/*
+ * Flag.cs
+ * Copyright (C) 2006 COLIN Cyrille.
+ *
+ */
+
+using System;
+using System.Collections;
+
+namespace System.Net.Imap {
+
+  public class Flag {
+    string _name;
+    public Flag(){}
+
+    public Flag(string name) {
+      this._name = name;
+    }
+    public string Name {
+      get { return this._name;}
+      set {this._name = value;}
+    }
+		public override string ToString() {
+			return this._name;
+		}
+  }
+}

Added: trunk/beagle/beagled/xemail-net/src/FlagCollection.cs
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/FlagCollection.cs	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,16 @@
+/*
+ * FlagCollection.cs
+ * Copyright (C) 2006 COLIN Cyrille.
+ *
+ */
+
+using System;
+using System.Collections;
+
+namespace System.Net.Imap {
+  public class Flags:System.Collections.CollectionBase {
+		public void Add(Flag flag){
+	    this.List.Add(flag);
+	  }
+  }
+}

Added: trunk/beagle/beagled/xemail-net/src/HMACMD5.cs
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/HMACMD5.cs	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,107 @@
+using System;
+using System.Security.Cryptography;
+
+namespace System.Security.Cryptography
+{
+	/// <summary>
+	/// 
+	/// </summary>
+	public class HMACMD5 : KeyedHashAlgorithm 
+	{
+		private MD5     hash1    = null;
+		private MD5     hash2    = null;
+		private bool    bHashing = false;
+		private byte[]  rgbInner = new byte[64];
+		private byte[]  rgbOuter = new byte[64];
+
+		/// <summary>
+		/// Rfc 2104.
+		/// </summary>
+		/// <param name="rgbKey"></param>
+		public HMACMD5 (byte[] rgbKey) 
+		{
+			HashSizeValue = 128;
+			// Create the hash algorithms.
+			hash1 = MD5.Create();
+			hash2 = MD5.Create();
+
+			this.Key = rgbKey;
+		}    
+
+		/// <summary>
+		/// 
+		/// </summary>
+		public override byte[] Key 
+		{
+			get { return (byte[])KeyValue.Clone(); }
+			set 
+			{
+				if(bHashing){
+					throw new Exception("Cannot change key during hash operation");
+				}
+				if(value.Length > 64){
+					KeyValue = hash1.ComputeHash(value);
+					// No need to call Initialize, ComputeHash does it automatically.
+				}
+				else{
+					KeyValue = (byte[]) value.Clone();
+				}
+				// Compute rgbInner and rgbOuter.
+				int i = 0;
+				for(i=0;i<64;i++){ 
+					rgbInner[i] = 0x36;
+					rgbOuter[i] = 0x5C;
+				}
+				for(i=0;i<KeyValue.Length;i++){
+					rgbInner[i] ^= KeyValue[i];
+					rgbOuter[i] ^= KeyValue[i];
+				}
+			}
+		}
+
+		/// <summary>
+		/// 
+		/// </summary>
+		public override void Initialize() 
+		{
+			hash1.Initialize();
+			hash2.Initialize();
+			bHashing = false;
+		}
+
+		/// <summary>
+		/// 
+		/// </summary>
+		/// <param name="rgb"></param>
+		/// <param name="ib"></param>
+		/// <param name="cb"></param>
+		protected override void HashCore(byte[] rgb,int ib,int cb) 
+		{
+			if(bHashing == false){
+				hash1.TransformBlock(rgbInner,0,64,rgbInner, 0);
+				bHashing = true;                
+			}
+			hash1.TransformBlock(rgb,ib,cb,rgb,ib);
+		}
+
+		/// <summary>
+		/// 
+		/// </summary>
+		/// <returns></returns>
+		protected override byte[] HashFinal() 
+		{
+			if(bHashing == false){
+				hash1.TransformBlock(rgbInner,0,64,rgbInner,0);
+				bHashing = true;                
+			}
+			// Finalize the original hash.
+			hash1.TransformFinalBlock(new byte[0],0,0);
+			// Write the outer array.
+			hash2.TransformBlock(rgbOuter,0,64,rgbOuter, 0);
+			// Write the inner hash and finalize the hash.
+			hash2.TransformFinalBlock(hash1.Hash,0,hash1.Hash.Length);
+			bHashing = false;
+			return hash2.Hash;
+		} 
+	}
+}

Added: trunk/beagle/beagled/xemail-net/src/ImapClient.cs
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/ImapClient.cs	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,756 @@
+/*
+ * ImapClient.cs.
+ * Copyright (C) 2006 COLIN Cyrille.
+ *
+ */
+
+
+using System;
+using System.Collections;
+using System.Net;
+using System.Net.Sockets;
+using System.IO;
+using System.Text;
+using System.Security.Cryptography;
+using System.Security.Cryptography.X509Certificates;
+#if MONO
+using Mono.Security.Protocol.Tls;
+#endif
+using System.Text.RegularExpressions;
+
+
+namespace System.Net.Imap {
+
+	public class ImapClient {
+		// Imap State
+		private bool 			_connected = false;
+		private bool            _authenticated = false;
+		private bool			_selected = false;
+
+		private string 			_authmethod = String.Empty;
+		private string 			_selectedmailbox = String.Empty;
+		private int	 			_port = 143;
+		private string 			_connectedhostname = String.Empty;
+		private bool 			_ssl = false;
+		private int 			_tag = 0;
+		private string 			_lasterror= String.Empty;
+		private string			_capability = String.Empty;		
+		
+		private TcpClient  		_imapconnection;
+		//private NetworkStream 	_imapnetworkstream;
+		private Stream 	_imapnetworkstream;
+		private StreamReader  	_imapstreamreader;
+		private int 			_maxlen; 			// Max lenght of received data
+		private int				_idletimeout = 6000; 		// Idle time out
+		
+/*
+ *
+ *		Properties
+ *
+ */
+
+	public string AuthMethod {
+		get {
+			return this._authmethod;
+		}
+		set {
+			this._authmethod = value;			
+		}
+	}
+
+	public string LastError {
+		get {
+			return this._lasterror;
+		}				
+	}	
+
+	public string ConnectedHostName {
+		get {
+			return this._connectedhostname;
+		}					
+   	}
+
+	public int Port {
+		get {
+			return this._port;
+		}
+		set {
+			this._port = value;
+		}
+	}
+
+	public bool Ssl {
+		get {
+			return this._ssl;
+		}
+		set {
+			this._ssl = value;
+		}
+	}
+
+	private string Tag {
+		get {
+			this._tag++;
+			if(this._tag<10)return "xm00"+this._tag.ToString()+" ";
+			if(this._tag<100)return "xm0"+this._tag.ToString()+" ";
+			if(this._tag<1000)return "xm"+this._tag.ToString()+" ";
+			return "xm"+ this._tag;
+		}
+
+	}
+
+
+	
+/*
+ *
+ *		Methods
+ *
+ *
+ */
+
+	public bool AppendMail(string mailbox, Mail email) {
+		try {
+            if(!_connected) throw new Exception("You must connect first !");
+			if(!_authenticated)throw new Exception("You must authenticate first !");
+			string flags = String.Empty;
+			string size = (email.Body.Length-1).ToString();
+			if(email.Flags.Count>0){
+				flags = "(";
+				foreach(Flag f in email.Flags){ flags += f.Name + " "; }
+				flags = flags.Substring(0,flags.Length-1);
+				flags += ")";
+			}
+            string command = this.Tag + "APPEND "+mailbox+" "+flags+" {"+size+"}\r\n";
+            SendCommand(command);
+            string response = ReadLine();
+			if(response.StartsWith("+")){	
+				SendCommand(email.Body);	
+    	        response = ReadLine();
+			}
+            return true;
+        } catch (Exception e) {
+            this._lasterror = "AppendMail : " + e.Message;
+            return false;
+        }	
+	}
+
+	public bool AppendMime(string mailbox, string mimeText) {
+		throw new Exception("Not yet implemented !");
+		return false;
+	}
+
+	public string Capability() {
+		try {
+	        if(!_connected) throw new Exception("You must connect first !");
+    	    string command = this.Tag + "CAPABILITY\r\n";
+        	SendCommand(command);
+	        string response = ReadLine();
+			if(response.StartsWith("* CAPABILITY "))response = response.Substring(13);
+			this._capability = response;
+        	ReadLine();
+	        return response;
+		} catch (Exception e) {
+			this._lasterror = "Capability : " + e.Message;
+			return null;
+		}
+    }
+
+	public bool Connect(string hostname) {
+    	try {
+        	_imapconnection = new TcpClient(hostname, this.Port);
+			_imapnetworkstream = _imapconnection.GetStream();
+#if MONO
+			if(this.Ssl) {
+				 _imapnetworkstream = new SslClientStream(_imapconnection.GetStream(),hostname,true,Mono.Security.Protocol.Tls.SecurityProtocolType.Default);
+				((SslClientStream)_imapnetworkstream).ClientCertSelectionDelegate = new CertificateSelectionCallback(DefaultCertificateSelectionCallback);
+                ((SslClientStream)_imapnetworkstream).ServerCertValidationDelegate = new CertificateValidationCallback(DefaultCertificateValidationCallback);
+                ((SslClientStream)_imapnetworkstream).PrivateKeyCertSelectionDelegate = new PrivateKeySelectionCallback(DefaultPrivateKeySelectionCallback); 
+			}
+#endif
+			
+      _imapstreamreader = new StreamReader(_imapnetworkstream,System.Text.Encoding.ASCII);
+      string info = ReadLine();
+			if(info.StartsWith("* OK") != true){
+					throw new Exception(info);
+			}
+			this._connected = true;
+			this._connectedhostname = hostname;
+			return true;
+		} catch(Exception e) {
+			this._connected = false;
+			this._connectedhostname = String.Empty;
+      this._lasterror = "Connect : " + e.Message;
+			return false;
+		}
+	}
+
+	public bool Copy(string messageset, string destination) {
+		try {
+            if(!_connected) throw new Exception("You must connect first !");
+            if(!_authenticated)throw new Exception("You must authenticate first !");
+			if(!_selected)      throw new Exception("You must select first !");
+            string command = this.Tag + "COPY "+messageset+" \""+destination+"\"\r\n";
+            SendCommand(command);
+            string response = ReadLine();
+            response = response.Substring(response.IndexOf(" ")).Trim();
+            if(!response.ToUpper().StartsWith("OK")){
+                throw new Exception(response);
+            }
+            return true;
+        } catch (Exception e) {
+            this._lasterror = "Copy : " + e.Message;
+            return false;
+        }
+	}
+
+	public bool CreateMailbox(string mailbox) {
+		try {
+		    if(!_connected) throw new Exception("You must connect first !");	
+		    if(!_authenticated)throw new Exception("You must authenticate first !");
+			string command = this.Tag + "CREATE \""+mailbox+"\"\r\n";
+			SendCommand(command);
+			string response = ReadLine();
+			response = response.Substring(response.IndexOf(" ")).Trim();
+			if(!response.ToUpper().StartsWith("OK")){
+				throw new Exception(response);
+			}
+	        return true;
+		} catch (Exception e) {
+			this._lasterror = "CreateMailbox : " + e.Message;
+            return false;
+		}
+	}
+
+	public bool DeleteMailbox(string mailbox) {
+		try {
+	        if(!_connected) throw new Exception("You must connect first !");
+    	    if(!_authenticated)throw new Exception("You must authenticate first !");
+	        string command = this.Tag + "DELETE \""+mailbox+"\"\r\n";
+    	    SendCommand(command);
+        	string response = ReadLine();
+	        response = response.Substring(response.IndexOf(" ")).Trim();
+    	    if(!response.ToUpper().StartsWith("OK")){
+				throw new Exception(response);
+        	}
+	        return true;
+		} catch (Exception e) {
+            this._lasterror = "DeleteMailbox : " + e.Message;
+            return false;
+        }
+	}
+
+	public void Disconnect() {
+		Logout();
+	}
+
+  public Mailbox Examine(string mailbox) {
+		try {
+	        if(!_connected) throw new Exception("You must connect first !");
+   		    if(!_authenticated)throw new Exception("You must authenticate first !");
+	        Mailbox x = null;
+    	    string tag = this.Tag;
+        	string command = tag + "EXAMINE \""+mailbox+"\"\r\n";
+	        SendCommand(command);
+    	    string response = ReadLine();
+        	if(response.StartsWith("*")) {
+            	x = new Mailbox(mailbox);
+	            while(response.StartsWith("*")){
+    	            Match m;
+        	        m = Regex.Match(response,@"(\d+) EXISTS");
+            	    if(m.Groups.Count>1){x.NumMsg = Convert.ToInt32(m.Groups[1].ToString());}
+                	m = Regex.Match(response,@"(\d+) RECENT");
+	                if(m.Groups.Count>1)x.NumNewMsg = Convert.ToInt32(m.Groups[1].ToString());
+    	            m = Regex.Match(response,@"UNSEEN (\d+)");
+        	        if(m.Groups.Count>1)x.NumUnSeen = Convert.ToInt32(m.Groups[1].ToString());
+            	    m = Regex.Match(response,@" FLAGS \((.*?)\)");
+                	if(m.Groups.Count>1)x.SetFlags(m.Groups[1].ToString());
+	                response = ReadLine();
+    	        }
+				if(response.StartsWith(tag+"OK")){
+					if(response.ToUpper().IndexOf("READ/WRITE") > -1) x.Rw = true;
+				}
+            	this._selected = true;
+            	this._selectedmailbox = mailbox;
+        	}
+        	return x;
+		 } catch (Exception e) {
+		 	this._lasterror = "Examine : " + e.Message;
+			return null;
+		 }
+    	}
+
+	public bool Expunge() {
+		try {
+        	if(!_connected) throw new Exception("You must connect first !");
+            if(!_authenticated)throw new Exception("You must authenticate first !");
+			if(!_selected)      throw new Exception("You must select first !");
+            string tag = this.Tag;
+            string command = tag + "EXPUNGE\r\n";
+            SendCommand(command);
+            string response = ReadLine();
+            while(response.StartsWith("*")){
+				response = ReadLine();
+			}
+			if(response.StartsWith(tag+"OK"))return true;
+        	return false;
+		} catch (Exception e) {
+            this._lasterror = "Expunge : " + e.Message;
+            return false;
+        }
+	}
+
+	public MailCollection FetchMessages(string start,string end,bool uid,bool headersonly,bool setseen) {
+		try {
+			if(!_connected) 	throw new Exception("You must connect first !");
+   	     	if(!_authenticated)	throw new Exception("You must authenticate first !");
+    	    if(!_selected)		throw new Exception("You must select first !");
+			string UID,HEADERS,SETSEEN;
+			UID = HEADERS = SETSEEN = String.Empty;
+			if(uid)UID="UID ";
+			if(headersonly)HEADERS="HEADER";
+			if(setseen)SETSEEN=".PEEK";
+			string tag = this.Tag;
+			string command = tag + UID + "FETCH " + start + ":" + end + " (UID RFC822.SIZE FLAGS BODY" + SETSEEN + "[" + HEADERS + "])\r\n";
+	        SendCommand(command);
+			MailCollection x = new MailCollection();
+			string reg = @"\* \d+ FETCH.*?BODY.*?\{(\d+)\}";
+			string response = ReadLine();
+			Match m = Regex.Match(response,reg);
+			while(m.Groups.Count > 1){
+				int bodylen = Convert.ToInt32(m.Groups[1].ToString());
+				Mail mail = new Mail();
+				byte[] body = ReadData(bodylen);
+				Match m2 = Regex.Match(response,@"UID (\d+)");
+				if(m2.Groups[1]!=null)mail.Uid = m2.Groups[1].ToString();
+				m2 = Regex.Match(response,@"FLAGS \((.*?)\)");
+				if(m2.Groups[1]!=null)mail.SetFlags(m2.Groups[1].ToString());
+				m2 = Regex.Match(response,@"RFC822\.SIZE (\d+)");
+				if(m2.Groups[1]!=null)mail.Size = Convert.ToInt32(m2.Groups[1].ToString());
+				mail.Load(body,headersonly);
+				x.Add(mail);
+				response = ReadLine(); // read last line terminated by )
+				response = ReadLine(); // read next line
+		        m = Regex.Match(response,reg);
+			}
+			return x;
+		} catch (Exception e) {
+			this._lasterror = "FetchMessages " + e.ToString();//e.Message;
+            return null;
+		}
+	 }
+	
+	public Quota GetQuota(string mailbox) {
+        try {
+            if(!_connected) throw new Exception("You must connect first !");
+            if(!_authenticated)throw new Exception("You must authenticate first !");
+            if(this._capability.IndexOf("NAMESPACE")== -1) 
+					 new Exception("This command is not supported by the server or call Capability() is need !");
+
+            string command = this.Tag + "GETQUOTAROOT " + mailbox + "\r\n";
+            SendCommand(command);
+            string response = ReadLine();
+			string reg = "\\* QUOTA (.*?) \\((.*?) (.*?) (.*?)\\)";
+            while(response.StartsWith("*")){
+				Match m = Regex.Match(response,reg);
+				if(m.Groups.Count > 1){
+			 		return new Quota(	m.Groups[1].ToString(),
+										m.Groups[2].ToString(),
+										Int32.Parse(m.Groups[3].ToString()),
+										Int32.Parse(m.Groups[4].ToString())
+									);
+				}
+				response = ReadLine();
+            }
+			return null;
+        } catch (Exception e) {
+            this._lasterror = "Quota : " + e.Message;
+            return null;
+        }
+
+	}
+	public bool IsConnected() {
+		return this._connected;
+	}
+
+	public bool IsLoggedIn() {
+		return this._authenticated;
+	}
+
+	public MailboxCollection ListMailboxes(string reference, string pattern) {
+		try {
+	        if(!_connected) throw new Exception("You must connect first !");
+    	    if(!_authenticated)throw new Exception("You must authenticate first !");
+			MailboxCollection x = new MailboxCollection();
+	        string command = this.Tag + "LIST \""+reference+"\" \""+pattern+"\"\r\n";
+    	    SendCommand(command);
+			string reg = "\\* LIST \\(([^\\)]*)\\) \\\"([^\\\"]+)\\\" \\\"([^\\\"]+)\\\"";
+	        string response = ReadLine();
+    	    Match m = Regex.Match(response,reg);
+        	while(m.Groups.Count > 1){
+				Mailbox mailbox = new Mailbox(m.Groups[3].ToString());
+				x.Add(mailbox);
+				response = ReadLine();
+				m = Regex.Match(response,reg);		
+			}
+    	    return x;
+		} catch (Exception e) {
+			this._lasterror = "ListMailboxes : " + e.Message;
+            return null;
+		}
+	}
+
+    public MailboxCollection ListSuscribesMailboxes(string reference, string pattern) {
+        if(!_connected) throw new Exception("You must connect first !");
+        if(!_authenticated)throw new Exception("You must authenticate first !");
+        MailboxCollection x = new MailboxCollection();
+        string command = this.Tag + "LSUB \""+reference+"\" \""+pattern+"\"\r\n";
+        SendCommand(command);
+		string reg = "\\* LSUB \\(([^\\)]*)\\) \\\"([^\\\"]+)\\\" \\\"([^\\\"]+)\\\"";
+        string response = ReadLine();
+        Match m = Regex.Match(response,reg);
+        while(m.Groups.Count > 1){
+            Mailbox mailbox = new Mailbox(m.Groups[3].ToString());
+            x.Add(mailbox);
+            response = ReadLine();
+            m = Regex.Match(response,reg);
+        }
+        return x;
+    }
+
+	public bool Login(string login, string password) {
+		try {
+			if(!_connected){
+				throw new Exception("You must connect first !");
+			}
+			string command = String.Empty;
+			string result = String.Empty;
+			string tag = this.Tag;
+			switch (this.AuthMethod) {
+				case "CRAM-MD5" :
+					command = tag + "AUTHENTICATE CRAM-MD5\r\n";
+					SendCommand(command);
+					// retrieve server key
+					string key = ReadLine().Replace("+ ","");
+					key = System.Text.Encoding.Default.GetString(Convert.FromBase64String(key));
+					// calcul hash
+					HMACMD5 kMd5 = new HMACMD5(System.Text.Encoding.ASCII.GetBytes(password));
+					byte[] hash1 = kMd5.ComputeHash(System.Text.Encoding.ASCII.GetBytes(key));
+					key = BitConverter.ToString(hash1).ToLower().Replace("-","");
+					string response = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(login + " " + key))+"\r\n";
+					SendCommand(response);
+					result = ReadLine();
+					if(result.StartsWith(tag+"OK")==true){
+						this._authenticated = true;
+						return true;
+					}else{
+						throw new Exception(result);
+					}
+					break;
+				case "LOGIN" :
+	                command = tag + "LOGIN "+login+" "+password+"\r\n";
+					SendCommand(command);
+					result = ReadLine();
+       		        if(result.StartsWith(tag+"OK")){
+   	 	    	        this._authenticated = true;
+           	    	    return true;
+                	}else{
+						throw new Exception(result);
+    	            }
+					break;
+			case "PLAIN" :
+			default :
+				throw new Exception("Authentication Mode Not Yet Supported !");
+				break;
+			}
+		} catch (Exception e) {
+			this._lasterror = "Login : " + e.Message;
+            return false;
+		}
+			
+	}
+
+	public bool Logout() {
+		try {
+			if(!_connected) throw new Exception("You must connect first !");
+			string command = this.Tag + "LOGOUT";
+			SendCommand(command);
+			this._connected = this._authenticated = false;
+			_imapconnection = null;
+			return true;
+		} catch (Exception e) {
+		    this._lasterror = "Logout : " + e.Message;
+		    return false;
+		}
+	}
+
+	public Namespaces Namespace(){
+		try {
+			if(!_connected) throw new Exception("You must connect first !");
+			if(!_authenticated)throw new Exception("You must authenticate first !");
+			if(this._capability.IndexOf("NAMESPACE")== -1) throw new Exception("This command is not supported by the server or call Capability() is need !");
+			string command = this.Tag + "NAMESPACE\r\n";
+			SendCommand(command);
+			string response = ReadLine();
+			//Console.WriteLine(response);
+			if(response.StartsWith("* NAMESPACE")){
+				response = response.Substring(12);
+				Namespaces n = new Namespaces();
+				//[TODO] be sure to parse correctly namespace when not all namespaces are present. NIL character
+				string reg =@"\((.*?)\) \((.*?)\) \((.*?)\)$";
+	            Match m = Regex.Match(response,reg);
+ 	           	if(m.Groups.Count != 4) {
+				ReadLine();
+				throw new Exception("En error occure, this command is not fully supported !");
+			}
+				string reg2 = "\\(\\\"(.*?)\\\" \\\"(.*?)\\\"\\)";
+				Match m2 = Regex.Match(m.Groups[1].ToString(),reg2);
+				while(m2.Groups.Count>1) {
+					n.AddServerNamespace(m2.Groups[1].ToString(),m2.Groups[2].ToString());
+					m2 = m2.NextMatch();
+				}
+				m2 = Regex.Match(m.Groups[2].ToString(),reg2);
+				while(m2.Groups.Count>1) {
+					n.AddUserNamespace(m2.Groups[1].ToString(),m2.Groups[2].ToString());
+					m2 = m2.NextMatch();
+				}
+				m2 = Regex.Match(m.Groups[3].ToString(),reg2);
+				while(m2.Groups.Count>1) {
+					n.AddSharedNamespace(m2.Groups[1].ToString(),m2.Groups[2].ToString());
+					m2 = m2.NextMatch();
+				}
+				ReadLine();
+				return n;
+			} else {
+				throw new Exception("Unknow server response !");
+			}
+		} catch (Exception e) {
+		    this._lasterror = "Namespace : " + e.Message;
+			return null;
+	    }
+    }
+
+	public int NumMails(string mailbox){
+		try {
+		    if(!_connected) throw new Exception("You must connect first !");	
+		    if(!_authenticated)throw new Exception("You must authenticate first !");
+			string command = this.Tag + "STATUS "+mailbox+" (MESSAGES)\r\n";
+			SendCommand(command);
+			string reg = @"\* STATUS.*MESSAGES (\d+)";
+			string response = ReadLine();
+			int result = 0;
+			while(response.StartsWith("*")){
+	    	    Match m = Regex.Match(response,reg);
+			    if(m.Groups.Count > 1)result=Convert.ToInt32(m.Groups[1].ToString());
+		        response = ReadLine();
+	    	    m = Regex.Match(response,reg);
+		    }
+		    return result;
+		} catch (Exception e) {
+            this._lasterror = "NumMails : " + e.Message;
+            return -1;
+        }
+	}
+
+	public bool RefetchMailFlags(Mail email) {
+			        throw new Exception("Not yet implemented !");
+					        return false;
+	}
+
+	public bool RenameMailbox(string frommailbox, string tomailbox) {
+		try {
+	        if(!_connected) throw new Exception("You must connect first !");
+    	    if(!_authenticated)throw new Exception("You must authenticate first !");
+        	string command = this.Tag + "RENAME \""+frommailbox+"\" \"" +tomailbox+"\"\r\n";
+	        SendCommand(command);
+    	    string response = ReadLine();
+        	response = response.Substring(response.IndexOf(" ")).Trim();
+	        if(!response.ToUpper().StartsWith("OK")){
+    	        throw new Exception(response);
+        	}
+        	return true;
+		} catch (Exception e) {
+            this._lasterror = "RenameMailbox : " + e.Message;
+            return false;
+        }
+	}
+
+    public MessageSet Search(string criteria,bool uid){
+        try {
+            if(!_connected) throw new Exception("You must connect first !");
+            if(!_authenticated)throw new Exception("You must authenticate first !");
+            if(!_selected)      throw new Exception("You must select first !");
+            string isuid = uid?"UID ":"";
+            string command = this.Tag + isuid + "SEARCH "+criteria+"\r\n";
+            SendCommand(command);
+
+            string reg = @"^\* SEARCH (.*)";
+            string response = ReadLine();
+	    ReadLine (); // Read the SUCCESS line
+            MessageSet ms = new MessageSet();
+            Match m = Regex.Match(response,reg);
+            if(m.Groups.Count > 1){
+                string[] uids = m.Groups[1].ToString().Trim().Split(' ');
+                foreach(string s in uids){
+                    ms.Messages.Add(s);
+                }
+                return ms;
+            }else {
+                throw new Exception(response);
+            }
+        } catch (Exception e) {
+            this._lasterror = "Search : " + e.Message;
+            return null;
+        }
+    }
+
+	public Mailbox SelectMailbox(string mailbox) {
+		try {
+	        if(!_connected) throw new Exception("You must connect first !");
+    	    if(!_authenticated)throw new Exception("You must authenticate first !");
+        	Mailbox x = null;
+			string tag = this.Tag;
+    	    string command = tag + "SELECT \""+mailbox+"\"\r\n";
+        	SendCommand(command);
+	        string response = ReadLine();
+			if(response.StartsWith("*")) {
+				x = new Mailbox(mailbox);
+			    while(response.StartsWith("*")){
+					Match m;
+					m = Regex.Match(response,@"(\d+) EXISTS");
+					if(m.Groups.Count>1){x.NumMsg = Convert.ToInt32(m.Groups[1].ToString());}
+					m = Regex.Match(response,@"(\d+) RECENT");
+					if(m.Groups.Count>1)x.NumNewMsg = Convert.ToInt32(m.Groups[1].ToString());
+					m = Regex.Match(response,@"UNSEEN (\d+)");
+	                if(m.Groups.Count>1)x.NumUnSeen = Convert.ToInt32(m.Groups[1].ToString());
+					m = Regex.Match(response,@" FLAGS \((.*?)\)");
+	    	        if(m.Groups.Count>1)x.SetFlags(m.Groups[1].ToString());
+    	    	    response = ReadLine();
+        		}
+				if(response.StartsWith(tag+"OK")){
+					if(response.ToUpper().IndexOf("READ/WRITE") > -1) x.Rw = true;
+				}
+				this._selected = true;
+				this._selectedmailbox = mailbox;
+			}
+	        return x;
+		} catch (Exception e) {
+            this._lasterror = "SelectMailbox : " + e.Message;
+            return null;
+        }
+	}
+
+	public bool Store(string messageset,bool replace,string flags){
+		try {
+            if(!_connected) throw new Exception("You must connect first !");
+            if(!_authenticated)throw new Exception("You must authenticate first !");
+            if(!_selected)      throw new Exception("You must select first !");
+			string isreplace = replace?"+":"";
+            string command = this.Tag + "STORE "+isreplace+"FLAGS.SILENT ("+flags+")\"\r\n";
+            SendCommand(command);
+            string response = ReadLine();
+            response = response.Substring(response.IndexOf(" ")).Trim();
+            if(!response.ToUpper().StartsWith("OK")){
+                throw new Exception(response);
+            }
+            return true;
+        } catch (Exception e) {
+            this._lasterror = "Store : " + e.Message;
+            return false;
+        }
+	}
+
+	public bool SuscribeMailbox(string mailbox) {
+		try {
+	        if(!_connected) throw new Exception("You must connect first !");
+    	    if(!_authenticated)throw new Exception("You must authenticate first !");
+        	string command = this.Tag + "SUBSCRIBE \""+mailbox+"\"\r\n";
+	        SendCommand(command);
+    	    string response = ReadLine();
+        	response = response.Substring(response.IndexOf(" ")).Trim();
+	        if(!response.ToUpper().StartsWith("OK")){
+    	        throw new Exception(response);
+        	}
+	        return true;
+		} catch (Exception e) {
+            this._lasterror = "SuscribeMailbox : " + e.Message;
+            return false;
+		}
+	}
+
+	public bool UnSuscribeMailbox(string mailbox) {
+		try {
+	        if(!_connected) throw new Exception("You must connect first !");
+			if(!_authenticated)throw new Exception("You must authenticate first !");
+			string command = this.Tag + "UNSUBSCRIBE \""+mailbox+"\"\r\n";
+	        SendCommand(command);
+    	    string response = ReadLine();
+        	response = response.Substring(response.IndexOf(" ")).Trim();
+	        if(!response.ToUpper().StartsWith("OK")){
+				throw new Exception(response);
+        	}
+	        return true;
+		 } catch (Exception e) {
+	        this._lasterror = "UnSuscribeMailbox : " + e.Message;
+	        return false;
+	     }
+    }
+
+/*
+ *
+ *		Privates functions
+ *
+ */
+
+	private void SendCommand(string command) {
+	    byte [] data = System.Text.Encoding.ASCII.GetBytes(command.ToCharArray());
+        try {
+			//Console.Write("SendCommand : "+command);
+        	_imapnetworkstream.Write(data, 0, data.Length);
+		} catch (Exception e) {
+       	   	throw new Exception("SendCommand error :" + e.Message);
+        }
+   	}
+    internal X509Certificate DefaultCertificateSelectionCallback(X509CertificateCollection clientCertificates,
+																X509Certificate serverCertificate,
+																string targetHost,
+																X509CertificateCollection serverRequestedCertificates) {
+    	return null;
+    }
+    internal bool DefaultCertificateValidationCallback(X509Certificate certificate,int[] certificateErrors) {
+    	return true;
+    }
+    internal AsymmetricAlgorithm DefaultPrivateKeySelectionCallback(X509Certificate certificate,string targetHost) {
+        return null;
+    }
+
+
+	/*
+	 *
+	 *			ReadData(), ReadLine(), function to catch streamer idle timeout
+	 *			TODO catch time out :) !!
+	 *
+	 * 
+	 */
+	
+	private string ReadLine(){
+		StringBuilder line = new StringBuilder();
+		char[] buf = new char[2];
+		while(!(buf[0]==13 && buf[1]==10)) {
+			buf[0] = buf[1];
+			buf[1] = (char)_imapnetworkstream.ReadByte();
+			line.Append(buf[1]);
+		}
+		return line.ToString(0,line.Length-2); 
+	}
+	private byte[] ReadData (int len) {
+		byte[] data = new byte[len];
+        byte[] buf = new byte[1];
+        Int32 numread = 0;
+		int x = 0;
+        while (x < len) {
+            data[x++] = (byte)_imapnetworkstream.ReadByte();
+        }
+		return data;
+	}
+  }
+}

Added: trunk/beagle/beagled/xemail-net/src/Mail.cs
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/Mail.cs	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,220 @@
+/*
+ * Mail.cs
+ * Copyright (C) 2006 COLIN Cyrille.
+ *
+ */
+
+using System;
+using System.IO;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Collections;
+using System.Web.Mail;
+
+namespace System.Net.Imap {
+
+  public class Mail {
+		
+		public ArrayList    _attachments;
+    private string      _body = String.Empty;
+    private Encoding    _bodyEncoding;
+    private MailFormat    _bodyFormat;
+    private Flags     _flags = new Flags();
+    private string      _header= String.Empty;
+    private string      _inline = String.Empty; // Mime content that could be display inline insteado of attachments
+    private MailPriority  _priority;
+    private int       _size;
+    const   int       _maxsize = 50000; // this is the max size to store body, elsewhere body keep at the server.
+    private string      _uid;
+    private bool      _headersonly; // set to true if only headers have been fetched.
+
+    // Constructor
+    public Mail () {
+      _attachments = new ArrayList ();
+      _bodyEncoding = Encoding.Default;
+    }
+    public string Bcc {
+      get { return GetHeader("Bcc:");}
+      set { SetHeader("Bcc:",value); }
+    }
+    public string Body {
+      get { return _body; }
+      set { _body = value; }
+    }
+    public string Cc {
+      get { return GetHeader("Cc:");}
+      set { SetHeader("Cc:",value); }
+    }
+    public string Date {
+      get { return GetHeader("Date:");}
+      set { SetHeader("Date:",value); }
+    }
+    public Flags Flags {
+        get {return this._flags;}
+        set {this._flags = value;}
+    }
+    public string From {
+      get { return GetHeader("From:");}
+      set { SetHeader("From:",value); }
+    }
+    public string Header {
+      get { return _header; }
+      set { _header = value; }
+    }
+    public string ReplyTo {
+      get { return GetHeader("Reply-To:");}
+      set { SetHeader("Reply-To:",value); }
+    }
+    public string Sender {
+      get { return GetHeader("Sender:");}
+      set { SetHeader("Sender:",value); }
+      }
+    public int Size {
+            get { return _size; }
+            set { _size = value; }
+      }
+    public string Subject {
+      get { return GetHeader("Subject:");}
+      set { SetHeader("Subject:",value); }
+    }
+    public string To {
+      get { return GetHeader("To:");}
+      set { SetHeader("To:",value); }
+    }
+    public string Uid {
+      get { return _uid; }
+      set { _uid = value; }
+    }
+    private void SetHeader(string header,string val) {
+      Match m;
+      m = Regex.Match(this._header,"^("+header+".*)\\r\\n",RegexOptions.Multiline);
+      if(m.Groups.Count > 1) {
+        this._header.Replace(m.Groups[0].ToString(), header+val+"\r\n");
+      } else {
+        this._header += header+val+"\r\n";
+      }
+    }
+    private string GetHeader(string header) {
+            Match m;
+            m = Regex.Match(this._header,"^"+header+" (.*)\\r\\n",RegexOptions.Multiline);
+            if(m.Groups.Count > 1) {
+                return m.Groups[1].ToString();
+            } else {
+                return String.Empty;
+            }
+    }
+    private string _boundary(string messagepart) {
+      Match m;
+            m = Regex.Match(messagepart,"boundary=[\"](.*?)[\"]\\r\\n",RegexOptions.Multiline);
+            if(m.Groups.Count > 1) {
+                return m.Groups[1].ToString();
+            } else {
+                return String.Empty;
+            }
+    }
+    private string _contentType() {
+      Match m;
+            m = Regex.Match(this._header,"Content-Type: (.*?);",RegexOptions.Multiline);
+            if(m.Groups.Count > 1) {
+                return m.Groups[1].ToString();
+            } else {
+                return String.Empty;
+            }
+    }
+    /*
+     *
+     *  Hum, what's this ugly think !! To read message we need to parse message to retrieve mime part.
+     *  At this point a specialized library/treatement is need. In waiting time, i hack this :
+     *  If in the message header there's a boundary field, I parse message in multiple attachments separate header : Content-type:.....
+     *  and body : the data.
+     *  Like this each parts of a Mime message is an attachment.
+     *
+     */
+    public void Load(byte[] message,bool headersonly) {
+          this._headersonly = headersonly;
+      if(headersonly) {
+        this._header = System.Text.Encoding.ASCII.GetString(message);
+      } else {
+        MemoryStream stream = new MemoryStream(message);
+        string line = ReadLine(stream);
+        while(line!="\r\n"){
+          this._header+=line;
+          line = ReadLine(stream);
+        }
+        string boundary = _boundary(this._header);
+        if(boundary==String.Empty){
+          line = ReadLine(stream);
+          while(line!=""){
+            this._body+=line;
+            line = ReadLine(stream);
+          }
+        } else { //else this is a multipart Mime Message
+            ParseMime(stream,boundary);
+                }
+      }
+    }
+    private void ParseMime(MemoryStream stream,string boundary) {
+      byte[] data = ReadDataLine(stream);
+            bool first = true;
+            bool header = true;
+            string part = "";
+            while(!System.Text.Encoding.ASCII.GetString(data).StartsWith("--"+boundary)){data = ReadDataLine(stream);}
+            while(!System.Text.Encoding.ASCII.GetString(data).StartsWith("--"+boundary+"--")){
+                  data = ReadDataLine(stream);
+                    Attachment a = new Attachment();
+                    part = "";
+                    // read part header
+                    while(!System.Text.Encoding.ASCII.GetString(data).StartsWith("--"+boundary) && !(data[0]==13 && data[1]==10)) {
+                        part+=System.Text.Encoding.ASCII.GetString(data);
+                        data = ReadDataLine(stream);
+                    }
+                    a.Header=part;
+                    // header body
+                    data = ReadDataLine(stream);
+                    ArrayList body = new ArrayList();
+                    while(!System.Text.Encoding.ASCII.GetString(data).StartsWith("--"+boundary)) {
+                        foreach (byte b in data) {body.Add(b);}
+                      data = ReadDataLine(stream);
+                    }
+          // check for nested part
+          string nestedboundary = _boundary(a.Header);
+          if(nestedboundary == String.Empty) {
+                    a.Content = (byte[])body.ToArray(typeof(byte));
+                    this._attachments.Add(a);
+          } else { // nested
+            ParseMime(new MemoryStream((byte[])body.ToArray(typeof(byte))),nestedboundary);
+          }
+      }
+    }
+    public void SetFlags(string flags) {
+      string[] f = flags.Split(' ');
+      this._flags.Clear();
+      foreach(string s in f){
+        this._flags.Add(new Flag(s));
+      }
+    }
+    private string ReadLine(MemoryStream stream){
+      if(stream.Position==stream.Length)return String.Empty;
+          StringBuilder line = new StringBuilder();
+          char[] buf = new char[2];
+          while(!(buf[0]==13 && buf[1]==10)) {
+              buf[0] = buf[1];
+              buf[1] = (char)stream.ReadByte();
+              line.Append(buf[1]);
+          }
+      //stream.Seek(line.Length, SeekOrigin.Current);
+          return line.ToString(0,line.Length);
+      }
+    private byte[] ReadDataLine(MemoryStream stream){
+      byte[] buf = new byte[2];
+      ArrayList result = new  ArrayList();
+      while(!(buf[0]==13 && buf[1]==10)) {
+         buf[0] = buf[1];
+         buf[1] = (byte)stream.ReadByte();
+    	   result.Add(buf[1]);
+      }
+      return (byte[])result.ToArray(typeof(byte));
+		}
+	}
+}
+

Added: trunk/beagle/beagled/xemail-net/src/MailCollection.cs
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/MailCollection.cs	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,18 @@
+/*
+ * MailCollection.cs
+ * Copyright (C) 2006 COLIN Cyrille.
+ *
+ */
+
+using System;
+using System.Collections;
+
+namespace System.Net.Imap {
+
+  public class MailCollection:System.Collections.CollectionBase {
+		public void Add(Mail mail){
+	 		this.List.Add(mail);
+		}
+  }
+}
+

Added: trunk/beagle/beagled/xemail-net/src/Mailbox.cs
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/Mailbox.cs	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,57 @@
+/*
+ * Mailbox.cs
+ * Copyright (C) 2006 COLIN Cyrille.
+ *
+ */
+
+using System;
+using System.Collections;
+
+namespace System.Net.Imap {
+
+  public class Mailbox {
+    private string _name;
+    private int _nummsg = 0;
+    private int _recent = 0;
+    private int _numunseen = 0;
+    private bool _rw = false;
+    private Flags _flags= new Flags();
+
+    public Mailbox() {}
+    public Mailbox(string name) {
+      this._name = name;
+    }
+    public string Name {
+            get { return this._name;}
+      set { this._name = value;}
+        }
+    public int NumNewMsg {
+      get { return this._recent;}
+      set { this._recent = value;}
+    }
+    public int NumMsg {
+      get { return this._nummsg;}
+      set { this._nummsg = value;}
+    }
+    public int NumUnSeen {
+      get { return this._numunseen;}
+      set { this._numunseen = value;}
+    }
+    public Flags Flags {
+      get {return this._flags;}
+      set {this._flags = value;}
+    }
+    public bool Rw {
+      get {return this._rw;}
+      set {this._rw = value;}
+    }
+    public void SetFlags(string flags) {
+      string[] f = flags.Split(' ');
+      this._flags.Clear();
+      foreach(string s in f){
+  	    this._flags.Add(new Flag(s));
+      }
+		}
+	}
+}
+

Added: trunk/beagle/beagled/xemail-net/src/MailboxCollection.cs
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/MailboxCollection.cs	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,18 @@
+/*
+ * MailboxCollection.cs
+ * Copyright (C) 2006 COLIN Cyrille.
+ *
+ */
+
+using System;
+using System.Collections;
+
+namespace System.Net.Imap {
+
+  public class MailboxCollection:System.Collections.CollectionBase {
+		public void Add(Mailbox mailbox){
+			this.List.Add(mailbox);
+		}
+  }
+}
+

Added: trunk/beagle/beagled/xemail-net/src/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/Makefile.am	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,16 @@
+xemaildir=$(pkglibdir)
+xemail_SCRIPTS = xemail-net.dll
+EXTRA_DIST = $(xemail_sources) $(xemail_sources_in)
+CLEANFILES = xemail-net.dll
+DISTCLEANFILES = AssemblyInfo.cs Makefile.in
+DEPENDENCIES_LIBS = -r:System.Web -r:Mono.Security
+
+xemail_sources_in = AssemblyInfo.cs.in
+xemail_generated_sources = $(xemail_sources_in:.in=)
+xemail_sources = *.cs
+
+xemail_build_sources = $(addprefix $(srcdir)/, $(xemail_sources))
+#xemail_build_sources += $(xemail_generated_sources)
+
+xemail-net.dll: $(xemail_build_sources)
+	$(MCS) -target:library -out:$@ -d:MONO $(xemail_build_sources) $(DEPENDENCIES_LIBS)

Added: trunk/beagle/beagled/xemail-net/src/MessageSet.cs
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/MessageSet.cs	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,28 @@
+/*
+ * MessageSet.cs.
+ * Copyright (C) 2006 COLIN Cyrille.
+ *
+ */
+
+using System;
+using System.Collections;
+
+
+namespace System.Net.Imap {
+
+  public class MessageSet {
+
+    private ArrayList   _messagesids;
+  
+    public MessageSet(){
+			_messagesids = new ArrayList();
+		}
+    public ArrayList Messages {
+	    set { this._messagesids = value;}
+      get { return this._messagesids;}
+    }
+		public void AddMessage(int Id) {
+			this._messagesids.Add(Id);
+		}
+  }
+}

Added: trunk/beagle/beagled/xemail-net/src/Namespace.cs
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/Namespace.cs	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,66 @@
+/*
+ * NameSpace.cs
+ * Copyright (C) 2005 COLIN Cyrille.
+ *
+ */
+
+using System;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Runtime.Serialization;
+using System.Web.Mail;
+
+namespace System.Net.Imap {
+	public class Namespaces {
+
+		private ArrayList		_servernamespace;
+		private ArrayList		_usernamespace;   
+		private ArrayList   	_sharednamespace;  
+		
+		public Namespaces(){
+			this. _servernamespace = new ArrayList();
+			this. _usernamespace = new ArrayList();
+			this. _sharednamespace = new ArrayList();
+		}
+		public void AddServerNamespace(string key,string name) {
+			this. _servernamespace.Add(new Namespace(key,name));
+		}
+		public void AddUserNamespace(string key,string name) {
+			this. _usernamespace.Add(new Namespace(key,name));
+		}
+		public void AddSharedNamespace(string key,string name) {
+			this. _sharednamespace.Add(new Namespace(key,name));
+		}
+		public ArrayList ServerNamespace {
+			set { this._servernamespace = value;}
+			get { return this._servernamespace;}
+		}
+		public ArrayList UserNamespace {
+			set { this._usernamespace = value;}
+			get { return this._usernamespace;}
+		}
+		public ArrayList SharedNamespace {
+			set { this._sharednamespace = value;}
+			get { return this._sharednamespace;}
+		}
+	}
+	public class Namespace {
+		private string _prefix;
+		private string _delimiter;
+		public Namespace(string prefix, string delimiter){
+			this._prefix = prefix;
+			this._delimiter = delimiter;
+		}
+		public Namespace(){}
+		public string Prefix {
+	        set { this._prefix = value;}
+			get { return this._prefix;}
+		}
+		public string Delimiter {
+ 	       set { this._delimiter = value;}
+           get { return this._delimiter;}
+        }
+	}
+}

Added: trunk/beagle/beagled/xemail-net/src/Quota.cs
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/src/Quota.cs	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,29 @@
+/*
+ * Quota.cs
+ * Copyright (C) 2005 COLIN Cyrille.
+ *
+ */
+
+using System;
+using System.Collections;
+
+namespace System.Net.Imap {
+	public class Quota {
+		private string ressource;
+		private string usage;
+		private int used;
+		private int max;
+		public Quota(string ressourceName,string usage,int used, int max) {
+			this.ressource = ressourceName;
+			this.usage = usage;
+			this.used = used;
+			this.max = max;
+		}
+		public int Used {
+			get { return this.used; }
+		}
+		public int Max {
+			get { return this.max; }
+		}
+	}
+}

Added: trunk/beagle/beagled/xemail-net/src/xemail.snk
==============================================================================
Binary file. No diff available.

Added: trunk/beagle/beagled/xemail-net/upstream-patches/01.patch
==============================================================================
--- (empty file)
+++ trunk/beagle/beagled/xemail-net/upstream-patches/01.patch	Mon Apr  7 02:35:06 2008
@@ -0,0 +1,22 @@
+--- /home/debajyoti/xemail-net-0.2/src/ImapClient.cs	2006-01-18 14:58:57.000000000 -0500
++++ src/ImapClient.cs	2008-04-05 18:37:33.394369500 -0400
+@@ -498,7 +498,10 @@
+ 				//[TODO] be sure to parse correctly namespace when not all namespaces are present. NIL character
+ 				string reg =@"\((.*?)\) \((.*?)\) \((.*?)\)$";
+ 	            Match m = Regex.Match(response,reg);
+- 	           	if(m.Groups.Count != 4) throw new Exception("En error occure, this command is not fully supported !");
++ 	           	if(m.Groups.Count != 4) {
++				ReadLine();
++				throw new Exception("En error occure, this command is not fully supported !");
++			}
+ 				string reg2 = "\\(\\\"(.*?)\\\" \\\"(.*?)\\\"\\)";
+ 				Match m2 = Regex.Match(m.Groups[1].ToString(),reg2);
+ 				while(m2.Groups.Count>1) {
+@@ -582,6 +585,7 @@
+ 
+             string reg = @"^\* SEARCH (.*)";
+             string response = ReadLine();
++	    ReadLine (); // Read the SUCCESS line
+             MessageSet ms = new MessageSet();
+             Match m = Regex.Match(response,reg);
+             if(m.Groups.Count > 1){



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