Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » General » Downloads
 
Add your own
alternative version

SIP Stack with SIP Proxy - (VOIP)

, 11 Jun 2007 CPOL
C# implementation of SIP
SIP_Proxy_demo.zip
SIP_Proxy_demo
SIP_Proxy_demo.suo
SIP_Proxy_demo
bin
Debug
LumiSoft.Net.dll
SIP_Proxy_demo.exe
SIP_Proxy_demo.vshost.exe
dep
LumiSoft.Net.dll
LumiSoft.Net.pdb
Properties
Settings.settings
Resources
add.ico
app.ico
delete.ico
edit.ico
error.ico
info.ico
refresh.ico
rule.ico
server_running.ico
server_stopped.ico
viewmessages.ico
Stack.zip
Net
docs
dns
dns_records.jpg
dns_records.vsd
Net
_junk
_Obsolete
AUTH
bin
Release
LumiSoft.Net.dll
Data
Dns
Client
FTP
Client
Server
HTTP
Server
ICMP
IMAP
Client
Server
IO
Log
LumiSoft.Net
Mime
vCard
Net.csproj.user
Net.suo
NNTP
Client
POP3
Client
Server
RTP
SDP
ServersCore
SIP
Client
Message
Proxy
Stack
SMTP
Client
Server
STUN
Client
Message
URI
using System;
using System.Collections;
using System.Collections.Generic;

namespace LumiSoft.Net.POP3.Client
{
	/// <summary>
	/// Holds POP3 messages info.
	/// </summary>
	public class POP3_MessagesInfo : IEnumerable
	{
		private List<POP3_MessageInfo> m_pMessages = null;

		/// <summary>
		/// Default constructor.
		/// </summary>
		public POP3_MessagesInfo()
		{	
			m_pMessages = new List<POP3_MessageInfo>();
		}


		#region method Add

		/// <summary>
		/// Add message to pop3 messages collection.
		/// </summary>
		/// <param name="messageID">Message unique ID.</param>
		/// <param name="messageNo">Message number.</param>
		/// <param name="messageSize">Message size in bytes.</param>
		internal void Add(string messageID,int messageNo,long messageSize)
		{
			m_pMessages.Add(new POP3_MessageInfo(messageID,messageNo,messageSize));
		}

		#endregion


		#region method Contains

		/// <summary>
		/// Gets if collection contains message with specified number.
		/// </summary>
		/// <param name="messageNo">Message number.</param>
		/// <returns></returns>
		public bool Contains(int messageNo)
		{
			foreach(POP3_MessageInfo msgInfo in this){
				if(msgInfo.MessageNumber == messageNo){
					return true;
				}
			}

			return false;
		}

		/// <summary>
		/// Gets if collection contains message with specified UID.
		/// </summary>
		/// <param name="messageUID">Message unique ID.</param>
		/// <returns></returns>
		public bool Contains(string messageUID)
		{
			foreach(POP3_MessageInfo msgInfo in this){
				if(msgInfo.MessageUID == messageUID){
					return true;
				}
			}

			return false;
		}

		#endregion


		#region method GetByNo

		/// <summary>
		/// Gets message by MessageNumber. Returns null if sepcified message info doesn't exist.
		/// </summary>
		/// <param name="messageNo">Message number.</param>
		/// <returns></returns>
		public POP3_MessageInfo GetByNo(int messageNo)
		{
			foreach(POP3_MessageInfo msgInfo in this){
				if(msgInfo.MessageNumber == messageNo){
					return msgInfo;
				}
			}

			return null;
		}

		#endregion

		#region method GetByUID

		/// <summary>
		/// Gets message by MessageUID. Returns null if sepcified message info doesn't exist.
		/// </summary>
		/// <param name="messageUID">Message UID.</param>
		/// <returns></returns>
		public POP3_MessageInfo GetByUID(string messageUID)
		{
			foreach(POP3_MessageInfo msgInfo in this){
				if(msgInfo.MessageUID == messageUID){
					return msgInfo;
				}
			}

			return null;
		}

		#endregion



		#region interface IEnumerator

		/// <summary>
		/// Gets enumerator.
		/// </summary>
		/// <returns></returns>
		public IEnumerator GetEnumerator()
		{
			return m_pMessages.GetEnumerator();
		}

		#endregion

		#region Properties Implementation

		/// <summary>
		/// Gets specified pop3 message info at specified index from collection.
		/// </summary>
		public POP3_MessageInfo this[int index]
		{
			get{
				if(index > -1 && index < m_pMessages.Count){
					return m_pMessages[index];
				}
				else{
					throw new Exception("No such message !");
				}
			}
		}

		/// <summary>
		/// Gets total size of messages in bytes.
		/// </summary>
		public long TotalSize
		{
			get{ 
				long sizeTotal = 0;
				foreach(POP3_MessageInfo msg in this.Messages){
					sizeTotal += msg.MessageSize;
				}
				return sizeTotal; 
			}
		}

		/// <summary>
		/// Gets messages count.
		/// </summary>
		public int Count
		{
			get{ return m_pMessages.Count; }
		}

		/// <summary>
		/// Gets pop3 messages info as array.
		/// </summary>
		public POP3_MessageInfo[] Messages
		{
			get{ return m_pMessages.ToArray(); }
		}

		#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)

Share

About the Author

Ivar Lumi

Estonia Estonia
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411023.1 | Last Updated 11 Jun 2007
Article Copyright 2007 by Ivar Lumi
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid