/*
* (standard BSD license)
*
* Copyright (c) 2002, Chad Myers, et al.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary form
* must reproduce the above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other materials provided with
* the distribution. Neither the name of SourceForge, nor Microsoft nor the names
* of its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
namespace MSNP{
/// <summary>
/// Represents a contact in a contact list.
/// </summary>
/// <remarks>
/// This class is returned whenever a list of contacts is requested from the <see cref="MSNPHelper"/>.
/// </remarks>
public class Contact
{
/***************************************************************
* Fields
***************************************************************/
private String m_UserName;
private String m_FriendlyName;
private String m_State;
private String m_Substate;
/***************************************************************
* Constructors
***************************************************************/
/// <summary>
/// Main constructor
/// </summary>
/// <param name="userName">The user handle (email address) for this user</param>
internal Contact(String userName)
{
m_UserName = userName;
m_State = "Offline";
m_Substate = "";
}
/// <summary>
/// Constructs a contact with a user handle and friendly name
/// </summary>
/// <param name="userName">The user handle (email address) for this user</param>
/// <param name="friendlyName">The friendly name of the user</param>
internal Contact(String userName, String friendlyName) :
this(userName)
{
m_FriendlyName = friendlyName;
}
/***************************************************************
* Properties
***************************************************************/
/// <summary>Returns the username or handle of this contact.</summary>
/// <remarks>This is usually the email of the contact (johndoe@msn.com).</remarks>
/// <value>The user handle of the contact</value>
public String UserName { get{ return m_UserName; } }
/// <summary>The friendly name or display name of the contact</summary>
/// <remarks>This is more friendly name of the contact such as John Doe</remarks>
/// <value>The friendly name or display name of the contact</value>
public String FriendlyName { get{ return m_FriendlyName; } }
/// <summary>The current state of the user</summary>
/// <remarks>This will either be NLN or FLN for online or offline</remarks>
/// <value>The current state of the user</value>
public String State { get{ return m_State; } }
/// <summary>The substate of the user</summary>
/// <remarks><para>This only applies when <see cref="State"/> is NLN (online) and will be empty when <see cref="State"/> is FLN.</para>
/// <para>The following are the supported substates:
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <description>Meaning</description>
/// </listheader>
/// <item>
/// <term>IDL</term>
/// <description>Idle</description>
/// </item>
/// <item>
/// <term>BRB</term>
/// <description>Be Right Back</description>
/// </item>
/// <item>
/// <term>AWY</term>
/// <description>Away</description>
/// </item>
/// <item>
/// <term>PHN</term>
/// <description>On The Phone</description>
/// </item>
/// <item>
/// <term>LUN</term>
/// <description>Out To Lunch</description>
/// </item>
/// </list></para>
/// </remarks>
/// <value>The substate of the contact</value>
public String Substate{ get{ return m_Substate; } }
/***************************************************************
* Internal Methods
***************************************************************/
internal void setUserName(String name){ m_UserName = name; }
internal void setFriendlyName(String name){ m_FriendlyName = name; }
internal void setState(String state)
{
if( state == ConnectionHandler.NLN )
m_State = "Online";
else if( state == ConnectionHandler.HDN )
{
m_State = "Hidden";
m_Substate = "";
}
else
{
m_State = "Offline";
m_Substate = "";
}
}
internal void setSubstate(String substate)
{
if( substate == ConnectionHandler.BSY )
{
m_State = "Online";
m_Substate = "Busy";
}
else if( substate == ConnectionHandler.IDL )
{
m_State = "Online";
m_Substate = "Idle";
}
else if( substate == ConnectionHandler.BRB )
{
m_State = "Online";
m_Substate = "Be Right Back";
}
else if( substate == ConnectionHandler.AWY )
{
m_State = "Online";
m_Substate = "Away From Computer";
}
else if( substate == ConnectionHandler.PHN )
{
m_State = "Online";
m_Substate = "On The Phone";
}
else if( substate == ConnectionHandler.LUN )
{
m_State = "Online";
m_Substate = "Out To Lunch";
}
else if( substate == ConnectionHandler.NLN )
{
m_State = "Online";
m_Substate = "Online";
}
}
/***************************************************************
* Public Methods
***************************************************************/
/// <summary>
/// Returns a string representation of the contact. Useful for debugging purposes only.
/// </summary>
public override string ToString()
{
return "contact[handle: " + m_UserName + " fn: " + m_FriendlyName + " st: " + m_State + " ss: " + m_Substate + "]";
}
}
}
|