Click here to Skip to main content
15,881,588 members
Articles / Programming Languages / C#

STUN Client

Rate me:
Please Sign up or sign in to vote.
4.83/5 (36 votes)
20 Apr 2007CPOL 322.4K   14.9K   85  
STUN client C# implementation with sample application
using System;

using LumiSoft.Net.Mime;

namespace LumiSoft.Net.IMAP.Server
{
	/// <summary>
	/// IMAP SEARCH message matcher. You can use this class to see if message values match to search criteria.
	/// </summary>
	public class IMAP_SearchMatcher
	{
		private SearchGroup m_pSearchCriteria = null;

		/// <summary>
		/// Deault constuctor.
		/// </summary>
		/// <param name="mainSearchGroup">SEARCH command main search group.</param>
		internal IMAP_SearchMatcher(SearchGroup mainSearchGroup)
		{
			m_pSearchCriteria = mainSearchGroup;
		}


		#region method Matches
		
		/// <summary>
		/// Gets if specified values match search criteria.
		/// </summary>
		/// <param name="no">Message sequence number.</param>
		/// <param name="uid">Message UID.</param>
		/// <param name="size">Message size in bytes.</param>
		/// <param name="internalDate">Message INTERNALDATE (dateTime when server stored message).</param>
		/// <param name="flags">Message flags.</param>
		/// <param name="header">Message header. This is only needed if this.IsHeaderNeeded is true.</param>
		/// <param name="bodyText">Message body text (must be decoded unicode text). This is only needed if this.IsBodyTextNeeded is true.</param>
		/// <returns></returns>
		public bool Matches(int no,int uid,int size,DateTime internalDate,IMAP_MessageFlags flags,string header,string bodyText)
		{
			// Parse header only if it's needed
			LumiSoft.Net.Mime.Mime m = null;
            if(m_pSearchCriteria.IsHeaderNeeded()){
				m = new LumiSoft.Net.Mime.Mime();
				m.MainEntity.Header.Parse(header);
			}

			return m_pSearchCriteria.Match(no,uid,size,internalDate,flags,m,bodyText);
		}

		#endregion


		#region Properties Implementation

		/// <summary>
		/// Gets if header is needed for matching.
		/// </summary>
		public bool IsHeaderNeeded
		{
			get{ return m_pSearchCriteria.IsHeaderNeeded(); }
		}

		/// <summary>
		/// Gets if body text is needed for matching.
		/// </summary>
		public bool IsBodyTextNeeded
		{
			get{ return m_pSearchCriteria.IsBodyTextNeeded(); }
		}

		#endregion

	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Estonia Estonia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions