Contact.cs :  » Network-Clients » MSNP-Helper-API » MSNP » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Network Clients » MSNP Helper API 
MSNP Helper API » MSNP » Contact.cs
/*
 * (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 + "]";
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.