Автор: Пользователь скрыл имя, 08 Апреля 2012 в 14:17, курсовая работа
В первые годы существования Всемирной паутины пользователи общались преимущественно через электронную почту, но отправлять письма было неудобно и даже нерационально, если оба собеседника одновременно находились в Интернете. Все изменилось, когда появились первые программы мгновенного общения или, менее официально, мессенджеры или интернет-пейджеры.
Введение 5
1 Аналитический обзор литературы
1.1 Анализ предметной области
1.2 Сравнительная характеристика существующих аналогов 8
1.3 Постановка задачи 10
2 Модели, положенные в основу ПС
2.1 Функциональные модели
2.2 Разработка спецификации требований к программному средству 13
3 Разработка программного средства
3.1 Обоснование выбора среды разаработки
3.2 Особенности реализации
3.3 Разработка программной архитектуры
4 Тестирование программного средства
5 Методика работы с программным средством 20
Заключение
Список использованных источников
Приложение A. Листинг программного средства
ЛИСТИНГ ПРОГРАММНОГО СРЕДСТВА
using System;
using System.Collections;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using csammisrun.OscarLib.Utility;
namespace csammisrun.OscarLib
{
#region Logged in / out exceptions
/// <summary>
/// Thrown when an operation is requested that requires the <see cref="Session"/>
/// to be logged in
/// </summary>
public class NotLoggedInException : Exception
{
}
/// <summary>
/// Thrown when an operation is requested that requires the <see cref="Session"/>
/// to be logged out
/// </summary>
public class LoggedInException : Exception
{
private readonly string _message;
/// <summary>
/// Creates a new LoggedInException with a blank message
/// </summary>
public LoggedInException()
{
_message = "";
}
/// <summary>
/// Creates a new LoggedInException
/// </summary>
/// <param name="message">The message to be passed with the exception</param>
public LoggedInException(string message)
{
_message = message;
}
/// <summary>
/// Gets a message that describes the current exception
/// </summary>
public override string Message
{
get { return _message; }
}
}
#endregion
/// <summary>
/// The representation of an AOL Instant Messenger or ICQ session
/// </summary>
public class Session
{
private readonly OSCARIdentification _clientid = new OSCARIdentification();
private readonly string _password;
private readonly Hashtable _requestidstorage = new Hashtable();
private readonly AuthorizationManager authManager;
private readonly ChatRoomManager chatRoomManager;
private readonly ConnectionManager connectionManager;
private readonly PacketDispatcher dispatcher = new PacketDispatcher();
private readonly FamilyManager familyManager = new FamilyManager();
private readonly GraphicsManager graphicsManager;
private readonly IcqManager icqManager;
private readonly LimitManager limitManager = new LimitManager();
private readonly MessageManager messageManager;
private readonly RateClassManager rateManager;
private readonly SearchManager searchManager;
private readonly ServiceManager serviceManager;
private readonly SSIManager ssiManager;
private readonly StatusManager statusManager;
private Capabilities _caps = Capabilities.OscarLib;
private bool _loggedin;
private ushort _loginport = 5190;
private ushort _parametercount;
private PrivacySetting _privacy;
private bool _publicidletime;
private string _screenname;
/// <summary>
/// Create a new OSCAR session
/// </summary>
/// <param name="screenname">The screenname to log in</param>
/// <param name="password">The password associated with the screenname</param>
/// <exception cref="ArgumentException">Throw
/// a valid AIM or ICQ screenname.</exception>
public Session(string screenname, string password)
{
// Check to make sure the screenname is something valid
if (!ScreennameVerifier.
!ScreennameVerifier.
{
throw new ArgumentException(screenname + " is not a valid AIM or ICQ screenname", "screenname");
}
// Save parameter values
_screenname = screenname;
_password = password;
connectionManager = new ConnectionManager(this);
serviceManager = new ServiceManager(this);
ssiManager = new SSIManager(this);
icqManager = new IcqManager(this);
messageManager = new MessageManager(this);
statusManager = new StatusManager(this);
chatRoomManager = new ChatRoomManager(this);
graphicsManager = new GraphicsManager(this);
authManager = new AuthorizationManager(this);
searchManager = new SearchManager(this);
rateManager = new RateClassManager(this);
connectionManager.
// Create a default set of capabilities for this session
SetDefaultIdentification();
// Set up some default values for public properties
_publicidletime = true;
// Set initial values for internal properties
_loggedin = false;
_privacy = PrivacySetting.AllowAllUsers;
_parametercount = 0;
}
#region Public methods
/// <summary>
/// Sets the session's <see cref="ClientIdentification"/> to the AOL defaults
/// </summary>
/// <exception cref="LoggedInException">Throw
public void SetDefaultIdentification()
{
if (LoggedIn)
{
throw new LoggedInException("
}
_clientid.ClientName = Constants.CLIENT_NAME;
_clientid.ClientId = Constants.CLIENT_ID;
_clientid.ClientMajor = Constants.CLIENT_MAJOR;
_clientid.ClientMinor = Constants.CLIENT_MINOR;
_clientid.ClientLesser = Constants.CLIENT_LESSER;
_clientid.ClientBuild = Constants.CLIENT_BUILD;
_clientid.ClientDistribution = Constants.CLIENT_DISTRIBUTION;
}
/// <summary>
/// Initialize the logging system
/// </summary>
/// <param name="baseDir">The directory in which to save log files</param>
/// <returns>The full logfile path</returns>
public string InitializeLogger(string baseDir)
{
// Initialize the logging system
DateTime currentTime = DateTime.Now;
string logfileName = String.Empty;
logfileName += ScreenName + "_";
logfileName += currentTime.Year.ToString("
currentTime.Day.ToString("00") + "_";
logfileName += currentTime.Hour.ToString("00"
currentTime.Second.ToString("
logfileName += currentTime.Millisecond.
logfileName += "OscarLib.log";
string logFilePath = Path.Combine(baseDir, logfileName);
if (!Directory.Exists(Path.
{
Directory.CreateDirectory(Path
}
Logging.sw = new StreamWriter(logFilePath);
return logFilePath;
}
/// <summary>
/// Begins the process of logging in to the OSCAR service
/// </summary>
/// <param name="loginserver">The OSCAR login server</param>
/// <param name="port">The OSCAR service port</param>
/// <remarks>
/// <para>
/// This function is non-blocking, because the login process does not happen
/// instantly. The OSCAR library will raise the <see cref="Session.LoginCompleted"/
/// when the login process has finished successfully.
/// </para>
/// <para>
/// The OSCAR library raises periodic status update events throughout the login process
/// via the <see cref="Session.StatusUpdate"/> event.
/// </para>
/// <para>
/// Errors may occur during the login process; if an error occurs, the OSCAR library raises
/// the <see cref="Session.ErrorMessage"/> event, and stops the remaining login sequence.
/// </para>
/// </remarks>
/// <exception cref="LoggedInException">Throw
public void Logon(string loginserver, int port)
{
if (LoggedIn)
{
throw new LoggedInException();
}
LoggedIn = false;
Authorization.LoginToService(
OnLoginStatusUpdate("
}
/// <summary>
/// Disconnects all active OSCAR connections and resets the session
/// </summary>
public void Logoff()
{
LoggedIn = false;
foreach (Connection conn in connectionManager.
{
conn.DisconnectFromServer(fals
}
}
/// <summary>
/// Adds a buddy to the client's server-side buddy list
/// </summary>
/// <param name="screenname">The screenname of the buddy to add</param>
/// <param name="parentID">The ID of the parent group of the buddy</param>
/// <param name="index">The index of the buddy in the group</param>
/// <param name="alias">The alias of the buddy ("" for none)</param>
/// <param name="email">The email address of the buddy ("" for none)</param>
/// <param name="comment">The comment to be stored for the buddy ("" for none)</param>
/// <param name="SMS">The SMS number for the buddy ("" for none)</param>
/// <param name="soundfile">The soundfile for the buddy ("" for none)</param>
/// <param name="authorziationRequired"><
///<param name="authorizationReason">The authorization reason/message that will be send to the client</param>
/// <exception cref="NotLoggedInException">Th
/// <remarks>This function will probably not remain here; the SSI Manager will be made public</remarks>
[Obsolete(
"This method is obsolete and will be removed soon. Use the overloaded AddBuddy method without the index parameter."
)]
public void AddBuddy(string screenname, ushort parentID, int index, string alias, string email, string comment,
string SMS, string soundfile, bool authorziationRequired, string authorizationReason)
{
if (!LoggedIn)
{
throw new NotLoggedInException();
}
SSI.AddBuddy(screenname, parentID, index, alias, email, SMS, comment, soundfile, authorziationRequired,
authorizationReason);
}
/// <summary>
/// Adds a buddy to the client's server-side buddy list
/// </summary>
/// <param name="screenname">The screenname of the buddy to add</param>
/// <param name="parentID">The ID of the parent group of the buddy</param>
/// <param name="alias">The alias of the buddy ("" for none)</param>
/// <param name="email">The email address of the buddy ("" for none)</param>
/// <param name="comment">The comment to be stored for the buddy ("" for none)</param>
/// <param name="SMS">The SMS number for the buddy ("" for none)</param>
/// <param name="soundfile">The soundfile for the buddy ("" for none)</param>
/// <param name="authorziationRequired"><
///<param name="authorizationReason">The authorization reason/message that will be send to the client</param>
/// <exception cref="NotLoggedInException">Th
/// <remarks>This function will probably not remain here; the SSI Manager will be made public</remarks>
public void AddBuddy(string screenname, ushort parentID, string alias, string email, string comment,
string SMS, string soundfile, bool authorziationRequired, string authorizationReason)
{
if (!LoggedIn)
{
throw new NotLoggedInException();
}
SSI.AddBuddy(screenname, parentID, alias, email, SMS, comment, soundfile, authorziationRequired,
authorizationReason);
}
/// <summary>
/// Moves a buddy
/// </summary>
/// <param name="buddyID">The ID of the buddy to move</param>
/// <param name="parentID">The ID of the destination group</param>
/// <param name="index">The index in the destination group to move to</param>
public void MoveBuddy(ushort buddyID, ushort parentID, int index)
{
if (!LoggedIn)
{
throw new NotLoggedInException();
}
SSI.MoveBuddy(SSI.
}
/// <summary>
/// Remove a buddy
/// </summary>
/// <param name="buddyID">The ID of the buddy to remove</param>
public void RemoveBuddy(ushort buddyID, ushort parentID)
{
if (!LoggedIn)
{
throw new NotLoggedInException();
}
SSIBuddy buddy = SSI.GetBuddyByID(buddyID, parentID);
if (buddy != null)
SSI.RemoveBuddy(buddy);
}
/// <summary>
/// Adds a group to the client's server-side buddy list
/// </summary>
/// <param name="groupname">The name of the new group</param>
/// <param name="index">The index into the current list of groups</param>
[Obsolete(
"This method is obsolete and will be removed soon. Use the overloaded AddGroup methods without the index parameter."
)]
public void AddGroup(string groupname, int index)
{
if (!LoggedIn)
{
throw new NotLoggedInException();
}
SSI.AddGroup(groupname, index);
}
/// <summary>
/// Adds a group to the client's server-side buddy list
/// </summary>
/// <param name="groupname">The name of the new group</param>
/// <param name="id">The group id</param>
public void AddGroup(string groupname, ushort id)
{
if (!LoggedIn)
{
throw new NotLoggedInException();
}
SSI.AddGroup(groupname, id);
}
/// <summary>
/// Adds a group to the client's server-side buddy list
/// </summary>
/// <param name="groupname">The name of the new group</param>
public void AddGroup(string groupname)
{
if (!LoggedIn)
{
throw new NotLoggedInException();
}
SSI.AddGroup(groupname);
}
/// <summary>
/// Adds the master group. This is necessary if a contact list is empty to add further groups after
/// </summary>
/// <param name="groupname">The master group name</param>
public void AddMasterGroup(string groupname)
{
if (!LoggedIn)
{
throw new NotLoggedInException();
}
AddGroup(groupname, (ushort) 0);
}
/// <summary>
/// Move a group in the buddy list
/// </summary>
/// <param name="groupID">The ID of the group to move</param>
/// <param name="index">The new index of the group</param>
public void MoveGroup(ushort groupID, int index)
{
if (!LoggedIn)
{
throw new NotLoggedInException();
}
SSI.MoveGroup(SSI.
}
/// <summary>
/// Remove a group from the server-side buddy list
/// </summary>
/// <param name="groupID">ID of the group to remove</param>
public void RemoveGroup(ushort groupID)
{
if (!LoggedIn)
{
throw new NotLoggedInException();
}
SSIGroup group = SSI.GetGroupByID(groupID);
if (group != null)
SSI.RemoveGroup(group);
}
/// <summary>
/// Tells AIM to begin sending UserStatus objects to client (online or away)
/// Client should call in response to <see cref="ContactListFinished"/> event
/// </summary>
public void ActivateBuddyList()
{
SNAC13.ActivateSSI(this);
OnLoginComplete();
}