Add the files
123
Example/AddContactForm.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
partial class AddContactForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.lblAccount = new System.Windows.Forms.Label();
|
||||||
|
this.txtAccount = new System.Windows.Forms.TextBox();
|
||||||
|
this.txtInvitation = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblInvitation = new System.Windows.Forms.Label();
|
||||||
|
this.btnOK = new System.Windows.Forms.Button();
|
||||||
|
this.btnCancel = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// lblAccount
|
||||||
|
//
|
||||||
|
this.lblAccount.AutoSize = true;
|
||||||
|
this.lblAccount.Location = new System.Drawing.Point(4, 21);
|
||||||
|
this.lblAccount.Name = "lblAccount";
|
||||||
|
this.lblAccount.Size = new System.Drawing.Size(106, 13);
|
||||||
|
this.lblAccount.TabIndex = 0;
|
||||||
|
this.lblAccount.Text = "Messenger address:*";
|
||||||
|
//
|
||||||
|
// txtAccount
|
||||||
|
//
|
||||||
|
this.txtAccount.CharacterCasing = System.Windows.Forms.CharacterCasing.Lower;
|
||||||
|
this.txtAccount.Location = new System.Drawing.Point(115, 18);
|
||||||
|
this.txtAccount.Name = "txtAccount";
|
||||||
|
this.txtAccount.Size = new System.Drawing.Size(250, 20);
|
||||||
|
this.txtAccount.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// txtInvitation
|
||||||
|
//
|
||||||
|
this.txtInvitation.Location = new System.Drawing.Point(115, 47);
|
||||||
|
this.txtInvitation.Name = "txtInvitation";
|
||||||
|
this.txtInvitation.Size = new System.Drawing.Size(250, 20);
|
||||||
|
this.txtInvitation.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// lblInvitation
|
||||||
|
//
|
||||||
|
this.lblInvitation.AutoSize = true;
|
||||||
|
this.lblInvitation.Location = new System.Drawing.Point(12, 50);
|
||||||
|
this.lblInvitation.Name = "lblInvitation";
|
||||||
|
this.lblInvitation.Size = new System.Drawing.Size(98, 13);
|
||||||
|
this.lblInvitation.TabIndex = 4;
|
||||||
|
this.lblInvitation.Text = "Invitation message:";
|
||||||
|
//
|
||||||
|
// btnOK
|
||||||
|
//
|
||||||
|
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||||
|
this.btnOK.Location = new System.Drawing.Point(209, 84);
|
||||||
|
this.btnOK.Name = "btnOK";
|
||||||
|
this.btnOK.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnOK.TabIndex = 3;
|
||||||
|
this.btnOK.Text = "OK";
|
||||||
|
this.btnOK.UseVisualStyleBackColor = true;
|
||||||
|
this.btnOK.Click += new System.EventHandler(this.btn_Click);
|
||||||
|
//
|
||||||
|
// btnCancel
|
||||||
|
//
|
||||||
|
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
|
this.btnCancel.Location = new System.Drawing.Point(290, 84);
|
||||||
|
this.btnCancel.Name = "btnCancel";
|
||||||
|
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnCancel.TabIndex = 4;
|
||||||
|
this.btnCancel.Text = "Cancel";
|
||||||
|
this.btnCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.btnCancel.Click += new System.EventHandler(this.btn_Click);
|
||||||
|
//
|
||||||
|
// AddContactForm
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(373, 119);
|
||||||
|
this.Controls.Add(this.btnCancel);
|
||||||
|
this.Controls.Add(this.btnOK);
|
||||||
|
this.Controls.Add(this.txtInvitation);
|
||||||
|
this.Controls.Add(this.lblInvitation);
|
||||||
|
this.Controls.Add(this.txtAccount);
|
||||||
|
this.Controls.Add(this.lblAccount);
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.MinimizeBox = false;
|
||||||
|
this.Name = "AddContactForm";
|
||||||
|
this.Text = "Add New Contact";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Label lblAccount;
|
||||||
|
private System.Windows.Forms.TextBox txtAccount;
|
||||||
|
private System.Windows.Forms.TextBox txtInvitation;
|
||||||
|
private System.Windows.Forms.Label lblInvitation;
|
||||||
|
private System.Windows.Forms.Button btnOK;
|
||||||
|
private System.Windows.Forms.Button btnCancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
50
Example/AddContactForm.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
public partial class AddContactForm : Form
|
||||||
|
{
|
||||||
|
public AddContactForm(string account)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(account))
|
||||||
|
{
|
||||||
|
this.account = account;
|
||||||
|
txtAccount.Text = account;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string account;
|
||||||
|
public string Account
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string invitationMessage;
|
||||||
|
public string InvitationMessage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return invitationMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
account = txtAccount.Text;
|
||||||
|
invitationMessage = txtInvitation.Text;
|
||||||
|
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
Example/AddContactForm.resx
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
240
Example/ContactCardForm.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,240 @@
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
partial class ContactCardForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows 窗体设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.pnlSpace = new System.Windows.Forms.Panel();
|
||||||
|
this.panel3 = new System.Windows.Forms.Panel();
|
||||||
|
this.lblSpaceTitle = new System.Windows.Forms.LinkLabel();
|
||||||
|
this.lblDisplayName = new System.Windows.Forms.Label();
|
||||||
|
this.picDisplayImage = new System.Windows.Forms.PictureBox();
|
||||||
|
this.pnlAlbum = new System.Windows.Forms.Panel();
|
||||||
|
this.tlpnlAlbum = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.lnkAlbumName = new System.Windows.Forms.LinkLabel();
|
||||||
|
this.pnlBlog = new System.Windows.Forms.Panel();
|
||||||
|
this.lnkBlogContent = new System.Windows.Forms.LinkLabel();
|
||||||
|
this.lnkBlogTitle = new System.Windows.Forms.LinkLabel();
|
||||||
|
this.pnlProfile = new System.Windows.Forms.Panel();
|
||||||
|
this.ttips = new System.Windows.Forms.ToolTip(this.components);
|
||||||
|
this.pnlSpace.SuspendLayout();
|
||||||
|
this.panel3.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.picDisplayImage)).BeginInit();
|
||||||
|
this.pnlAlbum.SuspendLayout();
|
||||||
|
this.pnlBlog.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// pnlSpace
|
||||||
|
//
|
||||||
|
this.pnlSpace.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255)))));
|
||||||
|
this.pnlSpace.Controls.Add(this.panel3);
|
||||||
|
this.pnlSpace.Controls.Add(this.picDisplayImage);
|
||||||
|
this.pnlSpace.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.pnlSpace.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.pnlSpace.Name = "pnlSpace";
|
||||||
|
this.pnlSpace.Padding = new System.Windows.Forms.Padding(10);
|
||||||
|
this.pnlSpace.Size = new System.Drawing.Size(272, 76);
|
||||||
|
this.pnlSpace.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// panel3
|
||||||
|
//
|
||||||
|
this.panel3.Controls.Add(this.lblSpaceTitle);
|
||||||
|
this.panel3.Controls.Add(this.lblDisplayName);
|
||||||
|
this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.panel3.Location = new System.Drawing.Point(69, 10);
|
||||||
|
this.panel3.Name = "panel3";
|
||||||
|
this.panel3.Size = new System.Drawing.Size(193, 56);
|
||||||
|
this.panel3.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// lblSpaceTitle
|
||||||
|
//
|
||||||
|
this.lblSpaceTitle.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.lblSpaceTitle.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
|
||||||
|
this.lblSpaceTitle.Location = new System.Drawing.Point(0, 23);
|
||||||
|
this.lblSpaceTitle.Margin = new System.Windows.Forms.Padding(0);
|
||||||
|
this.lblSpaceTitle.Name = "lblSpaceTitle";
|
||||||
|
this.lblSpaceTitle.Padding = new System.Windows.Forms.Padding(10, 0, 0, 0);
|
||||||
|
this.lblSpaceTitle.Size = new System.Drawing.Size(193, 19);
|
||||||
|
this.lblSpaceTitle.TabIndex = 2;
|
||||||
|
this.lblSpaceTitle.TabStop = true;
|
||||||
|
this.lblSpaceTitle.Text = "Space Title";
|
||||||
|
this.lblSpaceTitle.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lblSpaceTitle_LinkClicked);
|
||||||
|
//
|
||||||
|
// lblDisplayName
|
||||||
|
//
|
||||||
|
this.lblDisplayName.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.lblDisplayName.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.lblDisplayName.Margin = new System.Windows.Forms.Padding(0);
|
||||||
|
this.lblDisplayName.Name = "lblDisplayName";
|
||||||
|
this.lblDisplayName.Padding = new System.Windows.Forms.Padding(10, 0, 0, 0);
|
||||||
|
this.lblDisplayName.Size = new System.Drawing.Size(193, 23);
|
||||||
|
this.lblDisplayName.TabIndex = 1;
|
||||||
|
this.lblDisplayName.Text = "Display Name";
|
||||||
|
//
|
||||||
|
// picDisplayImage
|
||||||
|
//
|
||||||
|
this.picDisplayImage.BackColor = System.Drawing.Color.White;
|
||||||
|
this.picDisplayImage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.picDisplayImage.Dock = System.Windows.Forms.DockStyle.Left;
|
||||||
|
this.picDisplayImage.Location = new System.Drawing.Point(10, 10);
|
||||||
|
this.picDisplayImage.Name = "picDisplayImage";
|
||||||
|
this.picDisplayImage.Size = new System.Drawing.Size(59, 56);
|
||||||
|
this.picDisplayImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||||
|
this.picDisplayImage.TabIndex = 1;
|
||||||
|
this.picDisplayImage.TabStop = false;
|
||||||
|
//
|
||||||
|
// pnlAlbum
|
||||||
|
//
|
||||||
|
this.pnlAlbum.BackColor = System.Drawing.Color.Linen;
|
||||||
|
this.pnlAlbum.Controls.Add(this.tlpnlAlbum);
|
||||||
|
this.pnlAlbum.Controls.Add(this.lnkAlbumName);
|
||||||
|
this.pnlAlbum.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.pnlAlbum.Location = new System.Drawing.Point(0, 76);
|
||||||
|
this.pnlAlbum.Name = "pnlAlbum";
|
||||||
|
this.pnlAlbum.Padding = new System.Windows.Forms.Padding(5);
|
||||||
|
this.pnlAlbum.Size = new System.Drawing.Size(272, 65);
|
||||||
|
this.pnlAlbum.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// tlpnlAlbum
|
||||||
|
//
|
||||||
|
this.tlpnlAlbum.ColumnCount = 6;
|
||||||
|
this.tlpnlAlbum.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
|
||||||
|
this.tlpnlAlbum.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
|
||||||
|
this.tlpnlAlbum.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
|
||||||
|
this.tlpnlAlbum.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
|
||||||
|
this.tlpnlAlbum.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
|
||||||
|
this.tlpnlAlbum.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
|
||||||
|
this.tlpnlAlbum.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tlpnlAlbum.Location = new System.Drawing.Point(5, 17);
|
||||||
|
this.tlpnlAlbum.Name = "tlpnlAlbum";
|
||||||
|
this.tlpnlAlbum.RowCount = 1;
|
||||||
|
this.tlpnlAlbum.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tlpnlAlbum.Size = new System.Drawing.Size(262, 43);
|
||||||
|
this.tlpnlAlbum.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// lnkAlbumName
|
||||||
|
//
|
||||||
|
this.lnkAlbumName.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.lnkAlbumName.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
|
||||||
|
this.lnkAlbumName.Location = new System.Drawing.Point(5, 5);
|
||||||
|
this.lnkAlbumName.Name = "lnkAlbumName";
|
||||||
|
this.lnkAlbumName.Size = new System.Drawing.Size(262, 12);
|
||||||
|
this.lnkAlbumName.TabIndex = 0;
|
||||||
|
this.lnkAlbumName.TabStop = true;
|
||||||
|
this.lnkAlbumName.Text = "Album Name";
|
||||||
|
this.lnkAlbumName.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkAlbumName_LinkClicked);
|
||||||
|
//
|
||||||
|
// pnlBlog
|
||||||
|
//
|
||||||
|
this.pnlBlog.BackColor = System.Drawing.Color.Linen;
|
||||||
|
this.pnlBlog.Controls.Add(this.lnkBlogContent);
|
||||||
|
this.pnlBlog.Controls.Add(this.lnkBlogTitle);
|
||||||
|
this.pnlBlog.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.pnlBlog.Location = new System.Drawing.Point(0, 141);
|
||||||
|
this.pnlBlog.Name = "pnlBlog";
|
||||||
|
this.pnlBlog.Padding = new System.Windows.Forms.Padding(5);
|
||||||
|
this.pnlBlog.Size = new System.Drawing.Size(272, 58);
|
||||||
|
this.pnlBlog.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// lnkBlogContent
|
||||||
|
//
|
||||||
|
this.lnkBlogContent.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.lnkBlogContent.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
|
||||||
|
this.lnkBlogContent.Location = new System.Drawing.Point(5, 17);
|
||||||
|
this.lnkBlogContent.Name = "lnkBlogContent";
|
||||||
|
this.lnkBlogContent.Size = new System.Drawing.Size(262, 36);
|
||||||
|
this.lnkBlogContent.TabIndex = 1;
|
||||||
|
this.lnkBlogContent.TabStop = true;
|
||||||
|
this.lnkBlogContent.Text = "Blog Content";
|
||||||
|
this.lnkBlogContent.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkBlogContent_LinkClicked);
|
||||||
|
//
|
||||||
|
// lnkBlogTitle
|
||||||
|
//
|
||||||
|
this.lnkBlogTitle.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.lnkBlogTitle.LinkBehavior = System.Windows.Forms.LinkBehavior.HoverUnderline;
|
||||||
|
this.lnkBlogTitle.LinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||||
|
this.lnkBlogTitle.Location = new System.Drawing.Point(5, 5);
|
||||||
|
this.lnkBlogTitle.Name = "lnkBlogTitle";
|
||||||
|
this.lnkBlogTitle.Size = new System.Drawing.Size(262, 12);
|
||||||
|
this.lnkBlogTitle.TabIndex = 0;
|
||||||
|
this.lnkBlogTitle.TabStop = true;
|
||||||
|
this.lnkBlogTitle.Text = "Blog Title";
|
||||||
|
this.lnkBlogTitle.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkBlogTitle_LinkClicked);
|
||||||
|
//
|
||||||
|
// pnlProfile
|
||||||
|
//
|
||||||
|
this.pnlProfile.BackColor = System.Drawing.Color.Linen;
|
||||||
|
this.pnlProfile.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pnlProfile.Location = new System.Drawing.Point(0, 199);
|
||||||
|
this.pnlProfile.Name = "pnlProfile";
|
||||||
|
this.pnlProfile.Padding = new System.Windows.Forms.Padding(5);
|
||||||
|
this.pnlProfile.Size = new System.Drawing.Size(272, 35);
|
||||||
|
this.pnlProfile.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// ContactCardForm
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(272, 234);
|
||||||
|
this.Controls.Add(this.pnlProfile);
|
||||||
|
this.Controls.Add(this.pnlBlog);
|
||||||
|
this.Controls.Add(this.pnlAlbum);
|
||||||
|
this.Controls.Add(this.pnlSpace);
|
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.Name = "ContactCardForm";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "ContactCard";
|
||||||
|
this.Load += new System.EventHandler(this.ContactCardForm_Load);
|
||||||
|
this.pnlSpace.ResumeLayout(false);
|
||||||
|
this.panel3.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.picDisplayImage)).EndInit();
|
||||||
|
this.pnlAlbum.ResumeLayout(false);
|
||||||
|
this.pnlBlog.ResumeLayout(false);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Panel pnlSpace;
|
||||||
|
private System.Windows.Forms.Panel panel3;
|
||||||
|
private System.Windows.Forms.LinkLabel lblSpaceTitle;
|
||||||
|
private System.Windows.Forms.Label lblDisplayName;
|
||||||
|
private System.Windows.Forms.PictureBox picDisplayImage;
|
||||||
|
private System.Windows.Forms.Panel pnlAlbum;
|
||||||
|
private System.Windows.Forms.TableLayoutPanel tlpnlAlbum;
|
||||||
|
private System.Windows.Forms.LinkLabel lnkAlbumName;
|
||||||
|
private System.Windows.Forms.Panel pnlBlog;
|
||||||
|
private System.Windows.Forms.Panel pnlProfile;
|
||||||
|
private System.Windows.Forms.LinkLabel lnkBlogContent;
|
||||||
|
private System.Windows.Forms.LinkLabel lnkBlogTitle;
|
||||||
|
private System.Windows.Forms.ToolTip ttips;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
109
Example/ContactCardForm.cs
Normal file
|
|
@ -0,0 +1,109 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using MSNPSharp;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
public partial class ContactCardForm : Form
|
||||||
|
{
|
||||||
|
private ContactCard card = null;
|
||||||
|
|
||||||
|
public ContactCardForm(ContactCard cc)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
card = cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ContactCardForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
lblDisplayName.Text = card.DisplayName;
|
||||||
|
lblSpaceTitle.Text = (card.Space != null) ? card.Space.Title : String.Empty;
|
||||||
|
|
||||||
|
if (String.IsNullOrEmpty(card.DisplayImageUrl))
|
||||||
|
{
|
||||||
|
picDisplayImage.Visible = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
picDisplayImage.LoadAsync(card.DisplayImageUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (card.Album != null)
|
||||||
|
{
|
||||||
|
lnkAlbumName.Text = card.Album.Title;
|
||||||
|
int col = 0;
|
||||||
|
foreach (ThumbnailImage img in card.Album.Photos) //Setting the thumbnail pictures.
|
||||||
|
{
|
||||||
|
PictureBox lnkPic = new PictureBox();
|
||||||
|
lnkPic.Dock = DockStyle.Fill;
|
||||||
|
lnkPic.Margin = new Padding(6);
|
||||||
|
lnkPic.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
lnkPic.SizeMode = PictureBoxSizeMode.Zoom;
|
||||||
|
lnkPic.BackColor = Color.White;
|
||||||
|
lnkPic.LoadAsync(img.ThumbnailUrl);
|
||||||
|
|
||||||
|
tlpnlAlbum.Controls.Add(lnkPic, col, 0);
|
||||||
|
lnkPic.Tag = col;
|
||||||
|
lnkPic.Visible = true;
|
||||||
|
lnkPic.Click += new EventHandler(lnkPic_Click);
|
||||||
|
ttips.SetToolTip(lnkPic, img.ToolTip);
|
||||||
|
col++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pnlAlbum.Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (card.NewPost != null)
|
||||||
|
{
|
||||||
|
lnkBlogTitle.Text = card.NewPost.Title;
|
||||||
|
ttips.SetToolTip(lnkBlogTitle, card.NewPost.Description);
|
||||||
|
lnkBlogContent.Text = card.NewPost.Description;
|
||||||
|
ttips.SetToolTip(lnkBlogContent, card.NewPost.Description);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pnlBlog.Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Text = card.DisplayName + "'s ContactCard";
|
||||||
|
}
|
||||||
|
|
||||||
|
void lnkPic_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Process.Start(card.Album.Photos[(int)((PictureBox)sender).Tag].Url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lnkPic_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||||
|
{
|
||||||
|
Process.Start(card.Album.Photos[(int)((LinkLabel)sender).Tag].Url);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lblSpaceTitle_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||||
|
{
|
||||||
|
Process.Start(card.Space.Url);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lnkAlbumName_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||||
|
{
|
||||||
|
Process.Start(card.Album.Url);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lnkBlogTitle_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||||
|
{
|
||||||
|
Process.Start(card.NewPost.Url);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lnkBlogContent_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||||
|
{
|
||||||
|
Process.Start(card.NewPost.Url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
123
Example/ContactCardForm.resx
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="ttips.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
1077
Example/ConversationForm.cs
Normal file
135
Example/ConversationForm.resx
Normal file
|
|
@ -0,0 +1,135 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="tsMessage.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>274, 14</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="onlineUsersDropDown.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>397, 18</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="dlgColor.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>158, 20</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="openCustomEmoticonDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 57</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
876
Example/DotMSNClient.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,876 @@
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
partial class ClientForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.ImageList1 = new System.Windows.Forms.ImageList(this.components);
|
||||||
|
this.userMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||||
|
this.sendIMMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.sendOIMMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.sendMIMMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
|
this.importContactsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.createCircleMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
|
this.blockMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.unblockMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.deleteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||||
|
this.openImageDialog = new System.Windows.Forms.OpenFileDialog();
|
||||||
|
this.tmrKeepOnLine = new System.Windows.Forms.Timer(this.components);
|
||||||
|
this.tmrNews = new System.Windows.Forms.Timer(this.components);
|
||||||
|
this.sortContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||||
|
this.toolStripSortByStatus = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.toolStripSortBygroup = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.toolStripDeleteGroup = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.groupContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||||
|
this.toolTipChangePhoto = new System.Windows.Forms.ToolTip(this.components);
|
||||||
|
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.WhatsUpPanel = new System.Windows.Forms.Panel();
|
||||||
|
this.lblNewsLink = new System.Windows.Forms.LinkLabel();
|
||||||
|
this.lblNews = new System.Windows.Forms.Label();
|
||||||
|
this.pbNewsPicture = new System.Windows.Forms.PictureBox();
|
||||||
|
this.cmdNext = new System.Windows.Forms.Button();
|
||||||
|
this.cmdPrev = new System.Windows.Forms.Button();
|
||||||
|
this.lblWhatsup = new System.Windows.Forms.Label();
|
||||||
|
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||||
|
this.propertyGrid = new System.Windows.Forms.PropertyGrid();
|
||||||
|
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.pnlTreeViewsContainer = new System.Windows.Forms.Panel();
|
||||||
|
this.treeViewFilterList = new System.Windows.Forms.TreeView();
|
||||||
|
this.treeViewFavoriteList = new System.Windows.Forms.TreeView();
|
||||||
|
this.SortPanel = new System.Windows.Forms.Panel();
|
||||||
|
this.txtSearch = new System.Windows.Forms.TextBox();
|
||||||
|
this.btnAddNew = new System.Windows.Forms.Button();
|
||||||
|
this.btnSortBy = new System.Windows.Forms.Button();
|
||||||
|
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.tableLayoutPanel5 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.displayImageBox = new System.Windows.Forms.PictureBox();
|
||||||
|
this.panel1 = new System.Windows.Forms.Panel();
|
||||||
|
this.tableLayoutPanel6 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.pnlLogin = new System.Windows.Forms.Panel();
|
||||||
|
this.pnlNameAndPM = new System.Windows.Forms.Panel();
|
||||||
|
this.btnSetMusic = new System.Windows.Forms.Button();
|
||||||
|
this.lblPM = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblName = new System.Windows.Forms.TextBox();
|
||||||
|
this.cbRobotMode = new System.Windows.Forms.CheckBox();
|
||||||
|
this.accountTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.loginButton = new System.Windows.Forms.Button();
|
||||||
|
this.passwordTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.tableLayoutPanel7 = new System.Windows.Forms.TableLayoutPanel();
|
||||||
|
this.comboPlaces = new System.Windows.Forms.ComboBox();
|
||||||
|
this.comboStatus = new System.Windows.Forms.ComboBox();
|
||||||
|
this.statusBar = new System.Windows.Forms.Label();
|
||||||
|
this.userMenuStrip.SuspendLayout();
|
||||||
|
this.sortContextMenu.SuspendLayout();
|
||||||
|
this.groupContextMenu.SuspendLayout();
|
||||||
|
this.tableLayoutPanel1.SuspendLayout();
|
||||||
|
this.WhatsUpPanel.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pbNewsPicture)).BeginInit();
|
||||||
|
this.splitContainer1.Panel1.SuspendLayout();
|
||||||
|
this.splitContainer1.Panel2.SuspendLayout();
|
||||||
|
this.splitContainer1.SuspendLayout();
|
||||||
|
this.tableLayoutPanel2.SuspendLayout();
|
||||||
|
this.pnlTreeViewsContainer.SuspendLayout();
|
||||||
|
this.SortPanel.SuspendLayout();
|
||||||
|
this.tableLayoutPanel3.SuspendLayout();
|
||||||
|
this.tableLayoutPanel4.SuspendLayout();
|
||||||
|
this.tableLayoutPanel5.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.displayImageBox)).BeginInit();
|
||||||
|
this.panel1.SuspendLayout();
|
||||||
|
this.tableLayoutPanel6.SuspendLayout();
|
||||||
|
this.pnlLogin.SuspendLayout();
|
||||||
|
this.pnlNameAndPM.SuspendLayout();
|
||||||
|
this.tableLayoutPanel7.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// ImageList1
|
||||||
|
//
|
||||||
|
this.ImageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
|
||||||
|
this.ImageList1.ImageSize = new System.Drawing.Size(10, 10);
|
||||||
|
this.ImageList1.TransparentColor = System.Drawing.Color.Transparent;
|
||||||
|
//
|
||||||
|
// userMenuStrip
|
||||||
|
//
|
||||||
|
this.userMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.sendIMMenuItem,
|
||||||
|
this.sendOIMMenuItem,
|
||||||
|
this.sendMIMMenuItem,
|
||||||
|
this.toolStripMenuItem3,
|
||||||
|
this.importContactsMenuItem,
|
||||||
|
this.createCircleMenuItem,
|
||||||
|
this.toolStripMenuItem2,
|
||||||
|
this.blockMenuItem,
|
||||||
|
this.unblockMenuItem,
|
||||||
|
this.deleteMenuItem});
|
||||||
|
this.userMenuStrip.Name = "contextMenuStrip1";
|
||||||
|
this.userMenuStrip.Size = new System.Drawing.Size(201, 192);
|
||||||
|
//
|
||||||
|
// sendIMMenuItem
|
||||||
|
//
|
||||||
|
this.sendIMMenuItem.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold);
|
||||||
|
this.sendIMMenuItem.Name = "sendIMMenuItem";
|
||||||
|
this.sendIMMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||||
|
this.sendIMMenuItem.Text = "Send Instant Message";
|
||||||
|
this.sendIMMenuItem.Click += new System.EventHandler(this.sendMessageToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// sendOIMMenuItem
|
||||||
|
//
|
||||||
|
this.sendOIMMenuItem.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold);
|
||||||
|
this.sendOIMMenuItem.Name = "sendOIMMenuItem";
|
||||||
|
this.sendOIMMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||||
|
this.sendOIMMenuItem.Text = "Send Offline Message";
|
||||||
|
this.sendOIMMenuItem.Click += new System.EventHandler(this.sendOfflineMessageToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// sendMIMMenuItem
|
||||||
|
//
|
||||||
|
this.sendMIMMenuItem.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold);
|
||||||
|
this.sendMIMMenuItem.Name = "sendMIMMenuItem";
|
||||||
|
this.sendMIMMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||||
|
this.sendMIMMenuItem.Text = "Send Mobile Message";
|
||||||
|
this.sendMIMMenuItem.Click += new System.EventHandler(this.sendMIMMenuItem_Click);
|
||||||
|
//
|
||||||
|
// toolStripMenuItem3
|
||||||
|
//
|
||||||
|
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
|
||||||
|
this.toolStripMenuItem3.Size = new System.Drawing.Size(197, 6);
|
||||||
|
//
|
||||||
|
// importContactsMenuItem
|
||||||
|
//
|
||||||
|
this.importContactsMenuItem.Name = "importContactsMenuItem";
|
||||||
|
this.importContactsMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||||
|
this.importContactsMenuItem.Text = "Import Contacts";
|
||||||
|
this.importContactsMenuItem.Click += new System.EventHandler(this.importContactsMenuItem_Click);
|
||||||
|
//
|
||||||
|
// createCircleMenuItem
|
||||||
|
//
|
||||||
|
this.createCircleMenuItem.Name = "createCircleMenuItem";
|
||||||
|
this.createCircleMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||||
|
this.createCircleMenuItem.Text = "Circle Tests";
|
||||||
|
this.createCircleMenuItem.Click += new System.EventHandler(this.createCircleMenuItem_Click);
|
||||||
|
//
|
||||||
|
// toolStripMenuItem2
|
||||||
|
//
|
||||||
|
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
|
||||||
|
this.toolStripMenuItem2.Size = new System.Drawing.Size(197, 6);
|
||||||
|
//
|
||||||
|
// blockMenuItem
|
||||||
|
//
|
||||||
|
this.blockMenuItem.Name = "blockMenuItem";
|
||||||
|
this.blockMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||||
|
this.blockMenuItem.Text = "Block";
|
||||||
|
this.blockMenuItem.Click += new System.EventHandler(this.blockToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// unblockMenuItem
|
||||||
|
//
|
||||||
|
this.unblockMenuItem.Name = "unblockMenuItem";
|
||||||
|
this.unblockMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||||
|
this.unblockMenuItem.Text = "Unblock";
|
||||||
|
this.unblockMenuItem.Click += new System.EventHandler(this.unblockMenuItem_Click);
|
||||||
|
//
|
||||||
|
// deleteMenuItem
|
||||||
|
//
|
||||||
|
this.deleteMenuItem.Name = "deleteMenuItem";
|
||||||
|
this.deleteMenuItem.Size = new System.Drawing.Size(200, 22);
|
||||||
|
this.deleteMenuItem.Text = "Delete";
|
||||||
|
this.deleteMenuItem.Click += new System.EventHandler(this.deleteMenuItem_Click);
|
||||||
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
this.openFileDialog.Multiselect = true;
|
||||||
|
//
|
||||||
|
// openImageDialog
|
||||||
|
//
|
||||||
|
this.openImageDialog.Filter = "Supported Images|*.png;*.jpg;*.jpeg;*.gif";
|
||||||
|
this.openImageDialog.Multiselect = true;
|
||||||
|
this.openImageDialog.Title = "Select display image";
|
||||||
|
//
|
||||||
|
// tmrKeepOnLine
|
||||||
|
//
|
||||||
|
this.tmrKeepOnLine.Interval = 1000;
|
||||||
|
//
|
||||||
|
// tmrNews
|
||||||
|
//
|
||||||
|
this.tmrNews.Interval = 5000;
|
||||||
|
this.tmrNews.Tick += new System.EventHandler(this.tmrNews_Tick);
|
||||||
|
//
|
||||||
|
// sortContextMenu
|
||||||
|
//
|
||||||
|
this.sortContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.toolStripSortByStatus,
|
||||||
|
this.toolStripSortBygroup});
|
||||||
|
this.sortContextMenu.Name = "sortContextMenu";
|
||||||
|
this.sortContextMenu.ShowCheckMargin = true;
|
||||||
|
this.sortContextMenu.ShowImageMargin = false;
|
||||||
|
this.sortContextMenu.Size = new System.Drawing.Size(140, 48);
|
||||||
|
//
|
||||||
|
// toolStripSortByStatus
|
||||||
|
//
|
||||||
|
this.toolStripSortByStatus.Checked = true;
|
||||||
|
this.toolStripSortByStatus.CheckOnClick = true;
|
||||||
|
this.toolStripSortByStatus.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
|
this.toolStripSortByStatus.Name = "toolStripSortByStatus";
|
||||||
|
this.toolStripSortByStatus.ShowShortcutKeys = false;
|
||||||
|
this.toolStripSortByStatus.Size = new System.Drawing.Size(139, 22);
|
||||||
|
this.toolStripSortByStatus.Text = "Sort by status";
|
||||||
|
this.toolStripSortByStatus.Click += new System.EventHandler(this.toolStripSortByStatus_Click);
|
||||||
|
//
|
||||||
|
// toolStripSortBygroup
|
||||||
|
//
|
||||||
|
this.toolStripSortBygroup.CheckOnClick = true;
|
||||||
|
this.toolStripSortBygroup.Name = "toolStripSortBygroup";
|
||||||
|
this.toolStripSortBygroup.ShowShortcutKeys = false;
|
||||||
|
this.toolStripSortBygroup.Size = new System.Drawing.Size(139, 22);
|
||||||
|
this.toolStripSortBygroup.Text = "Sort by group";
|
||||||
|
this.toolStripSortBygroup.Click += new System.EventHandler(this.toolStripSortBygroup_Click);
|
||||||
|
//
|
||||||
|
// toolStripDeleteGroup
|
||||||
|
//
|
||||||
|
this.toolStripDeleteGroup.Name = "toolStripDeleteGroup";
|
||||||
|
this.toolStripDeleteGroup.Size = new System.Drawing.Size(142, 22);
|
||||||
|
this.toolStripDeleteGroup.Text = "Delete group";
|
||||||
|
this.toolStripDeleteGroup.Click += new System.EventHandler(this.toolStripDeleteGroup_Click);
|
||||||
|
//
|
||||||
|
// groupContextMenu
|
||||||
|
//
|
||||||
|
this.groupContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.toolStripDeleteGroup});
|
||||||
|
this.groupContextMenu.Name = "sortContextMenu";
|
||||||
|
this.groupContextMenu.ShowCheckMargin = true;
|
||||||
|
this.groupContextMenu.ShowImageMargin = false;
|
||||||
|
this.groupContextMenu.Size = new System.Drawing.Size(143, 26);
|
||||||
|
//
|
||||||
|
// tableLayoutPanel1
|
||||||
|
//
|
||||||
|
this.tableLayoutPanel1.ColumnCount = 1;
|
||||||
|
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.WhatsUpPanel, 0, 2);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.splitContainer1, 0, 1);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel3, 0, 0);
|
||||||
|
this.tableLayoutPanel1.Controls.Add(this.statusBar, 0, 3);
|
||||||
|
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||||
|
this.tableLayoutPanel1.RowCount = 4;
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 128F));
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 57F));
|
||||||
|
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
|
||||||
|
this.tableLayoutPanel1.Size = new System.Drawing.Size(643, 634);
|
||||||
|
this.tableLayoutPanel1.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// WhatsUpPanel
|
||||||
|
//
|
||||||
|
this.WhatsUpPanel.BackColor = System.Drawing.Color.White;
|
||||||
|
this.WhatsUpPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
|
this.WhatsUpPanel.Controls.Add(this.lblNewsLink);
|
||||||
|
this.WhatsUpPanel.Controls.Add(this.lblNews);
|
||||||
|
this.WhatsUpPanel.Controls.Add(this.pbNewsPicture);
|
||||||
|
this.WhatsUpPanel.Controls.Add(this.cmdNext);
|
||||||
|
this.WhatsUpPanel.Controls.Add(this.cmdPrev);
|
||||||
|
this.WhatsUpPanel.Controls.Add(this.lblWhatsup);
|
||||||
|
this.WhatsUpPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
|
this.WhatsUpPanel.Location = new System.Drawing.Point(3, 551);
|
||||||
|
this.WhatsUpPanel.Name = "WhatsUpPanel";
|
||||||
|
this.WhatsUpPanel.Size = new System.Drawing.Size(637, 50);
|
||||||
|
this.WhatsUpPanel.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// lblNewsLink
|
||||||
|
//
|
||||||
|
this.lblNewsLink.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.lblNewsLink.Location = new System.Drawing.Point(506, 25);
|
||||||
|
this.lblNewsLink.Name = "lblNewsLink";
|
||||||
|
this.lblNewsLink.Size = new System.Drawing.Size(69, 21);
|
||||||
|
this.lblNewsLink.TabIndex = 5;
|
||||||
|
this.lblNewsLink.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
this.lblNewsLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lblNewsLink_LinkClicked);
|
||||||
|
//
|
||||||
|
// lblNews
|
||||||
|
//
|
||||||
|
this.lblNews.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.lblNews.AutoEllipsis = true;
|
||||||
|
this.lblNews.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
this.lblNews.Location = new System.Drawing.Point(97, 3);
|
||||||
|
this.lblNews.Name = "lblNews";
|
||||||
|
this.lblNews.Size = new System.Drawing.Size(402, 42);
|
||||||
|
this.lblNews.TabIndex = 4;
|
||||||
|
this.lblNews.Text = " *";
|
||||||
|
this.lblNews.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// pbNewsPicture
|
||||||
|
//
|
||||||
|
this.pbNewsPicture.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.pbNewsPicture.BackColor = System.Drawing.Color.Transparent;
|
||||||
|
this.pbNewsPicture.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.pbNewsPicture.Location = new System.Drawing.Point(589, 1);
|
||||||
|
this.pbNewsPicture.Name = "pbNewsPicture";
|
||||||
|
this.pbNewsPicture.Size = new System.Drawing.Size(45, 45);
|
||||||
|
this.pbNewsPicture.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||||
|
this.pbNewsPicture.TabIndex = 3;
|
||||||
|
this.pbNewsPicture.TabStop = false;
|
||||||
|
//
|
||||||
|
// cmdNext
|
||||||
|
//
|
||||||
|
this.cmdNext.Location = new System.Drawing.Point(42, 22);
|
||||||
|
this.cmdNext.Name = "cmdNext";
|
||||||
|
this.cmdNext.Size = new System.Drawing.Size(22, 22);
|
||||||
|
this.cmdNext.TabIndex = 2;
|
||||||
|
this.cmdNext.Text = ">";
|
||||||
|
this.cmdNext.UseVisualStyleBackColor = true;
|
||||||
|
this.cmdNext.Click += new System.EventHandler(this.cmdNext_Click);
|
||||||
|
//
|
||||||
|
// cmdPrev
|
||||||
|
//
|
||||||
|
this.cmdPrev.Location = new System.Drawing.Point(15, 22);
|
||||||
|
this.cmdPrev.Name = "cmdPrev";
|
||||||
|
this.cmdPrev.Size = new System.Drawing.Size(22, 22);
|
||||||
|
this.cmdPrev.TabIndex = 1;
|
||||||
|
this.cmdPrev.Text = "<";
|
||||||
|
this.cmdPrev.UseVisualStyleBackColor = true;
|
||||||
|
this.cmdPrev.Click += new System.EventHandler(this.cmdPrev_Click);
|
||||||
|
//
|
||||||
|
// lblWhatsup
|
||||||
|
//
|
||||||
|
this.lblWhatsup.AutoSize = true;
|
||||||
|
this.lblWhatsup.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
|
||||||
|
this.lblWhatsup.Location = new System.Drawing.Point(11, 3);
|
||||||
|
this.lblWhatsup.Name = "lblWhatsup";
|
||||||
|
this.lblWhatsup.Size = new System.Drawing.Size(66, 13);
|
||||||
|
this.lblWhatsup.TabIndex = 0;
|
||||||
|
this.lblWhatsup.Text = "What\'s Up";
|
||||||
|
//
|
||||||
|
// splitContainer1
|
||||||
|
//
|
||||||
|
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.splitContainer1.Location = new System.Drawing.Point(3, 131);
|
||||||
|
this.splitContainer1.Name = "splitContainer1";
|
||||||
|
//
|
||||||
|
// splitContainer1.Panel1
|
||||||
|
//
|
||||||
|
this.splitContainer1.Panel1.BackColor = System.Drawing.Color.White;
|
||||||
|
this.splitContainer1.Panel1.Controls.Add(this.propertyGrid);
|
||||||
|
//
|
||||||
|
// splitContainer1.Panel2
|
||||||
|
//
|
||||||
|
this.splitContainer1.Panel2.Controls.Add(this.tableLayoutPanel2);
|
||||||
|
this.splitContainer1.Size = new System.Drawing.Size(637, 413);
|
||||||
|
this.splitContainer1.SplitterDistance = 252;
|
||||||
|
this.splitContainer1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// propertyGrid
|
||||||
|
//
|
||||||
|
this.propertyGrid.BackColor = System.Drawing.Color.White;
|
||||||
|
this.propertyGrid.CommandsBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(128)))));
|
||||||
|
this.propertyGrid.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.propertyGrid.HelpBackColor = System.Drawing.Color.White;
|
||||||
|
this.propertyGrid.LineColor = System.Drawing.SystemColors.ScrollBar;
|
||||||
|
this.propertyGrid.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.propertyGrid.Name = "propertyGrid";
|
||||||
|
this.propertyGrid.Size = new System.Drawing.Size(252, 413);
|
||||||
|
this.propertyGrid.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// tableLayoutPanel2
|
||||||
|
//
|
||||||
|
this.tableLayoutPanel2.ColumnCount = 1;
|
||||||
|
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel2.Controls.Add(this.pnlTreeViewsContainer, 0, 1);
|
||||||
|
this.tableLayoutPanel2.Controls.Add(this.SortPanel, 0, 0);
|
||||||
|
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(1);
|
||||||
|
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||||
|
this.tableLayoutPanel2.RowCount = 2;
|
||||||
|
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 29F));
|
||||||
|
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||||
|
this.tableLayoutPanel2.Size = new System.Drawing.Size(381, 413);
|
||||||
|
this.tableLayoutPanel2.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// pnlTreeViewsContainer
|
||||||
|
//
|
||||||
|
this.pnlTreeViewsContainer.Controls.Add(this.treeViewFilterList);
|
||||||
|
this.pnlTreeViewsContainer.Controls.Add(this.treeViewFavoriteList);
|
||||||
|
this.pnlTreeViewsContainer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pnlTreeViewsContainer.Location = new System.Drawing.Point(3, 32);
|
||||||
|
this.pnlTreeViewsContainer.Name = "pnlTreeViewsContainer";
|
||||||
|
this.pnlTreeViewsContainer.Size = new System.Drawing.Size(375, 378);
|
||||||
|
this.pnlTreeViewsContainer.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// treeViewFilterList
|
||||||
|
//
|
||||||
|
this.treeViewFilterList.BackColor = System.Drawing.Color.White;
|
||||||
|
this.treeViewFilterList.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.treeViewFilterList.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.treeViewFilterList.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
|
||||||
|
this.treeViewFilterList.FullRowSelect = true;
|
||||||
|
this.treeViewFilterList.HideSelection = false;
|
||||||
|
this.treeViewFilterList.Indent = 20;
|
||||||
|
this.treeViewFilterList.ItemHeight = 20;
|
||||||
|
this.treeViewFilterList.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.treeViewFilterList.Name = "treeViewFilterList";
|
||||||
|
this.treeViewFilterList.ShowLines = false;
|
||||||
|
this.treeViewFilterList.ShowPlusMinus = false;
|
||||||
|
this.treeViewFilterList.ShowRootLines = false;
|
||||||
|
this.treeViewFilterList.Size = new System.Drawing.Size(375, 378);
|
||||||
|
this.treeViewFilterList.TabIndex = 5;
|
||||||
|
this.treeViewFilterList.Visible = false;
|
||||||
|
this.treeViewFilterList.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseDoubleClick);
|
||||||
|
this.treeViewFilterList.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick);
|
||||||
|
//
|
||||||
|
// treeViewFavoriteList
|
||||||
|
//
|
||||||
|
this.treeViewFavoriteList.AllowDrop = true;
|
||||||
|
this.treeViewFavoriteList.BackColor = System.Drawing.Color.White;
|
||||||
|
this.treeViewFavoriteList.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.treeViewFavoriteList.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.treeViewFavoriteList.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
|
||||||
|
this.treeViewFavoriteList.FullRowSelect = true;
|
||||||
|
this.treeViewFavoriteList.HideSelection = false;
|
||||||
|
this.treeViewFavoriteList.ImageIndex = 0;
|
||||||
|
this.treeViewFavoriteList.ImageList = this.ImageList1;
|
||||||
|
this.treeViewFavoriteList.Indent = 15;
|
||||||
|
this.treeViewFavoriteList.ItemHeight = 20;
|
||||||
|
this.treeViewFavoriteList.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.treeViewFavoriteList.Name = "treeViewFavoriteList";
|
||||||
|
this.treeViewFavoriteList.SelectedImageIndex = 0;
|
||||||
|
this.treeViewFavoriteList.ShowLines = false;
|
||||||
|
this.treeViewFavoriteList.ShowPlusMinus = false;
|
||||||
|
this.treeViewFavoriteList.ShowRootLines = false;
|
||||||
|
this.treeViewFavoriteList.Size = new System.Drawing.Size(375, 378);
|
||||||
|
this.treeViewFavoriteList.TabIndex = 4;
|
||||||
|
this.treeViewFavoriteList.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseDoubleClick);
|
||||||
|
this.treeViewFavoriteList.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeViewFavoriteList_DragDrop);
|
||||||
|
this.treeViewFavoriteList.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeViewFavoriteList_DragEnter);
|
||||||
|
this.treeViewFavoriteList.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView1_NodeMouseClick);
|
||||||
|
this.treeViewFavoriteList.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeViewFavoriteList_ItemDrag);
|
||||||
|
this.treeViewFavoriteList.DragOver += new System.Windows.Forms.DragEventHandler(this.treeViewFavoriteList_DragOver);
|
||||||
|
//
|
||||||
|
// SortPanel
|
||||||
|
//
|
||||||
|
this.SortPanel.BackColor = System.Drawing.Color.White;
|
||||||
|
this.SortPanel.Controls.Add(this.txtSearch);
|
||||||
|
this.SortPanel.Controls.Add(this.btnAddNew);
|
||||||
|
this.SortPanel.Controls.Add(this.btnSortBy);
|
||||||
|
this.SortPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.SortPanel.Location = new System.Drawing.Point(1, 1);
|
||||||
|
this.SortPanel.Margin = new System.Windows.Forms.Padding(1);
|
||||||
|
this.SortPanel.Name = "SortPanel";
|
||||||
|
this.SortPanel.Size = new System.Drawing.Size(379, 27);
|
||||||
|
this.SortPanel.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// txtSearch
|
||||||
|
//
|
||||||
|
this.txtSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.txtSearch.ForeColor = System.Drawing.SystemColors.ScrollBar;
|
||||||
|
this.txtSearch.Location = new System.Drawing.Point(6, 4);
|
||||||
|
this.txtSearch.Name = "txtSearch";
|
||||||
|
this.txtSearch.Size = new System.Drawing.Size(279, 21);
|
||||||
|
this.txtSearch.TabIndex = 9;
|
||||||
|
this.txtSearch.Text = "Search contacts";
|
||||||
|
this.txtSearch.TextChanged += new System.EventHandler(this.txtSearch_TextChanged);
|
||||||
|
this.txtSearch.Leave += new System.EventHandler(this.txtSearch_Leave);
|
||||||
|
this.txtSearch.Enter += new System.EventHandler(this.txtSearch_Enter);
|
||||||
|
//
|
||||||
|
// btnAddNew
|
||||||
|
//
|
||||||
|
this.btnAddNew.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.btnAddNew.BackColor = System.Drawing.SystemColors.Control;
|
||||||
|
this.btnAddNew.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
|
||||||
|
this.btnAddNew.Location = new System.Drawing.Point(334, 2);
|
||||||
|
this.btnAddNew.Name = "btnAddNew";
|
||||||
|
this.btnAddNew.Size = new System.Drawing.Size(44, 22);
|
||||||
|
this.btnAddNew.TabIndex = 7;
|
||||||
|
this.btnAddNew.Text = "+";
|
||||||
|
this.btnAddNew.UseVisualStyleBackColor = true;
|
||||||
|
this.btnAddNew.Click += new System.EventHandler(this.btnAddNew_Click);
|
||||||
|
//
|
||||||
|
// btnSortBy
|
||||||
|
//
|
||||||
|
this.btnSortBy.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.btnSortBy.BackColor = System.Drawing.SystemColors.Control;
|
||||||
|
this.btnSortBy.Cursor = System.Windows.Forms.Cursors.Arrow;
|
||||||
|
this.btnSortBy.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
|
||||||
|
this.btnSortBy.Location = new System.Drawing.Point(290, 2);
|
||||||
|
this.btnSortBy.Name = "btnSortBy";
|
||||||
|
this.btnSortBy.Size = new System.Drawing.Size(44, 22);
|
||||||
|
this.btnSortBy.TabIndex = 0;
|
||||||
|
this.btnSortBy.Text = "sort";
|
||||||
|
this.btnSortBy.UseVisualStyleBackColor = true;
|
||||||
|
this.btnSortBy.Click += new System.EventHandler(this.btnSortBy_Click);
|
||||||
|
//
|
||||||
|
// tableLayoutPanel3
|
||||||
|
//
|
||||||
|
this.tableLayoutPanel3.BackColor = System.Drawing.Color.White;
|
||||||
|
this.tableLayoutPanel3.BackgroundImage = global::MSNPSharpClient.Properties.Resources.app_banner;
|
||||||
|
this.tableLayoutPanel3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
|
||||||
|
this.tableLayoutPanel3.ColumnCount = 2;
|
||||||
|
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 380F));
|
||||||
|
this.tableLayoutPanel3.Controls.Add(this.tableLayoutPanel4, 1, 0);
|
||||||
|
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableLayoutPanel3.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
|
||||||
|
this.tableLayoutPanel3.RowCount = 1;
|
||||||
|
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel3.Size = new System.Drawing.Size(637, 122);
|
||||||
|
this.tableLayoutPanel3.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// tableLayoutPanel4
|
||||||
|
//
|
||||||
|
this.tableLayoutPanel4.ColumnCount = 1;
|
||||||
|
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel4.Controls.Add(this.tableLayoutPanel5, 0, 0);
|
||||||
|
this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableLayoutPanel4.Location = new System.Drawing.Point(260, 3);
|
||||||
|
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
|
||||||
|
this.tableLayoutPanel4.RowCount = 1;
|
||||||
|
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 126F));
|
||||||
|
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 126F));
|
||||||
|
this.tableLayoutPanel4.Size = new System.Drawing.Size(374, 116);
|
||||||
|
this.tableLayoutPanel4.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// tableLayoutPanel5
|
||||||
|
//
|
||||||
|
this.tableLayoutPanel5.ColumnCount = 2;
|
||||||
|
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel5.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 87F));
|
||||||
|
this.tableLayoutPanel5.Controls.Add(this.displayImageBox, 1, 0);
|
||||||
|
this.tableLayoutPanel5.Controls.Add(this.panel1, 0, 0);
|
||||||
|
this.tableLayoutPanel5.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableLayoutPanel5.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.tableLayoutPanel5.Name = "tableLayoutPanel5";
|
||||||
|
this.tableLayoutPanel5.RowCount = 1;
|
||||||
|
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 120F));
|
||||||
|
this.tableLayoutPanel5.Size = new System.Drawing.Size(368, 120);
|
||||||
|
this.tableLayoutPanel5.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// displayImageBox
|
||||||
|
//
|
||||||
|
this.displayImageBox.BackColor = System.Drawing.Color.White;
|
||||||
|
this.displayImageBox.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.displayImageBox.Location = new System.Drawing.Point(284, 3);
|
||||||
|
this.displayImageBox.Name = "displayImageBox";
|
||||||
|
this.displayImageBox.Size = new System.Drawing.Size(80, 80);
|
||||||
|
this.displayImageBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
|
||||||
|
this.displayImageBox.TabIndex = 3;
|
||||||
|
this.displayImageBox.TabStop = false;
|
||||||
|
this.displayImageBox.Click += new System.EventHandler(this.displayImageBox_Click);
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
this.panel1.Controls.Add(this.tableLayoutPanel6);
|
||||||
|
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.panel1.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.panel1.Name = "panel1";
|
||||||
|
this.panel1.Size = new System.Drawing.Size(275, 114);
|
||||||
|
this.panel1.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// tableLayoutPanel6
|
||||||
|
//
|
||||||
|
this.tableLayoutPanel6.ColumnCount = 1;
|
||||||
|
this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel6.Controls.Add(this.pnlLogin, 0, 0);
|
||||||
|
this.tableLayoutPanel6.Controls.Add(this.tableLayoutPanel7, 0, 1);
|
||||||
|
this.tableLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableLayoutPanel6.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.tableLayoutPanel6.Name = "tableLayoutPanel6";
|
||||||
|
this.tableLayoutPanel6.RowCount = 2;
|
||||||
|
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
|
this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F));
|
||||||
|
this.tableLayoutPanel6.Size = new System.Drawing.Size(275, 114);
|
||||||
|
this.tableLayoutPanel6.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// pnlLogin
|
||||||
|
//
|
||||||
|
this.pnlLogin.Controls.Add(this.pnlNameAndPM);
|
||||||
|
this.pnlLogin.Controls.Add(this.cbRobotMode);
|
||||||
|
this.pnlLogin.Controls.Add(this.accountTextBox);
|
||||||
|
this.pnlLogin.Controls.Add(this.loginButton);
|
||||||
|
this.pnlLogin.Controls.Add(this.passwordTextBox);
|
||||||
|
this.pnlLogin.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pnlLogin.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.pnlLogin.Name = "pnlLogin";
|
||||||
|
this.pnlLogin.Size = new System.Drawing.Size(269, 73);
|
||||||
|
this.pnlLogin.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// pnlNameAndPM
|
||||||
|
//
|
||||||
|
this.pnlNameAndPM.Controls.Add(this.btnSetMusic);
|
||||||
|
this.pnlNameAndPM.Controls.Add(this.lblPM);
|
||||||
|
this.pnlNameAndPM.Controls.Add(this.lblName);
|
||||||
|
this.pnlNameAndPM.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.pnlNameAndPM.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.pnlNameAndPM.Name = "pnlNameAndPM";
|
||||||
|
this.pnlNameAndPM.Size = new System.Drawing.Size(269, 73);
|
||||||
|
this.pnlNameAndPM.TabIndex = 15;
|
||||||
|
this.pnlNameAndPM.Visible = false;
|
||||||
|
//
|
||||||
|
// btnSetMusic
|
||||||
|
//
|
||||||
|
this.btnSetMusic.Location = new System.Drawing.Point(233, 25);
|
||||||
|
this.btnSetMusic.Name = "btnSetMusic";
|
||||||
|
this.btnSetMusic.Size = new System.Drawing.Size(33, 22);
|
||||||
|
this.btnSetMusic.TabIndex = 8;
|
||||||
|
this.btnSetMusic.Tag = "0";
|
||||||
|
this.btnSetMusic.Text = "M";
|
||||||
|
this.btnSetMusic.UseVisualStyleBackColor = true;
|
||||||
|
this.btnSetMusic.Click += new System.EventHandler(this.btnSetMusic_Click);
|
||||||
|
//
|
||||||
|
// lblPM
|
||||||
|
//
|
||||||
|
this.lblPM.Location = new System.Drawing.Point(3, 26);
|
||||||
|
this.lblPM.Name = "lblPM";
|
||||||
|
this.lblPM.Size = new System.Drawing.Size(228, 21);
|
||||||
|
this.lblPM.TabIndex = 7;
|
||||||
|
this.lblPM.Leave += new System.EventHandler(this.lblName_Leave);
|
||||||
|
//
|
||||||
|
// lblName
|
||||||
|
//
|
||||||
|
this.lblName.Location = new System.Drawing.Point(3, 1);
|
||||||
|
this.lblName.Name = "lblName";
|
||||||
|
this.lblName.Size = new System.Drawing.Size(263, 21);
|
||||||
|
this.lblName.TabIndex = 6;
|
||||||
|
this.lblName.Leave += new System.EventHandler(this.lblName_Leave);
|
||||||
|
//
|
||||||
|
// cbRobotMode
|
||||||
|
//
|
||||||
|
this.cbRobotMode.AutoSize = true;
|
||||||
|
this.cbRobotMode.Location = new System.Drawing.Point(3, 54);
|
||||||
|
this.cbRobotMode.Name = "cbRobotMode";
|
||||||
|
this.cbRobotMode.Size = new System.Drawing.Size(136, 19);
|
||||||
|
this.cbRobotMode.TabIndex = 11;
|
||||||
|
this.cbRobotMode.Text = "Provisioned Account";
|
||||||
|
this.cbRobotMode.UseVisualStyleBackColor = true;
|
||||||
|
this.cbRobotMode.CheckedChanged += new System.EventHandler(this.cbRobotMode_CheckedChanged);
|
||||||
|
//
|
||||||
|
// accountTextBox
|
||||||
|
//
|
||||||
|
this.accountTextBox.Location = new System.Drawing.Point(3, 2);
|
||||||
|
this.accountTextBox.Name = "accountTextBox";
|
||||||
|
this.accountTextBox.Size = new System.Drawing.Size(263, 21);
|
||||||
|
this.accountTextBox.TabIndex = 9;
|
||||||
|
this.accountTextBox.Text = "example@escargot.chat";
|
||||||
|
this.accountTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.login_KeyPress);
|
||||||
|
//
|
||||||
|
// loginButton
|
||||||
|
//
|
||||||
|
this.loginButton.Location = new System.Drawing.Point(145, 50);
|
||||||
|
this.loginButton.Name = "loginButton";
|
||||||
|
this.loginButton.Size = new System.Drawing.Size(121, 22);
|
||||||
|
this.loginButton.TabIndex = 8;
|
||||||
|
this.loginButton.Tag = "0";
|
||||||
|
this.loginButton.Text = "> Sign in";
|
||||||
|
this.loginButton.UseVisualStyleBackColor = true;
|
||||||
|
this.loginButton.Click += new System.EventHandler(this.loginButton_Click);
|
||||||
|
//
|
||||||
|
// passwordTextBox
|
||||||
|
//
|
||||||
|
this.passwordTextBox.Location = new System.Drawing.Point(3, 27);
|
||||||
|
this.passwordTextBox.Name = "passwordTextBox";
|
||||||
|
this.passwordTextBox.PasswordChar = '*';
|
||||||
|
this.passwordTextBox.Size = new System.Drawing.Size(263, 21);
|
||||||
|
this.passwordTextBox.TabIndex = 10;
|
||||||
|
this.passwordTextBox.Text = "sneakysource";
|
||||||
|
this.passwordTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.login_KeyPress);
|
||||||
|
//
|
||||||
|
// tableLayoutPanel7
|
||||||
|
//
|
||||||
|
this.tableLayoutPanel7.ColumnCount = 2;
|
||||||
|
this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||||
|
this.tableLayoutPanel7.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||||
|
this.tableLayoutPanel7.Controls.Add(this.comboPlaces, 0, 0);
|
||||||
|
this.tableLayoutPanel7.Controls.Add(this.comboStatus, 0, 0);
|
||||||
|
this.tableLayoutPanel7.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableLayoutPanel7.Location = new System.Drawing.Point(3, 82);
|
||||||
|
this.tableLayoutPanel7.Name = "tableLayoutPanel7";
|
||||||
|
this.tableLayoutPanel7.RowCount = 1;
|
||||||
|
this.tableLayoutPanel7.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||||
|
this.tableLayoutPanel7.Size = new System.Drawing.Size(269, 29);
|
||||||
|
this.tableLayoutPanel7.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// comboPlaces
|
||||||
|
//
|
||||||
|
this.comboPlaces.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboPlaces.DropDownWidth = 220;
|
||||||
|
this.comboPlaces.FormattingEnabled = true;
|
||||||
|
this.comboPlaces.Location = new System.Drawing.Point(137, 3);
|
||||||
|
this.comboPlaces.Name = "comboPlaces";
|
||||||
|
this.comboPlaces.Size = new System.Drawing.Size(129, 23);
|
||||||
|
this.comboPlaces.TabIndex = 6;
|
||||||
|
this.comboPlaces.Visible = false;
|
||||||
|
this.comboPlaces.SelectedIndexChanged += new System.EventHandler(this.comboPlaces_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// comboStatus
|
||||||
|
//
|
||||||
|
this.comboStatus.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||||
|
this.comboStatus.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.comboStatus.FormattingEnabled = true;
|
||||||
|
this.comboStatus.ItemHeight = 15;
|
||||||
|
this.comboStatus.Items.AddRange(new object[] {
|
||||||
|
"Online",
|
||||||
|
"Busy",
|
||||||
|
"Away",
|
||||||
|
"Hidden",
|
||||||
|
"Offline"});
|
||||||
|
this.comboStatus.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.comboStatus.Name = "comboStatus";
|
||||||
|
this.comboStatus.Size = new System.Drawing.Size(128, 21);
|
||||||
|
this.comboStatus.TabIndex = 5;
|
||||||
|
this.comboStatus.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.comboStatus_DrawItem);
|
||||||
|
this.comboStatus.SelectedIndexChanged += new System.EventHandler(this.comboStatus_SelectedIndexChanged);
|
||||||
|
this.comboStatus.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.comboStatus_KeyPress);
|
||||||
|
//
|
||||||
|
// statusBar
|
||||||
|
//
|
||||||
|
this.statusBar.AutoSize = true;
|
||||||
|
this.statusBar.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.statusBar.Location = new System.Drawing.Point(3, 604);
|
||||||
|
this.statusBar.Name = "statusBar";
|
||||||
|
this.statusBar.Size = new System.Drawing.Size(637, 30);
|
||||||
|
this.statusBar.TabIndex = 10;
|
||||||
|
this.statusBar.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// ClientForm
|
||||||
|
//
|
||||||
|
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
|
||||||
|
this.BackColor = System.Drawing.Color.White;
|
||||||
|
this.ClientSize = new System.Drawing.Size(643, 634);
|
||||||
|
this.Controls.Add(this.tableLayoutPanel1);
|
||||||
|
this.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.MinimumSize = new System.Drawing.Size(640, 480);
|
||||||
|
this.Name = "ClientForm";
|
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
|
this.Text = "MSNPSharp Example Client for Escargot";
|
||||||
|
this.Load += new System.EventHandler(this.ClientForm_Load);
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ClientForm_FormClosing);
|
||||||
|
this.userMenuStrip.ResumeLayout(false);
|
||||||
|
this.sortContextMenu.ResumeLayout(false);
|
||||||
|
this.groupContextMenu.ResumeLayout(false);
|
||||||
|
this.tableLayoutPanel1.ResumeLayout(false);
|
||||||
|
this.tableLayoutPanel1.PerformLayout();
|
||||||
|
this.WhatsUpPanel.ResumeLayout(false);
|
||||||
|
this.WhatsUpPanel.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pbNewsPicture)).EndInit();
|
||||||
|
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||||
|
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||||
|
this.splitContainer1.ResumeLayout(false);
|
||||||
|
this.tableLayoutPanel2.ResumeLayout(false);
|
||||||
|
this.pnlTreeViewsContainer.ResumeLayout(false);
|
||||||
|
this.SortPanel.ResumeLayout(false);
|
||||||
|
this.SortPanel.PerformLayout();
|
||||||
|
this.tableLayoutPanel3.ResumeLayout(false);
|
||||||
|
this.tableLayoutPanel4.ResumeLayout(false);
|
||||||
|
this.tableLayoutPanel5.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.displayImageBox)).EndInit();
|
||||||
|
this.panel1.ResumeLayout(false);
|
||||||
|
this.tableLayoutPanel6.ResumeLayout(false);
|
||||||
|
this.pnlLogin.ResumeLayout(false);
|
||||||
|
this.pnlLogin.PerformLayout();
|
||||||
|
this.pnlNameAndPM.ResumeLayout(false);
|
||||||
|
this.pnlNameAndPM.PerformLayout();
|
||||||
|
this.tableLayoutPanel7.ResumeLayout(false);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private OpenFileDialog openFileDialog;
|
||||||
|
private OpenFileDialog openImageDialog;
|
||||||
|
private System.Windows.Forms.Timer tmrKeepOnLine;
|
||||||
|
private System.Windows.Forms.Timer tmrNews;
|
||||||
|
private ImageList ImageList1;
|
||||||
|
private ContextMenuStrip userMenuStrip;
|
||||||
|
private ToolStripMenuItem sendIMMenuItem;
|
||||||
|
private ToolStripMenuItem blockMenuItem;
|
||||||
|
private ToolStripSeparator toolStripMenuItem2;
|
||||||
|
private ToolStripMenuItem unblockMenuItem;
|
||||||
|
private ToolStripMenuItem sendOIMMenuItem;
|
||||||
|
private ToolStripSeparator toolStripMenuItem3;
|
||||||
|
private ToolStripMenuItem sendMIMMenuItem;
|
||||||
|
private ContextMenuStrip sortContextMenu;
|
||||||
|
private ToolStripMenuItem toolStripSortByStatus;
|
||||||
|
private ToolStripMenuItem toolStripSortBygroup;
|
||||||
|
private ToolStripMenuItem toolStripDeleteGroup;
|
||||||
|
private ContextMenuStrip groupContextMenu;
|
||||||
|
private ToolStripMenuItem importContactsMenuItem;
|
||||||
|
private ToolStripMenuItem createCircleMenuItem;
|
||||||
|
private ToolStripMenuItem deleteMenuItem;
|
||||||
|
private ToolTip toolTipChangePhoto;
|
||||||
|
private TableLayoutPanel tableLayoutPanel1;
|
||||||
|
private Panel WhatsUpPanel;
|
||||||
|
private LinkLabel lblNewsLink;
|
||||||
|
private Label lblNews;
|
||||||
|
private PictureBox pbNewsPicture;
|
||||||
|
private Button cmdNext;
|
||||||
|
private Button cmdPrev;
|
||||||
|
private Label lblWhatsup;
|
||||||
|
private SplitContainer splitContainer1;
|
||||||
|
private PropertyGrid propertyGrid;
|
||||||
|
private TableLayoutPanel tableLayoutPanel2;
|
||||||
|
private Panel SortPanel;
|
||||||
|
private TextBox txtSearch;
|
||||||
|
private Button btnAddNew;
|
||||||
|
private Button btnSortBy;
|
||||||
|
private TableLayoutPanel tableLayoutPanel3;
|
||||||
|
private Panel pnlTreeViewsContainer;
|
||||||
|
private TreeView treeViewFavoriteList;
|
||||||
|
private Label statusBar;
|
||||||
|
private TreeView treeViewFilterList;
|
||||||
|
private TableLayoutPanel tableLayoutPanel4;
|
||||||
|
private TableLayoutPanel tableLayoutPanel5;
|
||||||
|
private Panel panel1;
|
||||||
|
private TableLayoutPanel tableLayoutPanel6;
|
||||||
|
private Panel pnlLogin;
|
||||||
|
private Panel pnlNameAndPM;
|
||||||
|
private Button btnSetMusic;
|
||||||
|
private TextBox lblPM;
|
||||||
|
private TextBox lblName;
|
||||||
|
private CheckBox cbRobotMode;
|
||||||
|
private TextBox accountTextBox;
|
||||||
|
private Button loginButton;
|
||||||
|
private TextBox passwordTextBox;
|
||||||
|
private TableLayoutPanel tableLayoutPanel7;
|
||||||
|
private ComboBox comboPlaces;
|
||||||
|
private ComboBox comboStatus;
|
||||||
|
private PictureBox displayImageBox;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
2343
Example/DotMSNClient.cs
Normal file
257
Example/DotMSNClient.csproj
Normal file
|
|
@ -0,0 +1,257 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ProjectType>Local</ProjectType>
|
||||||
|
<ProductVersion>8.0.50727</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{BDF3E472-EFE8-44D6-AFB6-062DD929D56F}</ProjectGuid>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ApplicationIcon>MSNPSharp_logo.ico</ApplicationIcon>
|
||||||
|
<AssemblyKeyContainerName>
|
||||||
|
</AssemblyKeyContainerName>
|
||||||
|
<AssemblyName>DotMSNClient</AssemblyName>
|
||||||
|
<DefaultClientScript>JScript</DefaultClientScript>
|
||||||
|
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
|
||||||
|
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||||
|
<DelaySign>false</DelaySign>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<RootNamespace>MSNPSharpClient</RootNamespace>
|
||||||
|
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||||
|
<StartupObject>MSNPSharpClient.ClientForm</StartupObject>
|
||||||
|
<FileUpgradeFlags>
|
||||||
|
</FileUpgradeFlags>
|
||||||
|
<UpgradeBackupLocation>
|
||||||
|
</UpgradeBackupLocation>
|
||||||
|
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||||
|
<OldToolsVersion>2.0</OldToolsVersion>
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<BaseAddress>285212672</BaseAddress>
|
||||||
|
<ConfigurationOverrideFile>
|
||||||
|
</ConfigurationOverrideFile>
|
||||||
|
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||||
|
<DocumentationFile>
|
||||||
|
</DocumentationFile>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<FileAlignment>4096</FileAlignment>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<RegisterForComInterop>false</RegisterForComInterop>
|
||||||
|
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<BaseAddress>285212672</BaseAddress>
|
||||||
|
<ConfigurationOverrideFile>
|
||||||
|
</ConfigurationOverrideFile>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<DocumentationFile>
|
||||||
|
</DocumentationFile>
|
||||||
|
<FileAlignment>4096</FileAlignment>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<RegisterForComInterop>false</RegisterForComInterop>
|
||||||
|
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<DebugType>none</DebugType>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System">
|
||||||
|
<Name>System</Name>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data">
|
||||||
|
<Name>System.Data</Name>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Drawing">
|
||||||
|
<Name>System.Drawing</Name>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Web" />
|
||||||
|
<Reference Include="System.Web.Services" />
|
||||||
|
<Reference Include="System.Windows.Forms">
|
||||||
|
<Name>System.Windows.Forms</Name>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml">
|
||||||
|
<Name>System.XML</Name>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="MSNPSharp_logo.ico" />
|
||||||
|
<None Include="Resources\Color_fontHS.png" />
|
||||||
|
<None Include="Resources\app_banner.png" />
|
||||||
|
<None Include="Resources\loading.gif" />
|
||||||
|
<None Include="Resources\YahooMessenger_logo.png" />
|
||||||
|
<None Include="Resources\msn_ico.ico" />
|
||||||
|
<None Include="Resources\MSNPSharp_logo_small.ico" />
|
||||||
|
<None Include="Resources\MSNPSharp_logo.ico" />
|
||||||
|
<None Include="Resources\status\open.png" />
|
||||||
|
<None Include="Resources\status\online.png" />
|
||||||
|
<None Include="Resources\status\offline.png" />
|
||||||
|
<None Include="Resources\status\idle.png" />
|
||||||
|
<None Include="Resources\status\hidden.png" />
|
||||||
|
<None Include="Resources\status\closed.png" />
|
||||||
|
<None Include="Resources\status\circle.png" />
|
||||||
|
<None Include="Resources\status\busy.png" />
|
||||||
|
<None Include="Resources\status\away.png" />
|
||||||
|
<None Include="Resources\file.png" />
|
||||||
|
<None Include="Resources\nudge.png" />
|
||||||
|
<None Include="Resources\yahoo_ico.ico" />
|
||||||
|
<None Include="Resources\smileys\tongueout.gif" />
|
||||||
|
<None Include="Resources\smileys\smiley.gif" />
|
||||||
|
<None Include="Resources\smileys\sad.gif" />
|
||||||
|
<None Include="Resources\smileys\biggrin.gif" />
|
||||||
|
<None Include="Resources\smileys\wink.gif" />
|
||||||
|
<None Include="Resources\inner_emoicon.png" />
|
||||||
|
<Compile Include="AddContactForm.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="AddContactForm.Designer.cs">
|
||||||
|
<DependentUpon>AddContactForm.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ConversationForm.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="FileTransferForm.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="FileTransferForm.Designer.cs">
|
||||||
|
<DependentUpon>FileTransferForm.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="DotMSNClient.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="DotMSNClient.Designer.cs">
|
||||||
|
<DependentUpon>DotMSNClient.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ImportContacts.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ImportContacts.Designer.cs">
|
||||||
|
<DependentUpon>ImportContacts.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="MusicForm.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="MusicForm.Designer.cs">
|
||||||
|
<DependentUpon>MusicForm.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="RemoveContactForm.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="RemoveContactForm.Designer.cs">
|
||||||
|
<DependentUpon>RemoveContactForm.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ReverseAddedForm.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="ReverseAddedForm.Designer.cs">
|
||||||
|
<DependentUpon>ReverseAddedForm.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="RtfRichTextBox.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="TraceForm.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="TraceForm.Designer.cs">
|
||||||
|
<DependentUpon>TraceForm.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<EmbeddedResource Include="AddContactForm.resx">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<DependentUpon>AddContactForm.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="ConversationForm.resx">
|
||||||
|
<DependentUpon>ConversationForm.cs</DependentUpon>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="FileTransferForm.resx">
|
||||||
|
<DependentUpon>FileTransferForm.cs</DependentUpon>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="DotMSNClient.resx">
|
||||||
|
<DependentUpon>DotMSNClient.cs</DependentUpon>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="ImportContacts.resx">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<DependentUpon>ImportContacts.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="MusicForm.resx">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<DependentUpon>MusicForm.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="RemoveContactForm.resx">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<DependentUpon>RemoveContactForm.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="ReverseAddedForm.resx">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<DependentUpon>ReverseAddedForm.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="TraceForm.resx">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<DependentUpon>TraceForm.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\MSNPSharp\MSNPSharp.csproj">
|
||||||
|
<Project>{97CB2DC7-2FE8-4AF5-84D0-6B9872A5E960}</Project>
|
||||||
|
<Name>MSNPSharp</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Windows Installer 3.1</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<PreBuildEvent>
|
||||||
|
</PreBuildEvent>
|
||||||
|
<PostBuildEvent>
|
||||||
|
</PostBuildEvent>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
13
Example/DotMSNClient.csproj.user
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<PublishUrlHistory />
|
||||||
|
<InstallUrlHistory />
|
||||||
|
<SupportUrlHistory />
|
||||||
|
<UpdateUrlHistory />
|
||||||
|
<BootstrapperUrlHistory />
|
||||||
|
<ErrorReportUrlHistory />
|
||||||
|
<FallbackCulture>en-US</FallbackCulture>
|
||||||
|
<VerifyUploadedFiles>false</VerifyUploadedFiles>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
150
Example/DotMSNClient.resx
Normal file
|
|
@ -0,0 +1,150 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="ImageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>118, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="userMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>776, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>506, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="openImageDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>228, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="tmrKeepOnLine.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>639, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="tmrNews.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="sortContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 56</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="groupContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>163, 56</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="toolTipChangePhoto.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>322, 56</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>76</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
164
Example/FileTransferForm.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,164 @@
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
partial class FileTransferForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.lblFile = new System.Windows.Forms.Label();
|
||||||
|
this.txtFilePath = new System.Windows.Forms.TextBox();
|
||||||
|
this.btnOK = new System.Windows.Forms.Button();
|
||||||
|
this.btnCancel = new System.Windows.Forms.Button();
|
||||||
|
this.progressBar = new System.Windows.Forms.ProgressBar();
|
||||||
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
|
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.lblSize = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// lblFile
|
||||||
|
//
|
||||||
|
this.lblFile.AutoSize = true;
|
||||||
|
this.lblFile.Location = new System.Drawing.Point(18, 8);
|
||||||
|
this.lblFile.Name = "lblFile";
|
||||||
|
this.lblFile.Size = new System.Drawing.Size(29, 12);
|
||||||
|
this.lblFile.TabIndex = 0;
|
||||||
|
this.lblFile.Text = "File";
|
||||||
|
//
|
||||||
|
// txtFilePath
|
||||||
|
//
|
||||||
|
this.txtFilePath.Location = new System.Drawing.Point(64, 6);
|
||||||
|
this.txtFilePath.Name = "txtFilePath";
|
||||||
|
this.txtFilePath.Size = new System.Drawing.Size(270, 21);
|
||||||
|
this.txtFilePath.TabIndex = 3;
|
||||||
|
this.txtFilePath.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||||
|
//
|
||||||
|
// btnOK
|
||||||
|
//
|
||||||
|
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||||
|
this.btnOK.Location = new System.Drawing.Point(64, 94);
|
||||||
|
this.btnOK.Name = "btnOK";
|
||||||
|
this.btnOK.Size = new System.Drawing.Size(164, 37);
|
||||||
|
this.btnOK.TabIndex = 6;
|
||||||
|
this.btnOK.Tag = "OK";
|
||||||
|
this.btnOK.Text = "OK";
|
||||||
|
this.btnOK.UseVisualStyleBackColor = true;
|
||||||
|
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
|
||||||
|
//
|
||||||
|
// btnCancel
|
||||||
|
//
|
||||||
|
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
|
this.btnCancel.Location = new System.Drawing.Point(237, 94);
|
||||||
|
this.btnCancel.Name = "btnCancel";
|
||||||
|
this.btnCancel.Size = new System.Drawing.Size(97, 37);
|
||||||
|
this.btnCancel.TabIndex = 7;
|
||||||
|
this.btnCancel.Text = "Cancel";
|
||||||
|
this.btnCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||||
|
//
|
||||||
|
// progressBar
|
||||||
|
//
|
||||||
|
this.progressBar.Location = new System.Drawing.Point(64, 56);
|
||||||
|
this.progressBar.Name = "progressBar";
|
||||||
|
this.progressBar.Size = new System.Drawing.Size(270, 21);
|
||||||
|
this.progressBar.Step = 1;
|
||||||
|
this.progressBar.TabIndex = 8;
|
||||||
|
this.progressBar.Visible = false;
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
|
this.button1.Location = new System.Drawing.Point(254, 30);
|
||||||
|
this.button1.Name = "button1";
|
||||||
|
this.button1.Size = new System.Drawing.Size(80, 21);
|
||||||
|
this.button1.TabIndex = 9;
|
||||||
|
this.button1.Text = "Browse...";
|
||||||
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
|
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||||
|
//
|
||||||
|
// saveFileDialog
|
||||||
|
//
|
||||||
|
this.saveFileDialog.Filter = "*.*|*.*";
|
||||||
|
this.saveFileDialog.RestoreDirectory = true;
|
||||||
|
this.saveFileDialog.Title = "Save as...";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(18, 34);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(29, 12);
|
||||||
|
this.label1.TabIndex = 10;
|
||||||
|
this.label1.Text = "Size";
|
||||||
|
//
|
||||||
|
// lblSize
|
||||||
|
//
|
||||||
|
this.lblSize.AutoSize = true;
|
||||||
|
this.lblSize.Location = new System.Drawing.Point(61, 34);
|
||||||
|
this.lblSize.Name = "lblSize";
|
||||||
|
this.lblSize.Size = new System.Drawing.Size(35, 12);
|
||||||
|
this.lblSize.TabIndex = 11;
|
||||||
|
this.lblSize.Text = "bytes";
|
||||||
|
//
|
||||||
|
// FileTransferForm
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.CancelButton = this.btnCancel;
|
||||||
|
this.ClientSize = new System.Drawing.Size(345, 142);
|
||||||
|
this.ControlBox = false;
|
||||||
|
this.Controls.Add(this.lblSize);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.button1);
|
||||||
|
this.Controls.Add(this.progressBar);
|
||||||
|
this.Controls.Add(this.btnCancel);
|
||||||
|
this.Controls.Add(this.btnOK);
|
||||||
|
this.Controls.Add(this.txtFilePath);
|
||||||
|
this.Controls.Add(this.lblFile);
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.MinimizeBox = false;
|
||||||
|
this.Name = "FileTransferForm";
|
||||||
|
this.Text = "File Transfer";
|
||||||
|
this.Load += new System.EventHandler(this.FileTransferForm_Load);
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FileTransferForm_FormClosing);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Label lblFile;
|
||||||
|
private System.Windows.Forms.TextBox txtFilePath;
|
||||||
|
private System.Windows.Forms.Button btnOK;
|
||||||
|
private System.Windows.Forms.Button btnCancel;
|
||||||
|
private System.Windows.Forms.ProgressBar progressBar;
|
||||||
|
private System.Windows.Forms.Button button1;
|
||||||
|
private System.Windows.Forms.SaveFileDialog saveFileDialog;
|
||||||
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.Label lblSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
172
Example/FileTransferForm.cs
Normal file
|
|
@ -0,0 +1,172 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
using MSNPSharp.Core;
|
||||||
|
using MSNPSharp.DataTransfer;
|
||||||
|
|
||||||
|
|
||||||
|
public partial class FileTransferForm : Form
|
||||||
|
{
|
||||||
|
MSNSLPInvitationEventArgs invite;
|
||||||
|
private bool transferFinished;
|
||||||
|
|
||||||
|
public FileTransferForm(MSNSLPInvitationEventArgs invite)
|
||||||
|
{
|
||||||
|
this.invite = invite;
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FileTransferForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string appPath = Path.GetFullPath(".");
|
||||||
|
|
||||||
|
Text = "File Transfer: " + invite.TransferProperties.RemoteContact.Mail;
|
||||||
|
txtFilePath.Text = Path.Combine(appPath, invite.Filename);
|
||||||
|
lblSize.Text = invite.FileSize.ToString() + " bytes";
|
||||||
|
|
||||||
|
invite.TransferSession.TransferStarted += (TransferSession_TransferStarted);
|
||||||
|
invite.TransferSession.TransferProgressed += (TransferSession_TransferProgressed);
|
||||||
|
invite.TransferSession.TransferAborted += (TransferSession_TransferAborted);
|
||||||
|
invite.TransferSession.TransferFinished += (TransferSession_TransferFinished);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransferSession_TransferStarted(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (InvokeRequired)
|
||||||
|
{
|
||||||
|
Invoke(new EventHandler<EventArgs>(TransferSession_TransferStarted), sender, e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
progressBar.Visible = true;
|
||||||
|
lblSize.Text = "Transfer started";
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransferSession_TransferProgressed(object sender, P2PTransferProgressedEventArgs e)
|
||||||
|
{
|
||||||
|
if (InvokeRequired)
|
||||||
|
{
|
||||||
|
Invoke(new EventHandler<P2PTransferProgressedEventArgs>(TransferSession_TransferProgressed), sender, e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
progressBar.Visible = true;
|
||||||
|
progressBar.Value = e.Percent;
|
||||||
|
lblSize.Text = "Transferred: " + e.Transferred + " / " + e.TotalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransferSession_TransferFinished(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (InvokeRequired)
|
||||||
|
{
|
||||||
|
Invoke(new EventHandler<EventArgs>(TransferSession_TransferFinished), sender, e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transferFinished = true;
|
||||||
|
|
||||||
|
btnOK.Text = "Open File";
|
||||||
|
btnOK.Tag = "OPENFILE";
|
||||||
|
btnCancel.Visible = true;
|
||||||
|
|
||||||
|
lblSize.Text = "Transfer finished";
|
||||||
|
progressBar.Visible = false;
|
||||||
|
progressBar.Value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransferSession_TransferAborted(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (InvokeRequired)
|
||||||
|
{
|
||||||
|
Invoke(new EventHandler<EventArgs>(TransferSession_TransferAborted), sender, e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
btnOK.Text = "Close";
|
||||||
|
btnOK.Tag = "CLOSE";
|
||||||
|
lblSize.Text = "Transfer aborted";
|
||||||
|
|
||||||
|
progressBar.Visible = false;
|
||||||
|
progressBar.Value = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
txtFilePath.Text = saveFileDialog.FileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (transferFinished)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
invite.Accept = false;
|
||||||
|
invite.TransferHandler.RejectTransfer(invite);
|
||||||
|
|
||||||
|
btnCancel.Visible = false;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnOK_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
switch (btnOK.Tag.ToString())
|
||||||
|
{
|
||||||
|
case "OK":
|
||||||
|
|
||||||
|
invite.TransferSession.DataStream = new FileStream(txtFilePath.Text, FileMode.Create, FileAccess.Write);
|
||||||
|
invite.TransferSession.AutoCloseStream = true;
|
||||||
|
invite.Accept = true;
|
||||||
|
invite.TransferHandler.AcceptTransfer(invite);
|
||||||
|
|
||||||
|
btnCancel.Visible = false;
|
||||||
|
|
||||||
|
lblSize.Text = "Waiting to start...";
|
||||||
|
|
||||||
|
btnOK.Text = "Abort Transfer";
|
||||||
|
btnOK.Tag = "ABORT";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "ABORT":
|
||||||
|
invite.TransferHandler.CloseSession(invite.TransferSession);
|
||||||
|
btnOK.Text = "Close";
|
||||||
|
btnOK.Tag = "CLOSE";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "OPENFILE":
|
||||||
|
Process.Start(txtFilePath.Text);
|
||||||
|
Close();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "CLOSE":
|
||||||
|
Close();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FileTransferForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
invite.TransferSession.TransferStarted -= (TransferSession_TransferStarted);
|
||||||
|
invite.TransferSession.TransferProgressed -= (TransferSession_TransferProgressed);
|
||||||
|
invite.TransferSession.TransferAborted -= (TransferSession_TransferAborted);
|
||||||
|
invite.TransferSession.TransferFinished -= (TransferSession_TransferFinished);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
123
Example/FileTransferForm.resx
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
120
Example/ImportContacts.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
partial class ImportContacts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
||||||
|
this.lblInvitation = new System.Windows.Forms.Label();
|
||||||
|
this.txtInvitation = new System.Windows.Forms.TextBox();
|
||||||
|
this.browseFile = new System.Windows.Forms.Button();
|
||||||
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
|
this.button2 = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// openFileDialog
|
||||||
|
//
|
||||||
|
this.openFileDialog.DefaultExt = "ctt";
|
||||||
|
this.openFileDialog.Filter = "Messenger Contact List|*.ctt";
|
||||||
|
this.openFileDialog.Title = "Select Contact File";
|
||||||
|
//
|
||||||
|
// lblInvitation
|
||||||
|
//
|
||||||
|
this.lblInvitation.AutoSize = true;
|
||||||
|
this.lblInvitation.Location = new System.Drawing.Point(12, 20);
|
||||||
|
this.lblInvitation.Name = "lblInvitation";
|
||||||
|
this.lblInvitation.Size = new System.Drawing.Size(96, 13);
|
||||||
|
this.lblInvitation.TabIndex = 0;
|
||||||
|
this.lblInvitation.Text = "Invitation Message";
|
||||||
|
//
|
||||||
|
// txtInvitation
|
||||||
|
//
|
||||||
|
this.txtInvitation.Location = new System.Drawing.Point(114, 17);
|
||||||
|
this.txtInvitation.Name = "txtInvitation";
|
||||||
|
this.txtInvitation.Size = new System.Drawing.Size(342, 20);
|
||||||
|
this.txtInvitation.TabIndex = 1;
|
||||||
|
this.txtInvitation.Text = "Accept me :)";
|
||||||
|
//
|
||||||
|
// browseFile
|
||||||
|
//
|
||||||
|
this.browseFile.Location = new System.Drawing.Point(114, 43);
|
||||||
|
this.browseFile.Name = "browseFile";
|
||||||
|
this.browseFile.Size = new System.Drawing.Size(134, 23);
|
||||||
|
this.browseFile.TabIndex = 2;
|
||||||
|
this.browseFile.Text = "Browse Contact File...";
|
||||||
|
this.browseFile.UseVisualStyleBackColor = true;
|
||||||
|
this.browseFile.Click += new System.EventHandler(this.browseFile_Click);
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||||
|
this.button1.Location = new System.Drawing.Point(283, 73);
|
||||||
|
this.button1.Name = "button1";
|
||||||
|
this.button1.Size = new System.Drawing.Size(84, 23);
|
||||||
|
this.button1.TabIndex = 3;
|
||||||
|
this.button1.Text = "OK";
|
||||||
|
this.button1.UseVisualStyleBackColor = true;
|
||||||
|
this.button1.Click += new System.EventHandler(this.button_Click);
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
|
this.button2.Location = new System.Drawing.Point(373, 73);
|
||||||
|
this.button2.Name = "button2";
|
||||||
|
this.button2.Size = new System.Drawing.Size(83, 23);
|
||||||
|
this.button2.TabIndex = 4;
|
||||||
|
this.button2.Text = "Cancel";
|
||||||
|
this.button2.UseVisualStyleBackColor = true;
|
||||||
|
this.button2.Click += new System.EventHandler(this.button_Click);
|
||||||
|
//
|
||||||
|
// ImportContacts
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(466, 108);
|
||||||
|
this.Controls.Add(this.button2);
|
||||||
|
this.Controls.Add(this.button1);
|
||||||
|
this.Controls.Add(this.browseFile);
|
||||||
|
this.Controls.Add(this.txtInvitation);
|
||||||
|
this.Controls.Add(this.lblInvitation);
|
||||||
|
this.Name = "ImportContacts";
|
||||||
|
this.Text = "Import Contacts";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.OpenFileDialog openFileDialog;
|
||||||
|
private System.Windows.Forms.Label lblInvitation;
|
||||||
|
private System.Windows.Forms.TextBox txtInvitation;
|
||||||
|
private System.Windows.Forms.Button browseFile;
|
||||||
|
private System.Windows.Forms.Button button1;
|
||||||
|
private System.Windows.Forms.Button button2;
|
||||||
|
}
|
||||||
|
}
|
||||||
73
Example/ImportContacts.cs
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using MSNPSharp;
|
||||||
|
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
public partial class ImportContacts : Form
|
||||||
|
{
|
||||||
|
public ImportContacts()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private string invitationMessage = String.Empty;
|
||||||
|
public string InvitationMessage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return invitationMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string> _contacts = new List<string>();
|
||||||
|
public List<string> Contacts
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _contacts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void browseFile_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (DialogResult.OK == openFileDialog.ShowDialog(this))
|
||||||
|
{
|
||||||
|
Contacts.Clear();
|
||||||
|
invitationMessage = txtInvitation.Text;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
XmlDocument doc = new XmlDocument();
|
||||||
|
doc.LoadXml(File.ReadAllText(openFileDialog.FileName));
|
||||||
|
|
||||||
|
XmlNodeList contacts = doc.GetElementsByTagName("contact");
|
||||||
|
foreach (XmlNode contactNode in contacts)
|
||||||
|
{
|
||||||
|
if (ClientType.PassportMember == (ClientType)Convert.ToInt32(contactNode.Attributes["type"].Value))
|
||||||
|
{
|
||||||
|
Contacts.Add(contactNode.InnerText.ToLower(System.Globalization.CultureInfo.InvariantCulture));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
MessageBox.Show(Contacts.Count.ToString() + " contacts to be imported.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
123
Example/ImportContacts.resx
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
BIN
Example/MSNPSharp_logo.ico
Normal file
|
After Width: | Height: | Size: 91 KiB |
142
Example/MusicForm.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,142 @@
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
partial class MusicForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.lblArtist = new System.Windows.Forms.Label();
|
||||||
|
this.lblSong = new System.Windows.Forms.Label();
|
||||||
|
this.lblAlbum = new System.Windows.Forms.Label();
|
||||||
|
this.txtArtist = new System.Windows.Forms.TextBox();
|
||||||
|
this.txtSong = new System.Windows.Forms.TextBox();
|
||||||
|
this.txtAlbum = new System.Windows.Forms.TextBox();
|
||||||
|
this.btnOK = new System.Windows.Forms.Button();
|
||||||
|
this.btnCancel = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// lblArtist
|
||||||
|
//
|
||||||
|
this.lblArtist.AutoSize = true;
|
||||||
|
this.lblArtist.Location = new System.Drawing.Point(18, 9);
|
||||||
|
this.lblArtist.Name = "lblArtist";
|
||||||
|
this.lblArtist.Size = new System.Drawing.Size(30, 13);
|
||||||
|
this.lblArtist.TabIndex = 0;
|
||||||
|
this.lblArtist.Text = "Artist";
|
||||||
|
//
|
||||||
|
// lblSong
|
||||||
|
//
|
||||||
|
this.lblSong.AutoSize = true;
|
||||||
|
this.lblSong.Location = new System.Drawing.Point(16, 35);
|
||||||
|
this.lblSong.Name = "lblSong";
|
||||||
|
this.lblSong.Size = new System.Drawing.Size(32, 13);
|
||||||
|
this.lblSong.TabIndex = 1;
|
||||||
|
this.lblSong.Text = "Song";
|
||||||
|
//
|
||||||
|
// lblAlbum
|
||||||
|
//
|
||||||
|
this.lblAlbum.AutoSize = true;
|
||||||
|
this.lblAlbum.Location = new System.Drawing.Point(12, 59);
|
||||||
|
this.lblAlbum.Name = "lblAlbum";
|
||||||
|
this.lblAlbum.Size = new System.Drawing.Size(36, 13);
|
||||||
|
this.lblAlbum.TabIndex = 2;
|
||||||
|
this.lblAlbum.Text = "Album";
|
||||||
|
//
|
||||||
|
// txtArtist
|
||||||
|
//
|
||||||
|
this.txtArtist.Location = new System.Drawing.Point(64, 6);
|
||||||
|
this.txtArtist.Name = "txtArtist";
|
||||||
|
this.txtArtist.Size = new System.Drawing.Size(297, 20);
|
||||||
|
this.txtArtist.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// txtSong
|
||||||
|
//
|
||||||
|
this.txtSong.Location = new System.Drawing.Point(64, 32);
|
||||||
|
this.txtSong.Name = "txtSong";
|
||||||
|
this.txtSong.Size = new System.Drawing.Size(297, 20);
|
||||||
|
this.txtSong.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// txtAlbum
|
||||||
|
//
|
||||||
|
this.txtAlbum.Location = new System.Drawing.Point(64, 56);
|
||||||
|
this.txtAlbum.Name = "txtAlbum";
|
||||||
|
this.txtAlbum.Size = new System.Drawing.Size(297, 20);
|
||||||
|
this.txtAlbum.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// btnOK
|
||||||
|
//
|
||||||
|
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||||
|
this.btnOK.Location = new System.Drawing.Point(204, 82);
|
||||||
|
this.btnOK.Name = "btnOK";
|
||||||
|
this.btnOK.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnOK.TabIndex = 6;
|
||||||
|
this.btnOK.Text = "OK";
|
||||||
|
this.btnOK.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// btnCancel
|
||||||
|
//
|
||||||
|
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
|
this.btnCancel.Location = new System.Drawing.Point(285, 82);
|
||||||
|
this.btnCancel.Name = "btnCancel";
|
||||||
|
this.btnCancel.Size = new System.Drawing.Size(76, 23);
|
||||||
|
this.btnCancel.TabIndex = 7;
|
||||||
|
this.btnCancel.Text = "Cancel";
|
||||||
|
this.btnCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// MusicForm
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(374, 113);
|
||||||
|
this.Controls.Add(this.btnCancel);
|
||||||
|
this.Controls.Add(this.btnOK);
|
||||||
|
this.Controls.Add(this.txtAlbum);
|
||||||
|
this.Controls.Add(this.txtSong);
|
||||||
|
this.Controls.Add(this.txtArtist);
|
||||||
|
this.Controls.Add(this.lblAlbum);
|
||||||
|
this.Controls.Add(this.lblSong);
|
||||||
|
this.Controls.Add(this.lblArtist);
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.MinimizeBox = false;
|
||||||
|
this.Name = "MusicForm";
|
||||||
|
this.Text = "I am Listening...";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Label lblArtist;
|
||||||
|
private System.Windows.Forms.Label lblSong;
|
||||||
|
private System.Windows.Forms.Label lblAlbum;
|
||||||
|
private System.Windows.Forms.TextBox txtArtist;
|
||||||
|
private System.Windows.Forms.TextBox txtSong;
|
||||||
|
private System.Windows.Forms.TextBox txtAlbum;
|
||||||
|
private System.Windows.Forms.Button btnOK;
|
||||||
|
private System.Windows.Forms.Button btnCancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
44
Example/MusicForm.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
public partial class MusicForm : Form
|
||||||
|
{
|
||||||
|
public MusicForm()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string Artist
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return txtArtist.Text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Song
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return txtSong.Text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Album
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return txtSong.Text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
120
Example/MusicForm.resx
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
20
Example/Properties/AssemblyInfo.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
[assembly: ComVisibleAttribute(false)]
|
||||||
|
[assembly: CLSCompliantAttribute(false)]
|
||||||
|
[assembly: AssemblyTitleAttribute("MSNPSharp Example Client")]
|
||||||
|
[assembly: AssemblyDescriptionAttribute(".NET MSN Messenger library Example Client")]
|
||||||
|
[assembly: AssemblyCopyrightAttribute("Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.")]
|
||||||
|
[assembly: AssemblyProductAttribute("MSNPSharp")]
|
||||||
|
[assembly: AssemblyDelaySignAttribute(false)]
|
||||||
|
[assembly: GuidAttribute("FAE04EC0-301F-11D3-BF4B-00C04F79EFBC")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
// Major.Minor.Build.SVNRevision
|
||||||
|
[assembly: AssemblyVersionAttribute("3.2.1.2668")]
|
||||||
|
[assembly: AssemblyFileVersionAttribute("3.2.1.2668")]
|
||||||
|
[assembly: AssemblyCompanyAttribute("MSNPSharp")]
|
||||||
|
[assembly: AssemblyTrademarkAttribute("MSNPSharp")]
|
||||||
303
Example/Properties/Resources.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,303 @@
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace MSNPSharpClient.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
// class via a tool like ResGen or Visual Studio.
|
||||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
// with the /str option, or rebuild your VS project.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MSNPSharpClient.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap app_banner {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("app_banner", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap away {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("away", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap biggrin {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("biggrin", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap busy {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("busy", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap circle {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("circle", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap closed {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("closed", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap Color_fontHS {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("Color_fontHS", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap file {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("file", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap hidden {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("hidden", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap idle {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("idle", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap inner_emoticon {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("inner_emoticon", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap loading {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("loading", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Icon msn_ico {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("msn_ico", resourceCulture);
|
||||||
|
return ((System.Drawing.Icon)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Icon MSNPSharp_logo_small_ico {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("MSNPSharp_logo_small_ico", resourceCulture);
|
||||||
|
return ((System.Drawing.Icon)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap nudge {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("nudge", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap offline {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("offline", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap online {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("online", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap open {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("open", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap sad {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("sad", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap smiley {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("smiley", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap tongueout {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("tongueout", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap wink {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("wink", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Icon yahoo_ico {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("yahoo_ico", resourceCulture);
|
||||||
|
return ((System.Drawing.Icon)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap YahooMessenger_logo {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("YahooMessenger_logo", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
193
Example/Properties/Resources.resx
Normal file
|
|
@ -0,0 +1,193 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="yahoo_ico" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\yahoo_ico.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="sad" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\smileys\sad.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="nudge" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\nudge.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="MSNPSharp_logo_small_ico" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\MSNPSharp_logo_small.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="biggrin" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\smileys\biggrin.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="away" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\status\away.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="msn_ico" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\msn_ico.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="idle" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\status\idle.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="loading" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\loading.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="wink" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\smileys\wink.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="busy" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\status\busy.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="hidden" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\status\hidden.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="online" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\status\online.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="file" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\file.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="offline" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\status\offline.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="circle" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\status\circle.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="closed" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\status\closed.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="YahooMessenger_logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\YahooMessenger_logo.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="open" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\status\open.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="tongueout" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\smileys\tongueout.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="smiley" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\smileys\smiley.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="inner_emoticon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\inner_emoicon.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="app_banner" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\app_banner.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="Color_fontHS" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\Color_fontHS.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
||||||
102
Example/RemoveContactForm.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
partial class RemoveContactForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.cbRemove = new System.Windows.Forms.CheckBox();
|
||||||
|
this.cbBlock = new System.Windows.Forms.CheckBox();
|
||||||
|
this.btnRemove = new System.Windows.Forms.Button();
|
||||||
|
this.btnCancel = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// cbRemove
|
||||||
|
//
|
||||||
|
this.cbRemove.AutoSize = true;
|
||||||
|
this.cbRemove.Location = new System.Drawing.Point(12, 21);
|
||||||
|
this.cbRemove.Name = "cbRemove";
|
||||||
|
this.cbRemove.Size = new System.Drawing.Size(201, 17);
|
||||||
|
this.cbRemove.TabIndex = 0;
|
||||||
|
this.cbRemove.Text = "Remove this user from my contact list";
|
||||||
|
this.cbRemove.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// cbBlock
|
||||||
|
//
|
||||||
|
this.cbBlock.AutoSize = true;
|
||||||
|
this.cbBlock.Location = new System.Drawing.Point(12, 44);
|
||||||
|
this.cbBlock.Name = "cbBlock";
|
||||||
|
this.cbBlock.Size = new System.Drawing.Size(75, 17);
|
||||||
|
this.cbBlock.TabIndex = 1;
|
||||||
|
this.cbBlock.Text = "Also block";
|
||||||
|
this.cbBlock.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// btnRemove
|
||||||
|
//
|
||||||
|
this.btnRemove.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||||
|
this.btnRemove.Location = new System.Drawing.Point(24, 76);
|
||||||
|
this.btnRemove.Name = "btnRemove";
|
||||||
|
this.btnRemove.Size = new System.Drawing.Size(99, 23);
|
||||||
|
this.btnRemove.TabIndex = 2;
|
||||||
|
this.btnRemove.Text = "Remove contact";
|
||||||
|
this.btnRemove.UseVisualStyleBackColor = true;
|
||||||
|
this.btnRemove.Click += new System.EventHandler(this.btn_Click);
|
||||||
|
//
|
||||||
|
// btnCancel
|
||||||
|
//
|
||||||
|
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
|
this.btnCancel.Location = new System.Drawing.Point(129, 76);
|
||||||
|
this.btnCancel.Name = "btnCancel";
|
||||||
|
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnCancel.TabIndex = 3;
|
||||||
|
this.btnCancel.Text = "Cancel";
|
||||||
|
this.btnCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.btnCancel.Click += new System.EventHandler(this.btn_Click);
|
||||||
|
//
|
||||||
|
// RemoveContactForm
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(217, 113);
|
||||||
|
this.Controls.Add(this.btnCancel);
|
||||||
|
this.Controls.Add(this.btnRemove);
|
||||||
|
this.Controls.Add(this.cbBlock);
|
||||||
|
this.Controls.Add(this.cbRemove);
|
||||||
|
this.Name = "RemoveContactForm";
|
||||||
|
this.Text = "Remove Contact";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.CheckBox cbRemove;
|
||||||
|
private System.Windows.Forms.CheckBox cbBlock;
|
||||||
|
private System.Windows.Forms.Button btnRemove;
|
||||||
|
private System.Windows.Forms.Button btnCancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
40
Example/RemoveContactForm.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
public partial class RemoveContactForm : Form
|
||||||
|
{
|
||||||
|
|
||||||
|
public bool RemoveFromAddressBook
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return cbRemove.Checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Block
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return cbBlock.Checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public RemoveContactForm()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
Example/RemoveContactForm.resx
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
BIN
Example/Resources/Color_fontHS.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
Example/Resources/MSNPSharp_logo.ico
Normal file
|
After Width: | Height: | Size: 91 KiB |
BIN
Example/Resources/MSNPSharp_logo_small.ico
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
Example/Resources/YahooMessenger_logo.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
Example/Resources/app_banner.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
Example/Resources/file.png
Normal file
|
After Width: | Height: | Size: 917 B |
BIN
Example/Resources/inner_emoicon.png
Normal file
|
After Width: | Height: | Size: 7 KiB |
BIN
Example/Resources/loading.gif
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
Example/Resources/msn_ico.ico
Normal file
|
After Width: | Height: | Size: 7.1 KiB |
BIN
Example/Resources/nudge.png
Normal file
|
After Width: | Height: | Size: 823 B |
BIN
Example/Resources/smileys/biggrin.gif
Normal file
|
After Width: | Height: | Size: 230 B |
BIN
Example/Resources/smileys/sad.gif
Normal file
|
After Width: | Height: | Size: 236 B |
BIN
Example/Resources/smileys/smiley.gif
Normal file
|
After Width: | Height: | Size: 244 B |
BIN
Example/Resources/smileys/tongueout.gif
Normal file
|
After Width: | Height: | Size: 248 B |
BIN
Example/Resources/smileys/wink.gif
Normal file
|
After Width: | Height: | Size: 243 B |
BIN
Example/Resources/status/away.png
Normal file
|
After Width: | Height: | Size: 152 B |
BIN
Example/Resources/status/busy.png
Normal file
|
After Width: | Height: | Size: 152 B |
BIN
Example/Resources/status/circle.png
Normal file
|
After Width: | Height: | Size: 190 B |
BIN
Example/Resources/status/closed.png
Normal file
|
After Width: | Height: | Size: 179 B |
BIN
Example/Resources/status/hidden.png
Normal file
|
After Width: | Height: | Size: 152 B |
BIN
Example/Resources/status/idle.png
Normal file
|
After Width: | Height: | Size: 152 B |
BIN
Example/Resources/status/offline.png
Normal file
|
After Width: | Height: | Size: 151 B |
BIN
Example/Resources/status/online.png
Normal file
|
After Width: | Height: | Size: 152 B |
BIN
Example/Resources/status/open.png
Normal file
|
After Width: | Height: | Size: 152 B |
BIN
Example/Resources/yahoo_ico.ico
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
151
Example/ReverseAddedForm.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,151 @@
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
partial class ReverseAddedForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.lblAdded = new System.Windows.Forms.Label();
|
||||||
|
this.gbMembership = new System.Windows.Forms.GroupBox();
|
||||||
|
this.rbBlock = new System.Windows.Forms.RadioButton();
|
||||||
|
this.rbAllow = new System.Windows.Forms.RadioButton();
|
||||||
|
this.cbContactList = new System.Windows.Forms.CheckBox();
|
||||||
|
this.btnOK = new System.Windows.Forms.Button();
|
||||||
|
this.btnCancel = new System.Windows.Forms.Button();
|
||||||
|
this.gbMembership.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// lblAdded
|
||||||
|
//
|
||||||
|
this.lblAdded.AutoSize = true;
|
||||||
|
this.lblAdded.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
|
||||||
|
this.lblAdded.Location = new System.Drawing.Point(12, 9);
|
||||||
|
this.lblAdded.Name = "lblAdded";
|
||||||
|
this.lblAdded.Size = new System.Drawing.Size(226, 13);
|
||||||
|
this.lblAdded.TabIndex = 0;
|
||||||
|
this.lblAdded.Text = "{0} has added you to their contact list.";
|
||||||
|
//
|
||||||
|
// gbMembership
|
||||||
|
//
|
||||||
|
this.gbMembership.Controls.Add(this.rbBlock);
|
||||||
|
this.gbMembership.Controls.Add(this.rbAllow);
|
||||||
|
this.gbMembership.Location = new System.Drawing.Point(15, 36);
|
||||||
|
this.gbMembership.Name = "gbMembership";
|
||||||
|
this.gbMembership.Size = new System.Drawing.Size(441, 74);
|
||||||
|
this.gbMembership.TabIndex = 1;
|
||||||
|
this.gbMembership.TabStop = false;
|
||||||
|
this.gbMembership.Text = "Add contact to:";
|
||||||
|
//
|
||||||
|
// rbBlock
|
||||||
|
//
|
||||||
|
this.rbBlock.AutoSize = true;
|
||||||
|
this.rbBlock.Location = new System.Drawing.Point(15, 42);
|
||||||
|
this.rbBlock.Name = "rbBlock";
|
||||||
|
this.rbBlock.Size = new System.Drawing.Size(421, 17);
|
||||||
|
this.rbBlock.TabIndex = 1;
|
||||||
|
this.rbBlock.Text = "Blocked List (User can not see my online status and can not send instant messages" +
|
||||||
|
")";
|
||||||
|
this.rbBlock.UseVisualStyleBackColor = true;
|
||||||
|
this.rbBlock.CheckedChanged += new System.EventHandler(this.rbBlock_CheckedChanged);
|
||||||
|
//
|
||||||
|
// rbAllow
|
||||||
|
//
|
||||||
|
this.rbAllow.AutoSize = true;
|
||||||
|
this.rbAllow.Checked = true;
|
||||||
|
this.rbAllow.Location = new System.Drawing.Point(15, 19);
|
||||||
|
this.rbAllow.Name = "rbAllow";
|
||||||
|
this.rbAllow.Size = new System.Drawing.Size(352, 17);
|
||||||
|
this.rbAllow.TabIndex = 0;
|
||||||
|
this.rbAllow.TabStop = true;
|
||||||
|
this.rbAllow.Text = "Allowed List (User can see my status and can send instant messages)";
|
||||||
|
this.rbAllow.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// cbContactList
|
||||||
|
//
|
||||||
|
this.cbContactList.AutoSize = true;
|
||||||
|
this.cbContactList.Checked = true;
|
||||||
|
this.cbContactList.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
|
this.cbContactList.Location = new System.Drawing.Point(30, 125);
|
||||||
|
this.cbContactList.Name = "cbContactList";
|
||||||
|
this.cbContactList.Size = new System.Drawing.Size(169, 17);
|
||||||
|
this.cbContactList.TabIndex = 2;
|
||||||
|
this.cbContactList.Text = "Add this user to my contact list";
|
||||||
|
this.cbContactList.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// btnOK
|
||||||
|
//
|
||||||
|
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||||
|
this.btnOK.Location = new System.Drawing.Point(302, 125);
|
||||||
|
this.btnOK.Name = "btnOK";
|
||||||
|
this.btnOK.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnOK.TabIndex = 3;
|
||||||
|
this.btnOK.Text = "OK";
|
||||||
|
this.btnOK.UseVisualStyleBackColor = true;
|
||||||
|
this.btnOK.Click += new System.EventHandler(this.btn_Click);
|
||||||
|
//
|
||||||
|
// btnCancel
|
||||||
|
//
|
||||||
|
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
|
this.btnCancel.Location = new System.Drawing.Point(381, 125);
|
||||||
|
this.btnCancel.Name = "btnCancel";
|
||||||
|
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnCancel.TabIndex = 4;
|
||||||
|
this.btnCancel.Text = "Cancel";
|
||||||
|
this.btnCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.btnCancel.Click += new System.EventHandler(this.btn_Click);
|
||||||
|
//
|
||||||
|
// ReverseAddedForm
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(470, 156);
|
||||||
|
this.Controls.Add(this.btnCancel);
|
||||||
|
this.Controls.Add(this.btnOK);
|
||||||
|
this.Controls.Add(this.cbContactList);
|
||||||
|
this.Controls.Add(this.gbMembership);
|
||||||
|
this.Controls.Add(this.lblAdded);
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.MinimizeBox = false;
|
||||||
|
this.Name = "ReverseAddedForm";
|
||||||
|
this.Text = "Pending Contact {0}";
|
||||||
|
this.gbMembership.ResumeLayout(false);
|
||||||
|
this.gbMembership.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Label lblAdded;
|
||||||
|
private System.Windows.Forms.GroupBox gbMembership;
|
||||||
|
private System.Windows.Forms.RadioButton rbAllow;
|
||||||
|
private System.Windows.Forms.RadioButton rbBlock;
|
||||||
|
private System.Windows.Forms.CheckBox cbContactList;
|
||||||
|
private System.Windows.Forms.Button btnOK;
|
||||||
|
private System.Windows.Forms.Button btnCancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
51
Example/ReverseAddedForm.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using MSNPSharp;
|
||||||
|
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
public partial class ReverseAddedForm : Form
|
||||||
|
{
|
||||||
|
public ReverseAddedForm(Contact contact)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
Text = String.Format(Text, contact.Mail);
|
||||||
|
lblAdded.Text = String.Format(lblAdded.Text, contact.Name + " (" + contact.Mail + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Blocked
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return rbBlock.Checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AddToContactList
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return cbContactList.Checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rbBlock_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (rbBlock.Checked)
|
||||||
|
{
|
||||||
|
cbContactList.Checked = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btn_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
Example/ReverseAddedForm.resx
Normal file
|
|
@ -0,0 +1,120 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
427
Example/RtfRichTextBox.cs
Normal file
|
|
@ -0,0 +1,427 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.Data;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
|
||||||
|
public class RtfRichTextBox : RichTextBox
|
||||||
|
{
|
||||||
|
[DllImport("gdiplus.dll")]
|
||||||
|
private static extern uint GdipEmfToWmfBits(IntPtr _hEmf, uint _bufferSize, byte[] _buffer, int _mappingMode, EmfToWmfBitsFlags _flags);
|
||||||
|
|
||||||
|
#region .cctor
|
||||||
|
static bool hasGdiPlus = false;
|
||||||
|
static RtfRichTextBox()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(!Settings.IsMono)
|
||||||
|
{
|
||||||
|
//We are in M$ Windows!
|
||||||
|
GdipEmfToWmfBits(IntPtr.Zero, 0, null, 0, 0);
|
||||||
|
hasGdiPlus = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
private float xDpi;
|
||||||
|
private float yDpi;
|
||||||
|
|
||||||
|
private RtfColor textColor = RtfColor.Black;
|
||||||
|
private RtfColor highlightColor = RtfColor.White;
|
||||||
|
private Dictionary<string, Bitmap> emotions = new Dictionary<string, Bitmap>();
|
||||||
|
private Dictionary<RtfColor, string> rtfColor = new Dictionary<RtfColor, string>();
|
||||||
|
private Dictionary<string, string> rtfFontFamily = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
public RtfRichTextBox()
|
||||||
|
{
|
||||||
|
rtfColor.Add(RtfColor.Aqua, @"\red0\green255\blue255");
|
||||||
|
rtfColor.Add(RtfColor.Black, @"\red0\green0\blue0");
|
||||||
|
rtfColor.Add(RtfColor.Blue, @"\red0\green0\blue255");
|
||||||
|
rtfColor.Add(RtfColor.Fuchsia, @"\red255\green0\blue255");
|
||||||
|
rtfColor.Add(RtfColor.Gray, @"\red128\green128\blue128");
|
||||||
|
rtfColor.Add(RtfColor.Green, @"\red0\green128\blue0");
|
||||||
|
rtfColor.Add(RtfColor.Lime, @"\red0\green255\blue0");
|
||||||
|
rtfColor.Add(RtfColor.Maroon, @"\red128\green0\blue0");
|
||||||
|
rtfColor.Add(RtfColor.Navy, @"\red0\green0\blue128");
|
||||||
|
rtfColor.Add(RtfColor.Olive, @"\red128\green128\blue0");
|
||||||
|
rtfColor.Add(RtfColor.Purple, @"\red128\green0\blue128");
|
||||||
|
rtfColor.Add(RtfColor.Red, @"\red255\green0\blue0");
|
||||||
|
rtfColor.Add(RtfColor.Silver, @"\red192\green192\blue192");
|
||||||
|
rtfColor.Add(RtfColor.Teal, @"\red0\green128\blue128");
|
||||||
|
rtfColor.Add(RtfColor.White, @"\red255\green255\blue255");
|
||||||
|
rtfColor.Add(RtfColor.Yellow, @"\red255\green255\blue0");
|
||||||
|
|
||||||
|
rtfFontFamily.Add(FontFamily.GenericMonospace.Name, @"\fmodern");
|
||||||
|
rtfFontFamily.Add(FontFamily.GenericSansSerif.Name, @"\fswiss");
|
||||||
|
rtfFontFamily.Add(FontFamily.GenericSerif.Name, @"\froman");
|
||||||
|
rtfFontFamily.Add("UNKNOWN", @"\fnil");
|
||||||
|
|
||||||
|
using (Graphics graphics = CreateGraphics())
|
||||||
|
{
|
||||||
|
xDpi = graphics.DpiX;
|
||||||
|
yDpi = graphics.DpiY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public RtfRichTextBox(RtfColor _textColor)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
textColor = _textColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RtfRichTextBox(RtfColor _textColor, RtfColor _highlightColor)
|
||||||
|
: this()
|
||||||
|
{
|
||||||
|
textColor = _textColor;
|
||||||
|
highlightColor = _highlightColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AppendRtf(string _rtf)
|
||||||
|
{
|
||||||
|
Select(TextLength, 0);
|
||||||
|
SelectionColor = Color.Black;
|
||||||
|
SelectedRtf = _rtf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AppendTextAsRtf(string _text)
|
||||||
|
{
|
||||||
|
AppendTextAsRtf(_text, Font);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AppendTextAsRtf(string _text, Font _font)
|
||||||
|
{
|
||||||
|
AppendTextAsRtf(_text, _font, textColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AppendTextAsRtf(string _text, Font _font, RtfColor _textColor)
|
||||||
|
{
|
||||||
|
AppendTextAsRtf(_text, _font, _textColor, highlightColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AppendTextAsRtf(string _text, Font _font, RtfColor _textColor, RtfColor _backColor)
|
||||||
|
{
|
||||||
|
Select(TextLength, 0);
|
||||||
|
InsertTextAsRtf(_text, _font, _textColor, _backColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetColorTable(RtfColor _textColor, RtfColor _backColor)
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.Append(@"{\colortbl ;");
|
||||||
|
builder.Append(rtfColor[_textColor]);
|
||||||
|
builder.Append(";");
|
||||||
|
builder.Append(rtfColor[_backColor]);
|
||||||
|
builder.Append(@";}\n");
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetDocumentArea(string _text, Font _font)
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.Append(@"\viewkind4\uc1\pard\cf1\f0\fs20");
|
||||||
|
builder.Append(@"\highlight2");
|
||||||
|
if (_font.Bold)
|
||||||
|
{
|
||||||
|
builder.Append(@"\b");
|
||||||
|
}
|
||||||
|
if (_font.Italic)
|
||||||
|
{
|
||||||
|
builder.Append(@"\i");
|
||||||
|
}
|
||||||
|
if (_font.Strikeout)
|
||||||
|
{
|
||||||
|
builder.Append(@"\strike");
|
||||||
|
}
|
||||||
|
if (_font.Underline)
|
||||||
|
{
|
||||||
|
builder.Append(@"\ul");
|
||||||
|
}
|
||||||
|
builder.Append(@"\f0");
|
||||||
|
builder.Append(@"\fs");
|
||||||
|
builder.Append((int)Math.Round((double)(2f * _font.SizeInPoints)));
|
||||||
|
builder.Append(" ");
|
||||||
|
builder.Append(_text.Replace("\n", @"\par "));
|
||||||
|
builder.Append(@"\highlight0");
|
||||||
|
if (_font.Bold)
|
||||||
|
{
|
||||||
|
builder.Append(@"\b0");
|
||||||
|
}
|
||||||
|
if (_font.Italic)
|
||||||
|
{
|
||||||
|
builder.Append(@"\i0");
|
||||||
|
}
|
||||||
|
if (_font.Strikeout)
|
||||||
|
{
|
||||||
|
builder.Append(@"\strike0");
|
||||||
|
}
|
||||||
|
if (_font.Underline)
|
||||||
|
{
|
||||||
|
builder.Append(@"\ulnone");
|
||||||
|
}
|
||||||
|
builder.Append(@"\f0");
|
||||||
|
builder.Append(@"\fs20");
|
||||||
|
builder.Append(@"\cf0\fs17}");
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetFontTable(Font _font)
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.Append(@"{\fonttbl{\f0");
|
||||||
|
builder.Append(@"\");
|
||||||
|
if (rtfFontFamily.ContainsKey(_font.FontFamily.Name))
|
||||||
|
{
|
||||||
|
builder.Append(rtfFontFamily[_font.FontFamily.Name]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.Append(rtfFontFamily["UNKNOWN"]);
|
||||||
|
}
|
||||||
|
builder.Append(@"\fcharset0 ");
|
||||||
|
builder.Append(_font.Name);
|
||||||
|
builder.Append(";}}");
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetImagePrefix(Image _image)
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
int picw = (int)Math.Round((double)((((float)_image.Width) / xDpi) * 2540f));
|
||||||
|
int pich = (int)Math.Round((double)((((float)_image.Height) / yDpi) * 2540f));
|
||||||
|
int picwgoal = (int)Math.Round((double)((((float)_image.Width) / xDpi) * 1440f));
|
||||||
|
int pichgoal = (int)Math.Round((double)((((float)_image.Height) / yDpi) * 1440f));
|
||||||
|
builder.Append(@"{\pict\wmetafile8");
|
||||||
|
builder.Append(@"\picw");
|
||||||
|
builder.Append(picw);
|
||||||
|
builder.Append(@"\pich");
|
||||||
|
builder.Append(pich);
|
||||||
|
builder.Append(@"\picwgoal");
|
||||||
|
builder.Append(picwgoal);
|
||||||
|
builder.Append(@"\pichgoal");
|
||||||
|
builder.Append(pichgoal);
|
||||||
|
builder.Append(" ");
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetRtfImage(Image _image)
|
||||||
|
{
|
||||||
|
MemoryStream stream = null;
|
||||||
|
Graphics graphics = null;
|
||||||
|
Metafile image = null;
|
||||||
|
string ret;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
stream = new MemoryStream();
|
||||||
|
using (graphics = CreateGraphics())
|
||||||
|
{
|
||||||
|
IntPtr hdc = graphics.GetHdc();
|
||||||
|
image = new Metafile(stream, hdc);
|
||||||
|
graphics.ReleaseHdc(hdc);
|
||||||
|
}
|
||||||
|
using (graphics = Graphics.FromImage(image))
|
||||||
|
{
|
||||||
|
graphics.DrawImage(_image, new Rectangle(0, 0, _image.Width, _image.Height));
|
||||||
|
}
|
||||||
|
IntPtr henhmetafile = image.GetHenhmetafile();
|
||||||
|
uint num = GdipEmfToWmfBits(henhmetafile, 0, null, 1, EmfToWmfBitsFlags.EmfToWmfBitsFlagsDefault);
|
||||||
|
byte[] buffer = new byte[num];
|
||||||
|
GdipEmfToWmfBits(henhmetafile, num, buffer, 1, EmfToWmfBitsFlags.EmfToWmfBitsFlagsDefault);
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (int i = 0; i < buffer.Length; i++)
|
||||||
|
{
|
||||||
|
builder.Append(string.Format("{0:X2}", buffer[i]));
|
||||||
|
}
|
||||||
|
ret = builder.ToString();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (graphics != null)
|
||||||
|
{
|
||||||
|
graphics.Dispose();
|
||||||
|
}
|
||||||
|
if (image != null)
|
||||||
|
{
|
||||||
|
image.Dispose();
|
||||||
|
}
|
||||||
|
if (stream != null)
|
||||||
|
{
|
||||||
|
stream.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InsertEmotion()
|
||||||
|
{
|
||||||
|
if (hasGdiPlus)
|
||||||
|
{
|
||||||
|
foreach (string emoticon in emotions.Keys)
|
||||||
|
{
|
||||||
|
int start = Find(emoticon, RichTextBoxFinds.None);
|
||||||
|
if (start > -1)
|
||||||
|
{
|
||||||
|
Select(start, emoticon.Length);
|
||||||
|
InsertImage(emotions[emoticon]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InsertImage(Image _image)
|
||||||
|
{
|
||||||
|
if (hasGdiPlus)
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033");
|
||||||
|
builder.Append(GetFontTable(Font));
|
||||||
|
builder.Append(GetImagePrefix(_image));
|
||||||
|
builder.Append(GetRtfImage(_image));
|
||||||
|
builder.Append(@"}");
|
||||||
|
|
||||||
|
SelectedRtf = builder.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InsertRtf(string _rtf)
|
||||||
|
{
|
||||||
|
SelectedRtf = _rtf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InsertTextAsRtf(string _text)
|
||||||
|
{
|
||||||
|
InsertTextAsRtf(_text, Font);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InsertTextAsRtf(string _text, Font _font)
|
||||||
|
{
|
||||||
|
InsertTextAsRtf(_text, _font, textColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InsertTextAsRtf(string _text, Font _font, RtfColor _textColor)
|
||||||
|
{
|
||||||
|
InsertTextAsRtf(_text, _font, _textColor, highlightColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InsertTextAsRtf(string _text, Font _font, RtfColor _textColor, RtfColor _backColor)
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033");
|
||||||
|
builder.Append(GetFontTable(_font));
|
||||||
|
builder.Append(GetColorTable(_textColor, _backColor));
|
||||||
|
builder.Append(GetDocumentArea(_text, _font));
|
||||||
|
|
||||||
|
SelectedRtf = builder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string RemoveBadChars(string _originalRtf)
|
||||||
|
{
|
||||||
|
return _originalRtf.Replace("\0", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, Bitmap> Emotions
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return emotions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasEmotion
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (hasGdiPlus)
|
||||||
|
{
|
||||||
|
foreach (string emoticon in emotions.Keys)
|
||||||
|
{
|
||||||
|
if (Text.IndexOf(emoticon, StringComparison.CurrentCultureIgnoreCase) > -1)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public RtfColor HiglightColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return highlightColor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
highlightColor = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public new string Rtf
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return RemoveBadChars(base.Rtf);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.Rtf = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public RtfColor TextColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return textColor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
textColor = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
private enum EmfToWmfBitsFlags
|
||||||
|
{
|
||||||
|
EmfToWmfBitsFlagsDefault = 0,
|
||||||
|
EmfToWmfBitsFlagsEmbedEmf = 1,
|
||||||
|
EmfToWmfBitsFlagsIncludePlaceable = 2,
|
||||||
|
EmfToWmfBitsFlagsNoXORClip = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum RtfColor
|
||||||
|
{
|
||||||
|
Black,
|
||||||
|
Maroon,
|
||||||
|
Green,
|
||||||
|
Olive,
|
||||||
|
Navy,
|
||||||
|
Purple,
|
||||||
|
Teal,
|
||||||
|
Gray,
|
||||||
|
Silver,
|
||||||
|
Red,
|
||||||
|
Lime,
|
||||||
|
Yellow,
|
||||||
|
Blue,
|
||||||
|
Fuchsia,
|
||||||
|
Aqua,
|
||||||
|
White
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
165
Example/TraceForm.Designer.cs
generated
Normal file
|
|
@ -0,0 +1,165 @@
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
partial class TraceForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows 窗体设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TraceForm));
|
||||||
|
this.tsbStart = new System.Windows.Forms.ToolStripButton();
|
||||||
|
this.tsbStop = new System.Windows.Forms.ToolStripButton();
|
||||||
|
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
|
this.tsbClear = new System.Windows.Forms.ToolStripButton();
|
||||||
|
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
|
||||||
|
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||||
|
this.toolStripLabelLevel = new System.Windows.Forms.ToolStripLabel();
|
||||||
|
this.toolStripComboBoxLevel = new System.Windows.Forms.ToolStripComboBox();
|
||||||
|
this.rtbTrace = new System.Windows.Forms.RichTextBox();
|
||||||
|
this.toolStrip1.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// tsbStart
|
||||||
|
//
|
||||||
|
this.tsbStart.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
|
||||||
|
this.tsbStart.Enabled = false;
|
||||||
|
this.tsbStart.Image = ((System.Drawing.Image)(resources.GetObject("tsbStart.Image")));
|
||||||
|
this.tsbStart.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||||
|
this.tsbStart.Name = "tsbStart";
|
||||||
|
this.tsbStart.Size = new System.Drawing.Size(35, 22);
|
||||||
|
this.tsbStart.Text = "Start";
|
||||||
|
this.tsbStart.ToolTipText = "Start Tracing";
|
||||||
|
this.tsbStart.Click += new System.EventHandler(this.tsbStart_Click);
|
||||||
|
//
|
||||||
|
// tsbStop
|
||||||
|
//
|
||||||
|
this.tsbStop.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
|
||||||
|
this.tsbStop.Image = ((System.Drawing.Image)(resources.GetObject("tsbStop.Image")));
|
||||||
|
this.tsbStop.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||||
|
this.tsbStop.Name = "tsbStop";
|
||||||
|
this.tsbStop.Size = new System.Drawing.Size(35, 22);
|
||||||
|
this.tsbStop.Text = "Stop";
|
||||||
|
this.tsbStop.ToolTipText = "Stop Tracing";
|
||||||
|
this.tsbStop.Click += new System.EventHandler(this.tsbStop_Click);
|
||||||
|
//
|
||||||
|
// toolStripSeparator1
|
||||||
|
//
|
||||||
|
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||||
|
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
|
||||||
|
//
|
||||||
|
// tsbClear
|
||||||
|
//
|
||||||
|
this.tsbClear.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
|
||||||
|
this.tsbClear.Image = ((System.Drawing.Image)(resources.GetObject("tsbClear.Image")));
|
||||||
|
this.tsbClear.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||||
|
this.tsbClear.Name = "tsbClear";
|
||||||
|
this.tsbClear.Size = new System.Drawing.Size(38, 22);
|
||||||
|
this.tsbClear.Text = "Clear";
|
||||||
|
this.tsbClear.ToolTipText = "Clear All";
|
||||||
|
this.tsbClear.Click += new System.EventHandler(this.tsbClear_Click);
|
||||||
|
//
|
||||||
|
// toolStrip1
|
||||||
|
//
|
||||||
|
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.tsbStart,
|
||||||
|
this.tsbStop,
|
||||||
|
this.toolStripSeparator1,
|
||||||
|
this.tsbClear,
|
||||||
|
this.toolStripSeparator2,
|
||||||
|
this.toolStripLabelLevel,
|
||||||
|
this.toolStripComboBoxLevel});
|
||||||
|
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.toolStrip1.Name = "toolStrip1";
|
||||||
|
this.toolStrip1.Size = new System.Drawing.Size(661, 25);
|
||||||
|
this.toolStrip1.TabIndex = 1;
|
||||||
|
this.toolStrip1.Text = "toolStrip1";
|
||||||
|
//
|
||||||
|
// toolStripSeparator2
|
||||||
|
//
|
||||||
|
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||||
|
this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
|
||||||
|
//
|
||||||
|
// toolStripLabelLevel
|
||||||
|
//
|
||||||
|
this.toolStripLabelLevel.Name = "toolStripLabelLevel";
|
||||||
|
this.toolStripLabelLevel.Size = new System.Drawing.Size(40, 22);
|
||||||
|
this.toolStripLabelLevel.Text = "Level: ";
|
||||||
|
//
|
||||||
|
// toolStripComboBoxLevel
|
||||||
|
//
|
||||||
|
this.toolStripComboBoxLevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.toolStripComboBoxLevel.Items.AddRange(new object[] {
|
||||||
|
"Verbose",
|
||||||
|
"Info",
|
||||||
|
"Warning",
|
||||||
|
"Error",
|
||||||
|
"Off"});
|
||||||
|
this.toolStripComboBoxLevel.Name = "toolStripComboBoxLevel";
|
||||||
|
this.toolStripComboBoxLevel.Size = new System.Drawing.Size(121, 25);
|
||||||
|
this.toolStripComboBoxLevel.SelectedIndexChanged += new System.EventHandler(this.toolStripComboBoxLevel_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// rtbTrace
|
||||||
|
//
|
||||||
|
this.rtbTrace.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.rtbTrace.Location = new System.Drawing.Point(0, 30);
|
||||||
|
this.rtbTrace.Name = "rtbTrace";
|
||||||
|
this.rtbTrace.Size = new System.Drawing.Size(661, 457);
|
||||||
|
this.rtbTrace.TabIndex = 0;
|
||||||
|
this.rtbTrace.Text = "";
|
||||||
|
//
|
||||||
|
// TraceForm
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(661, 488);
|
||||||
|
this.Controls.Add(this.toolStrip1);
|
||||||
|
this.Controls.Add(this.rtbTrace);
|
||||||
|
this.Name = "TraceForm";
|
||||||
|
this.Text = "TraceForm";
|
||||||
|
this.Load += new System.EventHandler(this.TraceForm_Load);
|
||||||
|
this.toolStrip1.ResumeLayout(false);
|
||||||
|
this.toolStrip1.PerformLayout();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.ToolStripButton tsbStart;
|
||||||
|
private System.Windows.Forms.ToolStripButton tsbStop;
|
||||||
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||||
|
private System.Windows.Forms.ToolStripButton tsbClear;
|
||||||
|
private System.Windows.Forms.ToolStrip toolStrip1;
|
||||||
|
private System.Windows.Forms.RichTextBox rtbTrace;
|
||||||
|
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
||||||
|
private System.Windows.Forms.ToolStripLabel toolStripLabelLevel;
|
||||||
|
private System.Windows.Forms.ToolStripComboBox toolStripComboBoxLevel;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
291
Example/TraceForm.cs
Normal file
|
|
@ -0,0 +1,291 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.IO;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Security.Permissions;
|
||||||
|
|
||||||
|
namespace MSNPSharpClient
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
|
||||||
|
public partial class TraceForm : Form
|
||||||
|
{
|
||||||
|
RichTextBoxTraceListener rtbTraceListener = null;
|
||||||
|
public TraceForm()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.Icon = Properties.Resources.MSNPSharp_logo_small_ico;
|
||||||
|
rtbTraceListener = new RichTextBoxTraceListener(rtbTrace);
|
||||||
|
Trace.Listeners.Add(rtbTraceListener);
|
||||||
|
|
||||||
|
FormClosing += new FormClosingEventHandler(TraceForm_FormClosing);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TraceForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
rtbTraceListener.Close();
|
||||||
|
Trace.Listeners.Remove(rtbTraceListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tsbClear_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
rtbTrace.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tsbStop_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
rtbTraceListener.Stop();
|
||||||
|
tsbStart.Enabled = true;
|
||||||
|
tsbStop.Enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tsbStart_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
rtbTraceListener.Resume();
|
||||||
|
tsbStart.Enabled = false;
|
||||||
|
tsbStop.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TraceForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
toolStripComboBoxLevel.SelectedItem = "Verbose";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toolStripComboBoxLevel_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
MSNPSharp.Settings.TraceSwitch.Level = (TraceLevel)Enum.Parse(typeof(TraceLevel), toolStripComboBoxLevel.SelectedItem.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class TraceWriter : TextWriter
|
||||||
|
{
|
||||||
|
private RichTextBox richTextBox = null;
|
||||||
|
private delegate void WriteHandler(string buffer, RichTextBox rtb);
|
||||||
|
private const int MaxBufferLen = 1024;
|
||||||
|
private StringBuilder buffer = new StringBuilder(MaxBufferLen);
|
||||||
|
private DateTime lastInputTime = DateTime.Now;
|
||||||
|
private Thread writeThread = null;
|
||||||
|
private Queue<char> messageQueue = new Queue<char>(MaxBufferLen);
|
||||||
|
private bool canClose = false;
|
||||||
|
private bool userClick = false;
|
||||||
|
private int selectionStart = 0;
|
||||||
|
private int selectionLength = 0;
|
||||||
|
|
||||||
|
protected virtual void WriteBuffer()
|
||||||
|
{
|
||||||
|
StringBuilder trace = new StringBuilder(MaxBufferLen);
|
||||||
|
while (!canClose)
|
||||||
|
{
|
||||||
|
lock (messageQueue)
|
||||||
|
{
|
||||||
|
|
||||||
|
while (messageQueue.Count > 0)
|
||||||
|
{
|
||||||
|
trace.EnsureCapacity(buffer.Length < MaxBufferLen ? MaxBufferLen : MaxBufferLen + 2);
|
||||||
|
trace.Append(messageQueue.Dequeue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trace.Length > 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
richTextBox.BeginInvoke(new WriteHandler(OutPut), new object[] { trace.ToString(), richTextBox });
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace.Remove(0, trace.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.Sleep(Settings.IsMono ? 5000 : 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OutPut(string buffer, RichTextBox rtb)
|
||||||
|
{
|
||||||
|
if (selectionStart == rtb.Text.Length)
|
||||||
|
userClick = false;
|
||||||
|
|
||||||
|
rtb.AppendText(buffer);
|
||||||
|
if (userClick)
|
||||||
|
{
|
||||||
|
rtb.Select(selectionStart, selectionLength);
|
||||||
|
rtb.ScrollToCaret();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TraceWriter(RichTextBox outputRTB)
|
||||||
|
{
|
||||||
|
richTextBox = outputRTB;
|
||||||
|
richTextBox.Click += new EventHandler(richTextBox_Click);
|
||||||
|
richTextBox.KeyDown += new KeyEventHandler(richTextBox_KeyDown);
|
||||||
|
writeThread = new Thread(new ThreadStart(WriteBuffer));
|
||||||
|
writeThread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void richTextBox_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
userClick = true;
|
||||||
|
selectionStart = richTextBox.SelectionStart;
|
||||||
|
selectionLength = richTextBox.SelectionLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
void richTextBox_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
userClick = true;
|
||||||
|
selectionStart = richTextBox.SelectionStart;
|
||||||
|
selectionLength = richTextBox.SelectionLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(char value)
|
||||||
|
{
|
||||||
|
if (richTextBox != null && buffer != null)
|
||||||
|
{
|
||||||
|
lock (messageQueue)
|
||||||
|
{
|
||||||
|
messageQueue.Enqueue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Close()
|
||||||
|
{
|
||||||
|
canClose = true;
|
||||||
|
base.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Encoding Encoding
|
||||||
|
{
|
||||||
|
get { return Encoding.Default; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HostProtection(SecurityAction.LinkDemand, Synchronization = true)]
|
||||||
|
public class RichTextBoxTraceListener : TraceListener
|
||||||
|
{
|
||||||
|
// Fields
|
||||||
|
private TraceWriter writer = null;
|
||||||
|
private object syncObject = new object();
|
||||||
|
private bool stop = false;
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
public RichTextBoxTraceListener()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public RichTextBoxTraceListener(RichTextBox rtb)
|
||||||
|
: base(string.Empty)
|
||||||
|
{
|
||||||
|
writer = new TraceWriter(rtb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override void Close()
|
||||||
|
{
|
||||||
|
if (this.writer != null)
|
||||||
|
{
|
||||||
|
this.writer.Close();
|
||||||
|
}
|
||||||
|
this.writer = null;
|
||||||
|
this.stop = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool EnsureWriter()
|
||||||
|
{
|
||||||
|
lock (syncObject)
|
||||||
|
{
|
||||||
|
if (writer == null || stop == true) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Flush()
|
||||||
|
{
|
||||||
|
if (!EnsureWriter()) return;
|
||||||
|
this.writer.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Encoding GetEncodingWithFallback(Encoding encoding)
|
||||||
|
{
|
||||||
|
Encoding encoding2 = (Encoding)encoding.Clone();
|
||||||
|
encoding2.EncoderFallback = EncoderFallback.ReplacementFallback;
|
||||||
|
encoding2.DecoderFallback = DecoderFallback.ReplacementFallback;
|
||||||
|
return encoding2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write (string message)
|
||||||
|
{
|
||||||
|
if (!EnsureWriter ())
|
||||||
|
return;
|
||||||
|
if (base.NeedIndent)
|
||||||
|
{
|
||||||
|
this.WriteIndent ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Settings.IsMono)
|
||||||
|
{
|
||||||
|
this.writer.Write ("[" + DateTime.Now.ToString ("u") + "] " + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteLine(string message)
|
||||||
|
{
|
||||||
|
if (!EnsureWriter()) return;
|
||||||
|
if (base.NeedIndent)
|
||||||
|
{
|
||||||
|
this.WriteIndent();
|
||||||
|
}
|
||||||
|
this.writer.WriteLine("[" + DateTime.Now.ToString("u") + "] " + message);
|
||||||
|
base.NeedIndent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
lock (syncObject)
|
||||||
|
{
|
||||||
|
stop = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Resume()
|
||||||
|
{
|
||||||
|
lock (syncObject)
|
||||||
|
{
|
||||||
|
stop = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
public TraceWriter Writer
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.writer;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.writer = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
169
Example/TraceForm.resx
Normal file
|
|
@ -0,0 +1,169 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
|
<data name="tsbStart.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>
|
||||||
|
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||||
|
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgxJREFUOE+lkvtL
|
||||||
|
U2EYx+0PEbtpFwnBKPGKiJImGP0gYhIYs1E5GF5gIxkpA00JRSmMEF0ohMh+GaRWYlqabMVcNdS2QpaI
|
||||||
|
VqiDIYhk397vA6fXhCjyhYdzeM/5fp7vczkAdeL2cwho7v/wWzT1zcN+Pwhr51uY2/y41PQaF+wzKKiZ
|
||||||
|
QvaN58g0jyLd5KEUcQbg+84P/Cm2tncQjW3j68YWIqubCC3FcOJc478BAuGoZM6zvoRnakXEruEIjhc4
|
||||||
|
/g5gZop9c+voGAyLbQIfeBZxLL9BA1jzXvuGbWamuKh+GmmVbswE19A59FEBbmoAG7YbsLtm2mZmiml9
|
||||||
|
cvabNDwpz6YB7LYBoMXCumkJr7LOmnnHzBQ/9X2Bo2cOibm1GsBREbAQiYmw/8lnuCeWkVzcgnZlnw1j
|
||||||
|
3HV/wuNXK6i/9x5Hc6wawDlTXHbLJ+LZUBQPRyKwdQdxutwl1h+NLXHh5Ht1ewBHsiwawCW57HyDAfWR
|
||||||
|
dvl0uhZQ1eqX8aVc7EKLqrum651ATLf9OJx5XQM4KmY0xPzZ0hFAiQJnXB0WwME0E3IsL5B17ZlADqWb
|
||||||
|
NYDrOepdlcysmTWWOrxqbceRWtaLk0VO1XW72D5Vckd2gMBfq8zdpmUG62NJvKM4+XyziDk24xmfWoGE
|
||||||
|
s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<data name="tsbStop.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>
|
||||||
|
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||||
|
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgxJREFUOE+lkvtL
|
||||||
|
U2EYx+0PEbtpFwnBKPGKiJImGP0gYhIYs1E5GF5gIxkpA00JRSmMEF0ohMh+GaRWYlqabMVcNdS2QpaI
|
||||||
|
VqiDIYhk397vA6fXhCjyhYdzeM/5fp7vczkAdeL2cwho7v/wWzT1zcN+Pwhr51uY2/y41PQaF+wzKKiZ
|
||||||
|
QvaN58g0jyLd5KEUcQbg+84P/Cm2tncQjW3j68YWIqubCC3FcOJc478BAuGoZM6zvoRnakXEruEIjhc4
|
||||||
|
/g5gZop9c+voGAyLbQIfeBZxLL9BA1jzXvuGbWamuKh+GmmVbswE19A59FEBbmoAG7YbsLtm2mZmiml9
|
||||||
|
cvabNDwpz6YB7LYBoMXCumkJr7LOmnnHzBQ/9X2Bo2cOibm1GsBREbAQiYmw/8lnuCeWkVzcgnZlnw1j
|
||||||
|
3HV/wuNXK6i/9x5Hc6wawDlTXHbLJ+LZUBQPRyKwdQdxutwl1h+NLXHh5Ht1ewBHsiwawCW57HyDAfWR
|
||||||
|
dvl0uhZQ1eqX8aVc7EKLqrum651ATLf9OJx5XQM4KmY0xPzZ0hFAiQJnXB0WwME0E3IsL5B17ZlADqWb
|
||||||
|
NYDrOepdlcysmTWWOrxqbceRWtaLk0VO1XW72D5Vckd2gMBfq8zdpmUG62NJvKM4+XyziDk24xmfWoGE
|
||||||
|
s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<data name="tsbClear.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>
|
||||||
|
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||||
|
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgxJREFUOE+lkvtL
|
||||||
|
U2EYx+0PEbtpFwnBKPGKiJImGP0gYhIYs1E5GF5gIxkpA00JRSmMEF0ohMh+GaRWYlqabMVcNdS2QpaI
|
||||||
|
VqiDIYhk397vA6fXhCjyhYdzeM/5fp7vczkAdeL2cwho7v/wWzT1zcN+Pwhr51uY2/y41PQaF+wzKKiZ
|
||||||
|
QvaN58g0jyLd5KEUcQbg+84P/Cm2tncQjW3j68YWIqubCC3FcOJc478BAuGoZM6zvoRnakXEruEIjhc4
|
||||||
|
/g5gZop9c+voGAyLbQIfeBZxLL9BA1jzXvuGbWamuKh+GmmVbswE19A59FEBbmoAG7YbsLtm2mZmiml9
|
||||||
|
cvabNDwpz6YB7LYBoMXCumkJr7LOmnnHzBQ/9X2Bo2cOibm1GsBREbAQiYmw/8lnuCeWkVzcgnZlnw1j
|
||||||
|
3HV/wuNXK6i/9x5Hc6wawDlTXHbLJ+LZUBQPRyKwdQdxutwl1h+NLXHh5Ht1ewBHsiwawCW57HyDAfWR
|
||||||
|
dvl0uhZQ1eqX8aVc7EKLqrum651ATLf9OJx5XQM4KmY0xPzZ0hFAiQJnXB0WwME0E3IsL5B17ZlADqWb
|
||||||
|
NYDrOepdlcysmTWWOrxqbceRWtaLk0VO1XW72D5Vckd2gMBfq8zdpmUG62NJvKM4+XyziDk24xmfWoGE
|
||||||
|
s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
60
MSNPSharp.sln
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotMSNClient", "Example\DotMSNClient.csproj", "{BDF3E472-EFE8-44D6-AFB6-062DD929D56F}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxyServer", "ProxyServer\ProxyServer.csproj", "{EB773C85-DDF7-4031-A993-102B9C8ED02C}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSNPSharp", "MSNPSharp\MSNPSharp.csproj", "{97CB2DC7-2FE8-4AF5-84D0-6B9872A5E960}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(TestCaseManagementSettings) = postSolution
|
||||||
|
CategoryFile = MSNPSharp.vsmdi
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Release|Mixed Platforms = Release|Mixed Platforms
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{BDF3E472-EFE8-44D6-AFB6-062DD929D56F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{BDF3E472-EFE8-44D6-AFB6-062DD929D56F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{BDF3E472-EFE8-44D6-AFB6-062DD929D56F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{BDF3E472-EFE8-44D6-AFB6-062DD929D56F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{BDF3E472-EFE8-44D6-AFB6-062DD929D56F}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||||
|
{BDF3E472-EFE8-44D6-AFB6-062DD929D56F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{BDF3E472-EFE8-44D6-AFB6-062DD929D56F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BDF3E472-EFE8-44D6-AFB6-062DD929D56F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{BDF3E472-EFE8-44D6-AFB6-062DD929D56F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{BDF3E472-EFE8-44D6-AFB6-062DD929D56F}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||||
|
{EB773C85-DDF7-4031-A993-102B9C8ED02C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{EB773C85-DDF7-4031-A993-102B9C8ED02C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{EB773C85-DDF7-4031-A993-102B9C8ED02C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{EB773C85-DDF7-4031-A993-102B9C8ED02C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{EB773C85-DDF7-4031-A993-102B9C8ED02C}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||||
|
{EB773C85-DDF7-4031-A993-102B9C8ED02C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{EB773C85-DDF7-4031-A993-102B9C8ED02C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{EB773C85-DDF7-4031-A993-102B9C8ED02C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{EB773C85-DDF7-4031-A993-102B9C8ED02C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{EB773C85-DDF7-4031-A993-102B9C8ED02C}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||||
|
{97CB2DC7-2FE8-4AF5-84D0-6B9872A5E960}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{97CB2DC7-2FE8-4AF5-84D0-6B9872A5E960}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{97CB2DC7-2FE8-4AF5-84D0-6B9872A5E960}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{97CB2DC7-2FE8-4AF5-84D0-6B9872A5E960}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{97CB2DC7-2FE8-4AF5-84D0-6B9872A5E960}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||||
|
{97CB2DC7-2FE8-4AF5-84D0-6B9872A5E960}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{97CB2DC7-2FE8-4AF5-84D0-6B9872A5E960}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{97CB2DC7-2FE8-4AF5-84D0-6B9872A5E960}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{97CB2DC7-2FE8-4AF5-84D0-6B9872A5E960}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{97CB2DC7-2FE8-4AF5-84D0-6B9872A5E960}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(MonoDevelopProperties) = preSolution
|
||||||
|
StartupItem = Example\DotMSNClient.csproj
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
45
MSNPSharp/Circle.Obsolete.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using MSNPSharp.MSNWS.MSNABSharingService;
|
||||||
|
|
||||||
|
namespace MSNPSharp
|
||||||
|
{
|
||||||
|
public partial class Circle
|
||||||
|
{
|
||||||
|
private ContactType hiddenRepresentative = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Circle constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="me">The "Me Contact" in the addressbook.</param>
|
||||||
|
/// <param name="hidden"></param>
|
||||||
|
/// <param name="circleInfo"></param>
|
||||||
|
/// <param name="handler"></param>
|
||||||
|
[Obsolete("No hidden representative is needed anymore.", true)]
|
||||||
|
public Circle(ContactType me, ContactType hidden, CircleInverseInfoType circleInfo, NSMessageHandler handler)
|
||||||
|
: base(circleInfo.Content.Handle.Id.ToLowerInvariant(), circleInfo.Content.Handle.Id.ToLowerInvariant() + "@" + circleInfo.Content.Info.HostedDomain.ToLowerInvariant(), ClientType.CircleMember, me.contactInfo.CID, handler)
|
||||||
|
{
|
||||||
|
hostDomain = circleInfo.Content.Info.HostedDomain.ToLowerInvariant();
|
||||||
|
hiddenRepresentative = hidden;
|
||||||
|
|
||||||
|
CircleRole = (CirclePersonalMembershipRole)Enum.Parse(typeof(CirclePersonalMembershipRole), circleInfo.PersonalInfo.MembershipInfo.CirclePersonalMembership.Role);
|
||||||
|
|
||||||
|
SetName(circleInfo.Content.Info.DisplayName);
|
||||||
|
SetNickName(Name);
|
||||||
|
|
||||||
|
meContact = me;
|
||||||
|
|
||||||
|
if (hidden != null)
|
||||||
|
{
|
||||||
|
Guid = new Guid(hidden.contactId);
|
||||||
|
|
||||||
|
if (hidden.contactInfo != null && hidden.contactInfo.CIDSpecified)
|
||||||
|
CID = hidden.contactInfo.CID;
|
||||||
|
}
|
||||||
|
|
||||||
|
contactList = new ContactList(AddressBookId, new Owner(AddressBookId, me.contactInfo.passportName, me.contactInfo.CID, NSMessageHandler), NSMessageHandler);
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
438
MSNPSharp/Circle.cs
Normal file
|
|
@ -0,0 +1,438 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using MSNPSharp.MSNWS.MSNABSharingService;
|
||||||
|
|
||||||
|
namespace MSNPSharp
|
||||||
|
{
|
||||||
|
using MSNPSharp.Core;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A new type of group introduces with WLM2009.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable()]
|
||||||
|
public partial class Circle : Contact
|
||||||
|
{
|
||||||
|
private ContactList contactList = null;
|
||||||
|
private string hostDomain = CircleString.DefaultHostDomain;
|
||||||
|
private long segmentCounter = 0;
|
||||||
|
|
||||||
|
private ContactType meContact = null;
|
||||||
|
|
||||||
|
private ABFindContactsPagedResultTypeAB abinfo = null;
|
||||||
|
|
||||||
|
|
||||||
|
public string HostDomain
|
||||||
|
{
|
||||||
|
get { return hostDomain; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactList ContactList
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return contactList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The last change time of circle's addressbook.
|
||||||
|
/// </summary>
|
||||||
|
public string LastChanged
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (abinfo == null)
|
||||||
|
return WebServiceConstants.ZeroTime;
|
||||||
|
|
||||||
|
return abinfo.lastChange;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Circle constructor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="me">The "Me Contact" in the addressbook.</param>
|
||||||
|
/// <param name="circleInfo"></param>
|
||||||
|
/// <param name="handler"></param>
|
||||||
|
public Circle(ContactType me, CircleInverseInfoType circleInfo, NSMessageHandler handler)
|
||||||
|
: base(circleInfo.Content.Handle.Id.ToLowerInvariant(), circleInfo.Content.Handle.Id.ToLowerInvariant() + "@" + circleInfo.Content.Info.HostedDomain.ToLowerInvariant(), ClientType.CircleMember, me.contactInfo.CID, handler)
|
||||||
|
{
|
||||||
|
hostDomain = circleInfo.Content.Info.HostedDomain.ToLowerInvariant();
|
||||||
|
|
||||||
|
CircleRole = (CirclePersonalMembershipRole)Enum.Parse(typeof(CirclePersonalMembershipRole), circleInfo.PersonalInfo.MembershipInfo.CirclePersonalMembership.Role);
|
||||||
|
|
||||||
|
SetName(circleInfo.Content.Info.DisplayName);
|
||||||
|
SetNickName(Name);
|
||||||
|
|
||||||
|
meContact = me;
|
||||||
|
|
||||||
|
CID = 0;
|
||||||
|
|
||||||
|
contactList = new ContactList(AddressBookId, new Owner(AddressBookId, me.contactInfo.passportName, me.contactInfo.CID, NSMessageHandler), NSMessageHandler);
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckValidation()
|
||||||
|
{
|
||||||
|
if (NSMessageHandler == null)
|
||||||
|
throw new MSNPSharpException("NSMessagehandler is null");
|
||||||
|
if (!NSMessageHandler.IsSignedIn)
|
||||||
|
throw new InvalidOperationException("Cannot send a message without signning in to the server. Please sign in first.");
|
||||||
|
|
||||||
|
if (NSMessageHandler.ContactList.Owner.Status == PresenceStatus.Hidden)
|
||||||
|
throw new InvalidOperationException("Cannot send a message when you are in 'Hidden' status.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ConstructSDGScheme()
|
||||||
|
{
|
||||||
|
string from = ((int)NSMessageHandler.ContactList.Owner.ClientType).ToString() + ":" +
|
||||||
|
NSMessageHandler.ContactList.Owner.Mail +
|
||||||
|
";epid=" + NSMessageHandler.ContactList.Owner.MachineGuid.ToString("B").ToLowerInvariant();
|
||||||
|
|
||||||
|
|
||||||
|
string to = ((int)ClientType).ToString() + ":" + Mail + ";path=IM";
|
||||||
|
|
||||||
|
string routingInfo = CircleString.RoutingScheme.Replace(CircleString.ToReplacementTag, to);
|
||||||
|
routingInfo = routingInfo.Replace(CircleString.FromReplacementTag, from);
|
||||||
|
|
||||||
|
string reliabilityInfo = CircleString.ReliabilityScheme.Replace(CircleString.StreamReplacementTag, "0");
|
||||||
|
reliabilityInfo = reliabilityInfo.Replace(CircleString.SegmentReplacementTag, IncreaseSegmentCounter().ToString());
|
||||||
|
|
||||||
|
string putCommandString = CircleString.CircleMessageScheme;
|
||||||
|
putCommandString = putCommandString.Replace(CircleString.RoutingSchemeReplacementTag, routingInfo);
|
||||||
|
putCommandString = putCommandString.Replace(CircleString.ReliabilitySchemeReplacementTag, reliabilityInfo);
|
||||||
|
|
||||||
|
return putCommandString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send nudge to all members in this circle.
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="MSNPSharpException">NSMessageHandler is null</exception>
|
||||||
|
/// <exception cref="InvalidOperationException">Not sign in to the server, or in <see cref="PresenceStatus.Hidden"/> status.</exception>
|
||||||
|
public void SendNudge()
|
||||||
|
{
|
||||||
|
CheckValidation();
|
||||||
|
string scheme = ConstructSDGScheme();
|
||||||
|
|
||||||
|
scheme = scheme.Replace(CircleString.MessageSchemeReplacementTag, CircleString.NudgeMessageScheme);
|
||||||
|
|
||||||
|
NSPayLoadMessage nspayload = new NSPayLoadMessage("SDG", scheme);
|
||||||
|
NSMessageHandler.MessageProcessor.SendMessage(nspayload);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send a text message to all members in this circle.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="textMessage"></param>
|
||||||
|
/// <exception cref="MSNPSharpException">NSMessageHandler is null</exception>
|
||||||
|
/// <exception cref="InvalidOperationException">Not sign in to the server, or in <see cref="PresenceStatus.Hidden"/> status.</exception>
|
||||||
|
public void SendMessage(TextMessage textMessage)
|
||||||
|
{
|
||||||
|
CheckValidation();
|
||||||
|
|
||||||
|
string scheme = ConstructSDGScheme();
|
||||||
|
|
||||||
|
textMessage.PrepareMessage();
|
||||||
|
|
||||||
|
string content = MimeHeaderStrings.X_MMS_IM_Format + ": " + textMessage.GetStyleString() + "\r\n\r\n" + textMessage.Text;
|
||||||
|
string textMessageScheme = CircleString.TextMessageScheme.Replace(CircleString.TextMessageContentReplacementTag, content);
|
||||||
|
textMessageScheme = textMessageScheme.Replace(CircleString.ContentLengthReplacementTag, textMessage.Text.Length.ToString());
|
||||||
|
|
||||||
|
scheme = scheme.Replace(CircleString.MessageSchemeReplacementTag, textMessageScheme);
|
||||||
|
|
||||||
|
NSPayLoadMessage nspayload = new NSPayLoadMessage("SDG", scheme);
|
||||||
|
NSMessageHandler.MessageProcessor.SendMessage(nspayload);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send a typing message indicates that you are typing to all members in this circle.
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="MSNPSharpException">NSMessageHandler is null</exception>
|
||||||
|
/// <exception cref="InvalidOperationException">Not sign in to the server, or in <see cref="PresenceStatus.Hidden"/> status.</exception>
|
||||||
|
public void SendTypingMessage()
|
||||||
|
{
|
||||||
|
CheckValidation();
|
||||||
|
string scheme = ConstructSDGScheme();
|
||||||
|
|
||||||
|
string typingScheme = CircleString.TypingMessageScheme.Replace(CircleString.OwnerReplacementTag, NSMessageHandler.ContactList.Owner.Mail);
|
||||||
|
scheme = scheme.Replace(CircleString.MessageSchemeReplacementTag, typingScheme);
|
||||||
|
|
||||||
|
NSPayLoadMessage nspayload = new NSPayLoadMessage("SDG", scheme);
|
||||||
|
NSMessageHandler.MessageProcessor.SendMessage(nspayload);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal long IncreaseSegmentCounter()
|
||||||
|
{
|
||||||
|
return segmentCounter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a specific contact from circle's contact list by the information provided.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account">The contact information</param>
|
||||||
|
/// <param name="option">The parse option for the account parameter</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
internal Contact GetMember(string account, AccountParseOption option)
|
||||||
|
{
|
||||||
|
string lowerAccount = account.ToLowerInvariant();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (option)
|
||||||
|
{
|
||||||
|
case AccountParseOption.ParseAsClientTypeAndAccount:
|
||||||
|
{
|
||||||
|
string[] typeAccount = lowerAccount.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (typeAccount.Length >= 2)
|
||||||
|
{
|
||||||
|
ClientType type = (ClientType)(int.Parse(typeAccount[0]));
|
||||||
|
string mail = typeAccount[1];
|
||||||
|
if (HasMember(mail, type))
|
||||||
|
{
|
||||||
|
return ContactList.GetContact(mail, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case AccountParseOption.ParseAsFullCircleAccount:
|
||||||
|
{
|
||||||
|
string[] sp = lowerAccount.Split(new string[] { CircleString.ViaCircleGroupSplitter }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (sp.Length < 2)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] idDomain = sp[1].Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (idDomain.Length < 2)
|
||||||
|
return null;
|
||||||
|
string[] typeAccount = sp[0].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (typeAccount.Length < 2)
|
||||||
|
return null;
|
||||||
|
Guid abid = new Guid(idDomain[0]);
|
||||||
|
if (abid != AddressBookId || idDomain[1].ToLowerInvariant() != HostDomain) //Is it the correct circle selected?
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ClientType type = (ClientType)(int.Parse(typeAccount[0]));
|
||||||
|
string mail = typeAccount[1];
|
||||||
|
if (HasMember(mail, type))
|
||||||
|
{
|
||||||
|
return ContactList.GetContact(mail, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "Get contact from circle error: account: " + account +
|
||||||
|
" in " + ToString() + "\r\nError Message: " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove a specific contact from circle's contact list by the information provided.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account">The contact information</param>
|
||||||
|
/// <param name="option">The parse option for the account parameter</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
internal bool RemoveMember(string account, AccountParseOption option)
|
||||||
|
{
|
||||||
|
string lowerAccount = account.ToLowerInvariant();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (option)
|
||||||
|
{
|
||||||
|
case AccountParseOption.ParseAsClientTypeAndAccount:
|
||||||
|
{
|
||||||
|
string[] typeAccount = lowerAccount.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (typeAccount.Length >= 2)
|
||||||
|
{
|
||||||
|
ClientType type = (ClientType)(int.Parse(typeAccount[0]));
|
||||||
|
string mail = typeAccount[1];
|
||||||
|
if (HasMember(mail, type))
|
||||||
|
{
|
||||||
|
ContactList.Remove(account, type);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case AccountParseOption.ParseAsFullCircleAccount:
|
||||||
|
{
|
||||||
|
string[] sp = lowerAccount.Split(new string[] { CircleString.ViaCircleGroupSplitter }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (sp.Length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] idDomain = sp[1].Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (idDomain.Length < 2)
|
||||||
|
return false;
|
||||||
|
string[] typeAccount = sp[0].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (typeAccount.Length < 2)
|
||||||
|
return false;
|
||||||
|
Guid abid = new Guid(idDomain[0]);
|
||||||
|
if (abid != AddressBookId || idDomain[1].ToLowerInvariant() != HostDomain) //Is it the correct circle selected?
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ClientType type = (ClientType)(int.Parse(typeAccount[0]));
|
||||||
|
string mail = typeAccount[1];
|
||||||
|
if (HasMember(mail, type))
|
||||||
|
{
|
||||||
|
ContactList.Remove(account, type);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "Remove contact from circle error: account: " + account +
|
||||||
|
" in " + ToString() + "\r\nError Message: " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check whether a specific contact exists in circle's contact list by the information provided.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account">The contact information</param>
|
||||||
|
/// <param name="option">The parse option for the account parameter</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
internal bool HasMember(string account, AccountParseOption option)
|
||||||
|
{
|
||||||
|
string lowerAccount = account.ToLowerInvariant();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (option)
|
||||||
|
{
|
||||||
|
case AccountParseOption.ParseAsClientTypeAndAccount:
|
||||||
|
{
|
||||||
|
string[] typeAccount = lowerAccount.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (typeAccount.Length >= 2)
|
||||||
|
{
|
||||||
|
ClientType type = (ClientType)(int.Parse(typeAccount[0]));
|
||||||
|
string mail = typeAccount[1];
|
||||||
|
return HasMember(mail, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case AccountParseOption.ParseAsFullCircleAccount:
|
||||||
|
{
|
||||||
|
string[] sp = lowerAccount.Split(new string[] { CircleString.ViaCircleGroupSplitter }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (sp.Length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] idDomain = sp[1].Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (idDomain.Length < 2)
|
||||||
|
return false;
|
||||||
|
string[] typeAccount = sp[0].Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (typeAccount.Length < 2)
|
||||||
|
return false;
|
||||||
|
Guid abid = new Guid(idDomain[0]);
|
||||||
|
if (abid != AddressBookId || idDomain[1].ToLowerInvariant() != HostDomain) //Is it the correct circle selected?
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ClientType type = (ClientType)(int.Parse(typeAccount[0]));
|
||||||
|
string mail = typeAccount[1];
|
||||||
|
return HasMember(mail, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "Verifying membership error: account: " + account +
|
||||||
|
" in " + ToString() + "\r\nError Message: " + ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal bool HasMember(string account, ClientType type)
|
||||||
|
{
|
||||||
|
lock (ContactList)
|
||||||
|
return ContactList.HasContact(account, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool HasMember(Guid contactId)
|
||||||
|
{
|
||||||
|
lock (ContactList)
|
||||||
|
return (ContactList.GetContactByGuid(contactId) != null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool HasMember(long CID)
|
||||||
|
{
|
||||||
|
lock (ContactList)
|
||||||
|
return (ContactList.GetContactByCID(CID) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void SetAddressBookInfo(ABFindContactsPagedResultTypeAB abInfo)
|
||||||
|
{
|
||||||
|
abinfo = abInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Protected
|
||||||
|
protected virtual void Initialize()
|
||||||
|
{
|
||||||
|
ContactType = MessengerContactType.Circle;
|
||||||
|
Lists = MSNLists.AllowedList | MSNLists.ForwardList;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
76
MSNPSharp/CircleInviter.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
#region
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice, Andy Phan.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using MSNPSharp.MSNWS.MSNABSharingService;
|
||||||
|
|
||||||
|
namespace MSNPSharp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="Contact"/> who send a join contact invitation.
|
||||||
|
/// </summary>
|
||||||
|
[Obsolete("Inviter is no more supported by Microsoft.")]
|
||||||
|
[Serializable()]
|
||||||
|
public class CircleInviter : Contact
|
||||||
|
{
|
||||||
|
private string message = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invitation message send via the email.
|
||||||
|
/// </summary>
|
||||||
|
public string Message
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal CircleInviter(ContactType inviter, string inviterMessage)
|
||||||
|
: base(WebServiceConstants.MessengerIndividualAddressBookId, inviter.contactInfo.passportName, ClientType.PassportMember, inviter.contactInfo.CID, null)
|
||||||
|
{
|
||||||
|
if (inviterMessage != null)
|
||||||
|
message = inviterMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal CircleInviter(string inviterEmail, string inviterName, string inviterMessage)
|
||||||
|
: base(WebServiceConstants.MessengerIndividualAddressBookId, inviterEmail, ClientType.PassportMember, 0, null)
|
||||||
|
{
|
||||||
|
if (inviterMessage != null)
|
||||||
|
message = inviterMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
168
MSNPSharp/CircleList.cs
Normal file
|
|
@ -0,0 +1,168 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace MSNPSharp
|
||||||
|
{
|
||||||
|
[Serializable()]
|
||||||
|
public class CircleList : IEnumerable
|
||||||
|
{
|
||||||
|
private Dictionary<string, Circle> list = new Dictionary<string, Circle>();
|
||||||
|
|
||||||
|
[NonSerialized]
|
||||||
|
private NSMessageHandler nsMessageHandler = null;
|
||||||
|
|
||||||
|
[NonSerialized]
|
||||||
|
private object syncRoot;
|
||||||
|
|
||||||
|
public object SyncRoot
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (syncRoot == null)
|
||||||
|
{
|
||||||
|
object newobj = new object();
|
||||||
|
Interlocked.CompareExchange(ref syncRoot, newobj, null);
|
||||||
|
}
|
||||||
|
return syncRoot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool AddCircle(Circle circle)
|
||||||
|
{
|
||||||
|
if (this[circle.Mail] == null)
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
list.Add(circle.Mail, circle);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
circle.Lists = list[circle.Mail].Lists;
|
||||||
|
list[circle.Mail] = circle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove a circle from circle list.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="circle"></param>
|
||||||
|
internal void RemoveCircle(Circle circle)
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
list.Remove(circle.Mail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove a circle from circle list, by providing addressbook Id and Host Domain.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="abId">The addressbook Id for circle's addressbook page.</param>
|
||||||
|
/// <param name="hostDomain">The host domain of a circle.</param>
|
||||||
|
internal void RemoveCircle(Guid abId, string hostDomain)
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
string identifier = abId.ToString().ToLowerInvariant() + "@" + hostDomain.ToLowerInvariant();
|
||||||
|
list.Remove(identifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal CircleList(NSMessageHandler handler)
|
||||||
|
{
|
||||||
|
nsMessageHandler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find <see cref="Circle"/> by circle Id and host domain if circle not found, return null.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="abId">Circle id</param>
|
||||||
|
/// <param name="hostDomain">Circle host domain.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Circle this[Guid abId, string hostDomain]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string identifier = abId.ToString().ToLowerInvariant() + "@" + hostDomain.ToLowerInvariant();
|
||||||
|
if (list.ContainsKey(identifier))
|
||||||
|
return list[identifier];
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find <see cref="Circle"/> by circle Id and host domain, if circle not found, return null.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idAndHostDomain">Via Id: guid@hostdomain</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Circle this[string idAndHostDomain]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string identifier = idAndHostDomain.ToLowerInvariant();
|
||||||
|
if (list.ContainsKey(identifier))
|
||||||
|
return list[identifier];
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator GetEnumerator()
|
||||||
|
{
|
||||||
|
return list.Values.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
list.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Count
|
||||||
|
{
|
||||||
|
get { return list.Count; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
923
MSNPSharp/ClassDiagram1.cd
Normal file
|
|
@ -0,0 +1,923 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ClassDiagram MajorVersion="1" MinorVersion="1">
|
||||||
|
<Font Name="Tahoma" Size="8.25" />
|
||||||
|
<Class Name="MSNPSharp.Settings" Collapsed="true">
|
||||||
|
<Position X="32" Y="5.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Configuration.cs</FileName>
|
||||||
|
<HashCode>AABAAAAAAAAAAAAAAAAAAAAAAAAgAAoAAABAIAAACAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.ConnectivityException" Collapsed="true">
|
||||||
|
<Position X="5.5" Y="12" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ConnectivityException.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.ConnectivitySettings" Collapsed="true">
|
||||||
|
<Position X="25" Y="0.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ConnectivitySettings.cs</FileName>
|
||||||
|
<HashCode>AAQAAACEAAAAoAAEACAAAgAACAIACAwCAAgEAgAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.ContactStatusChangedEventArgs" Collapsed="true">
|
||||||
|
<Position X="23.25" Y="1.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Contact.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAACAAAAAgIAAAACAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.ContactEventArgs" Collapsed="true">
|
||||||
|
<Position X="26.75" Y="0.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Contact.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAACAAAAAgAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.StatusChangedEventArgs" Collapsed="true">
|
||||||
|
<Position X="23.25" Y="6.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Contact.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Contact" Collapsed="true">
|
||||||
|
<Position X="10.5" Y="11.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Contact.cs</FileName>
|
||||||
|
<HashCode>UFVJQQQEoQJFgSQgwLFkVFSFQUxOFekEUgDAQRFAAmU=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.ContactGroupEventArgs" Collapsed="true">
|
||||||
|
<Position X="30.25" Y="0.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ContactGroup.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAQ=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.ContactGroup" Collapsed="true">
|
||||||
|
<Position X="28.5" Y="0.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ContactGroup.cs</FileName>
|
||||||
|
<HashCode>EAAAAAAAAAAAAAAAgAAAABQEAAAEBIAAEAAAQBAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.ContactGroupList" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="32" Y="0.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ContactGroupList.cs</FileName>
|
||||||
|
<HashCode>AAIAAgAAAAAAABAACAAABAAAAAAgAAAAEAAAAABAAAg=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.ContactList" Collapsed="true">
|
||||||
|
<Position X="33.75" Y="0.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ContactList.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAgACAACAAQKAAAFAAAAAABAAAAgoACIAAIIAI=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Conversation" Collapsed="true">
|
||||||
|
<Position X="25" Y="1.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Conversation.cs</FileName>
|
||||||
|
<HashCode>BEIQRCKCFZVEgCWg0EACpBMQBg0FwBSxg4QGIAUUYQA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Credentials" Collapsed="true">
|
||||||
|
<Position X="28.5" Y="1.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Credentials.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAgAAIAAAAAAAAAAAAgAAAAAAACAAAAQgAAAEA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DisplayImage" Collapsed="true">
|
||||||
|
<Position X="10.5" Y="8.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DisplayImage.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAEAAACBAAEAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Emoticon" Collapsed="true">
|
||||||
|
<Position X="10.5" Y="10.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Emoticon.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.EmoticonMessage" Collapsed="true">
|
||||||
|
<Position X="14.25" Y="1.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>EmoticonMessage.cs</FileName>
|
||||||
|
<HashCode>AACAAAAAACAACCAkAAAABAAAAAQAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.ExceptionEventArgs" Collapsed="true">
|
||||||
|
<Position X="32" Y="1.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>EventArgs.cs</FileName>
|
||||||
|
<HashCode>AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.TextMessageEventArgs" Collapsed="true">
|
||||||
|
<Position X="28.5" Y="6.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>EventArgs.cs</FileName>
|
||||||
|
<HashCode>AAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAIACA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.WinkEventArgs" Collapsed="true">
|
||||||
|
<Position X="30.25" Y="6.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>EventArgs.cs</FileName>
|
||||||
|
<HashCode>AAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAIIAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.EmoticonDefinitionEventArgs" Collapsed="true">
|
||||||
|
<Position X="30.25" Y="1.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>EventArgs.cs</FileName>
|
||||||
|
<HashCode>AAgAAAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAIAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.MailboxStatusEventArgs" Collapsed="true">
|
||||||
|
<Position X="28.5" Y="2.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>MailEventArgs.cs</FileName>
|
||||||
|
<HashCode>SAAAAUgAEAEgAAAAIAAAAAAAEAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.MailChangedEventArgs" Collapsed="true">
|
||||||
|
<Position X="30.25" Y="2.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>MailEventArgs.cs</FileName>
|
||||||
|
<HashCode>AAgAAAAAAAAAQAAABAAAAAQABAAAAAAAAAAEAAAIAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.NewMailEventArgs" Collapsed="true">
|
||||||
|
<Position X="30.25" Y="3.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>MailEventArgs.cs</FileName>
|
||||||
|
<HashCode>AgACAQIAAAEARAAAAIQAAACEAAAABAAAAAAEAAAAAgA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.ConversationCreatedEventArgs" Collapsed="true">
|
||||||
|
<Position X="26.75" Y="1.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Messenger.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAQQAIAAAAAAAAgAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Messenger" Collapsed="true">
|
||||||
|
<Position X="32" Y="2.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Messenger.cs</FileName>
|
||||||
|
<HashCode>ECRAAACAAAABQAAIAAAAgIAAAEAEKEgAHECQAlACAgA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.MobileMessage" Collapsed="true">
|
||||||
|
<Position X="3.5" Y="3.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>MobileMessage.cs</FileName>
|
||||||
|
<HashCode>AACAAAAgAAAAKCAEACAAAAAgAAAEAAAIBAAACAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.MSNObject" Collapsed="true">
|
||||||
|
<Position X="11.75" Y="7.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>MSNObject.cs</FileName>
|
||||||
|
<HashCode>AAEIAEAABgVAgoQEgIIAQAIKBAARAIAAEISAAgAABiI=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.MSNObjectCatalog" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="23.25" Y="3.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>MSNObject.cs</FileName>
|
||||||
|
<HashCode>AAIAAAAAAACAABBAAAAAFAQABABAAAAAAAAAAAAAICA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.MSNPSharpException" Collapsed="true">
|
||||||
|
<Position X="6.75" Y="10.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>MSNPSharpException.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.ListReceivedEventArgs" Collapsed="true">
|
||||||
|
<Position X="26.75" Y="2.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>EventArgs.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.SignedOffEventArgs" Collapsed="true">
|
||||||
|
<Position X="33.75" Y="5.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>EventArgs.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAgAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.PingAnswerEventArgs" Collapsed="true">
|
||||||
|
<Position X="33.75" Y="4.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>EventArgs.cs</FileName>
|
||||||
|
<HashCode>AAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.ListMutateEventArgs" Collapsed="true">
|
||||||
|
<Position X="25" Y="2.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>EventArgs.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAACQAAAAkAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.MSNErrorEventArgs" Collapsed="true">
|
||||||
|
<Position X="33.75" Y="2.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>EventArgs.cs</FileName>
|
||||||
|
<HashCode>AAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.NSMessageHandler" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="32" Y="3.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>NSMessageHandler.cs</FileName>
|
||||||
|
<HashCode>PAjnFUTGC1CprQGioUBgIigmEHAEXPRCnELxJspflPU=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.NSMessageProcessor" Collapsed="true">
|
||||||
|
<Position X="4.25" Y="5.75" Width="2" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>NSMessageProcessor.cs</FileName>
|
||||||
|
<HashCode>AAQAAAAgCAAAAAAAACAAAIAoAAAAAAAAAAAAAAAAAgA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Owner" Collapsed="true">
|
||||||
|
<Position X="10.5" Y="12.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Owner.cs</FileName>
|
||||||
|
<HashCode>gAFAAHDFIABITGWAIMwNoSwBKKdIdWkGBOABIYhAQSE=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.PersonalMessage" Collapsed="true">
|
||||||
|
<Position X="32" Y="4.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>PersonalMessage.cs</FileName>
|
||||||
|
<HashCode>ACACAAAAAAAAUAgEAEAYCAAAQAqAAAIAAQAAIAAwAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.QRYFactory" Collapsed="true">
|
||||||
|
<Position X="23.25" Y="0.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>QRYFactory.cs</FileName>
|
||||||
|
<HashCode>AAAAARAAAAAAAAAAAACAAEAIAAAAAAAAAAAAAAAAgAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.SBEventArgs" Collapsed="true">
|
||||||
|
<Position X="28.5" Y="5.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>SBMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.SBCreatedEventArgs" Collapsed="true">
|
||||||
|
<Position X="26.75" Y="5.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>SBMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAQAAAAEAAAAAAAAAAAAAQAAAAEAAABACAAQQAgAEA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.SBMessageHandler" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="1.5" Y="14.75" Width="2" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>SBMessageHandler.cs</FileName>
|
||||||
|
<HashCode>FEABzQZCGIBQCABusUggIDGaFoAAeBSQHAAAIBGE4BA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.SBMessageProcessor" Collapsed="true">
|
||||||
|
<Position X="7" Y="5.75" Width="2" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>SBMessageProcessor.cs</FileName>
|
||||||
|
<HashCode>AAQAAAAgCAAAAAAAACACAIAoAAAAAAAAAAAAAAAAAgA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.StrKeyValuePair" Collapsed="true">
|
||||||
|
<Position X="26.75" Y="6.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>StrDictionary.cs</FileName>
|
||||||
|
<HashCode>AAAAAIAAAAAAAAQAAAAEAAAAAAAAAAAAAAAgAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.StrDictionary" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="25" Y="6.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>StrDictionary.cs</FileName>
|
||||||
|
<HashCode>AAICAAAAAAAEABAACAAAAAAAAAAAAAAAAAAAAABAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.TextMessage" Collapsed="true">
|
||||||
|
<Position X="16.5" Y="1.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>TextMessage.cs</FileName>
|
||||||
|
<HashCode>IAKAAAAAQAAACCAEAAQAAAAMABABCACYAAQAiAAGABA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.UnauthorizedException" Collapsed="true">
|
||||||
|
<Position X="7.75" Y="12" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>UnauthorizedException.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<InheritanceLine Type="MSNPSharp.MSNPSharpException" ManuallyRouted="true">
|
||||||
|
<Path>
|
||||||
|
<Point X="7.5" Y="11.13" />
|
||||||
|
<Point X="7.5" Y="11.71" />
|
||||||
|
<Point X="8.5" Y="11.71" />
|
||||||
|
<Point X="8.5" Y="12" />
|
||||||
|
</Path>
|
||||||
|
</InheritanceLine>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Wink" Collapsed="true">
|
||||||
|
<Position X="12.75" Y="8.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Wink.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Core.Factory" Collapsed="true">
|
||||||
|
<Position X="33.75" Y="1.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\Factory.cs</FileName>
|
||||||
|
<HashCode>ECAAIAAAABAFABAICAEACAhAgQAFYCAgYBAABAQAAAQ=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Core.MessagePool" Collapsed="true">
|
||||||
|
<Position X="1.75" Y="10.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\MessagePool.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAECAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Core.MSNMessage" Collapsed="true">
|
||||||
|
<Position X="8" Y="1.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\MSNMessage.cs</FileName>
|
||||||
|
<HashCode>AACAAYAgAAGgCCAMAAAABAAgAAQAAAAAAQgAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Core.NetworkMessage" Collapsed="true">
|
||||||
|
<Position X="10.25" Y="0.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\NetworkMessage.cs</FileName>
|
||||||
|
<HashCode>AACAAAAAQgAACiAAAIIEAAAABgAAAABAgQAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Core.NotificationMessage" Collapsed="true">
|
||||||
|
<Position X="5.75" Y="3.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\NotificationMessage.cs</FileName>
|
||||||
|
<HashCode>AACQkAAwAACALAgEIIAAABAAAgAEAQgIAAAABAEAAgE=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Core.NSMessage" Collapsed="true">
|
||||||
|
<Position X="8" Y="3.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\NSMessage.cs</FileName>
|
||||||
|
<HashCode>AACAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Core.NSMessagePool" Collapsed="true">
|
||||||
|
<Position X="0.5" Y="11.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\NSMessagePool.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAACECEAQAIFCAAAAAAAAAEgAAABIAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Core.SBMessage" Collapsed="true">
|
||||||
|
<Position X="10.25" Y="3.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\SBMessage.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Core.SBMessagePool" Collapsed="true">
|
||||||
|
<Position X="0.5" Y="13.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\SBMessagePool.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Core.MSGMessage" Collapsed="true">
|
||||||
|
<Position X="20.75" Y="1.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\SBMSGMessage.cs</FileName>
|
||||||
|
<HashCode>AACAQAAIAEAACAAEAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Core.SocketMessageProcessor" Collapsed="true">
|
||||||
|
<Position X="7" Y="4.5" Width="2" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\SocketMessageProcessor.cs</FileName>
|
||||||
|
<HashCode>CARgAAIBAAAAQQAAACBBQJAQQUAAIEICAAEAAgAYAkA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.MSNSLPTransferProperties" Collapsed="true">
|
||||||
|
<Position X="28.5" Y="3.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\MSNSLPHandler.cs</FileName>
|
||||||
|
<HashCode>EAgKIhAAAgIAEABAABgAIkCIACJAgAAAAAAAAAAICEA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.P2PTransferSessionEventArgs" Collapsed="true">
|
||||||
|
<Position X="30.25" Y="4.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\MSNSLPHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.MSNSLPInvitationEventArgs" Collapsed="true">
|
||||||
|
<Position X="26.75" Y="3.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\MSNSLPHandler.cs</FileName>
|
||||||
|
<HashCode>AIAAAQDUAUEAQAFAAAgAAAAAAAAAAVAAAAEAAAAIAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.MSNSLPHandler" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="25" Y="3.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\MSNSLPHandler.cs</FileName>
|
||||||
|
<HashCode>CQAAgQBGECAgAAgAQBJgAIQVEAEAOCAAAFAAQ4AAgCA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.MSNSLPMessage" Collapsed="true">
|
||||||
|
<Position X="18.75" Y="1.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\MSNSLPMessage.cs</FileName>
|
||||||
|
<HashCode>IgiAACIAAAAAiAAEAIAhBAoAkQAYCJgAEAgQACAIAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.P2PDCPool" Collapsed="true">
|
||||||
|
<Position X="2.75" Y="11.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\P2PDCPool.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAECAAAAAEAAAAAAAAAAAAABAAAQAAAAABA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.P2PDirectProcessor" Collapsed="true">
|
||||||
|
<Position X="9.75" Y="5.75" Width="2" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\P2PDirectProcessor.cs</FileName>
|
||||||
|
<HashCode>AAQAAAAAAAEAAEAAACCAAAAAgAAAAAAAAQAAAAAAAgA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.P2PSessionAffectedEventArgs" Collapsed="true">
|
||||||
|
<Position X="26.75" Y="4.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\P2PHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.P2PHandler" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="33.75" Y="3.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\P2PHandler.cs</FileName>
|
||||||
|
<HashCode>GAgoAABAQAQgAxkACAAgAAA0ECEAKQAAEAAAIAAIEIA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.P2PMessage" Collapsed="true">
|
||||||
|
<Position X="1.25" Y="1.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\P2PMessage.cs</FileName>
|
||||||
|
<HashCode>BBCgBAQAAIIgCKAGIAiAAAAIBAAAAARAACAAQAAghAQ=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.P2PDataMessage" Collapsed="true">
|
||||||
|
<Position X="1.25" Y="3.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\P2PMessage.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAABAAAAAAEAAAAAAAAQAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.P2PDCMessage" Collapsed="true">
|
||||||
|
<Position X="1.25" Y="4.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\P2PMessage.cs</FileName>
|
||||||
|
<HashCode>AACAAAAAAAAACAAEAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.P2PDCHandshakeMessage" Collapsed="true">
|
||||||
|
<Position X="1.25" Y="6" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\P2PMessage.cs</FileName>
|
||||||
|
<HashCode>AACgAAAAAAAAAAAEAAAAAAAEAAAABAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.P2PMessagePool" Collapsed="true">
|
||||||
|
<Position X="23.25" Y="4.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\P2PMessagePool.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAEgAAAAAAAAAAQAAAAACQAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.P2PMessageSession" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="25" Y="4.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\P2PMessageSession.cs</FileName>
|
||||||
|
<HashCode>S9AkKABIECQADwAECDGgIgkiUDASagBAGEACIUIAhAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.DataTransfer.P2PTransferSession" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="28.5" Y="4.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\P2PTransferSession.cs</FileName>
|
||||||
|
<HashCode>CBgYCYBIAKEEEQDEBDjgUDAoICAAKEBIAAEQAhAYGAM=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="Org.Mentalis.Network.ProxySocket.Authentication.AuthMethod" Collapsed="true">
|
||||||
|
<Position X="6.75" Y="7.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ProxySocket\AuthMethod.cs</FileName>
|
||||||
|
<HashCode>AAAAAAQBAAAAAEAAAAAAAAIAAAAACAAgAAAAAgAAQAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="Org.Mentalis.Network.ProxySocket.Authentication.AuthNone" Collapsed="true">
|
||||||
|
<Position X="5.5" Y="8.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ProxySocket\AuthNone.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAgAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="Org.Mentalis.Network.ProxySocket.Authentication.AuthUserPass" Collapsed="true">
|
||||||
|
<Position X="7.75" Y="8.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ProxySocket\AuthUserPass.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAQAAAAAQAABQIBAAAAAAAiAAAAAAAABAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="Org.Mentalis.Network.ProxySocket.IAsyncProxyResult" Collapsed="true" BaseTypeListCollapsed="true">
|
||||||
|
<Position X="23.25" Y="2.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ProxySocket\IAsyncProxyResult.cs</FileName>
|
||||||
|
<HashCode>AAAAAAIAAAAABAAAAAAAECAAAAAAABAQEAACAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
<Lollipop Position="0.2" Collapsed="true" />
|
||||||
|
</Class>
|
||||||
|
<Class Name="Org.Mentalis.Network.ProxySocket.ProxyException" Collapsed="true">
|
||||||
|
<Position X="23.25" Y="5.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ProxySocket\ProxyException.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="Org.Mentalis.Network.ProxySocket.ProxySocket" Collapsed="true">
|
||||||
|
<Position X="25" Y="5.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ProxySocket\ProxySocket.cs</FileName>
|
||||||
|
<HashCode>AAAQAAAEICCJAEgAAAQAIICACAQFACAGAAAARAAgAEA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="Org.Mentalis.Network.ProxySocket.Socks4Handler" Collapsed="true">
|
||||||
|
<Position X="0.5" Y="8.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ProxySocket\Socks4Handler.cs</FileName>
|
||||||
|
<HashCode>AAAAABAAAAASAAAAAAAAAAABAAEEAAAAAAAAAAAAAAg=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="Org.Mentalis.Network.ProxySocket.Socks5Handler" Collapsed="true">
|
||||||
|
<Position X="2.75" Y="8.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ProxySocket\Socks5Handler.cs</FileName>
|
||||||
|
<HashCode>AAAAABAAAAASAAAAAEAAAQKBAAEEAAACAEAABEAQEAg=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="Org.Mentalis.Network.ProxySocket.SocksHandler" Collapsed="true">
|
||||||
|
<Position X="1.75" Y="7.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ProxySocket\SocksHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAABQBACAAAAAAEQAABAAACAAACEAAAAAQAgAAQAg=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.Core.YIMMessage" Collapsed="true">
|
||||||
|
<Position X="12.75" Y="3.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\YIMMessage.cs</FileName>
|
||||||
|
<HashCode>AACAAAAAAAEAAGAAAAAABAAgBAAAAIAAAQAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Class Name="MSNPSharp.YIMMessageHandler" Collapsed="true">
|
||||||
|
<Position X="1.5" Y="16" Width="2" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>YIMMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAABAAAAAAAAsAAAAAAECAgAAABwACAAAAAKAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Class>
|
||||||
|
<Interface Name="MSNPSharp.Core.IMessageHandler" Collapsed="true">
|
||||||
|
<Position X="23.25" Y="7.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\IMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAABAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Interface>
|
||||||
|
<Interface Name="MSNPSharp.Core.IMessageProcessor" Collapsed="true">
|
||||||
|
<Position X="25" Y="7.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Core\MessageProcessor.cs</FileName>
|
||||||
|
<HashCode>CAAAAAAAAAAAAQAAACAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Interface>
|
||||||
|
<Enum Name="MSNPSharp.ProxyType" Collapsed="true">
|
||||||
|
<Position X="32" Y="9.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>enums.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAEAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.NotificationType" Collapsed="true">
|
||||||
|
<Position X="23.25" Y="9.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>enums.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAACEAAAAAAAAAAI=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.PresenceStatus" Collapsed="true">
|
||||||
|
<Position X="28.5" Y="9.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>enums.cs</FileName>
|
||||||
|
<HashCode>AAAAAABABAAAAAAAAAgAEAAAAABAAAAAAAAAIAAEgFA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.MSNError" Collapsed="true">
|
||||||
|
<Position X="30.25" Y="8.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>enums.cs</FileName>
|
||||||
|
<HashCode>AAcpAoEqohACAGQAgEYgAIaHBAoURRIJAUFQACGBAJA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.MSNLists" Collapsed="true">
|
||||||
|
<Position X="32" Y="8.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>enums.cs</FileName>
|
||||||
|
<HashCode>AAQAAAQAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAEIAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.PrivacyMode" Collapsed="true">
|
||||||
|
<Position X="30.25" Y="9.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>enums.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAIAAAAAgAAAAAAAAAAAAAAAAAAAAAAABA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.NotifyPrivacy" Collapsed="true">
|
||||||
|
<Position X="25" Y="9.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>enums.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAEAAAAAAABA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.ClientCapacities" Collapsed="true">
|
||||||
|
<Position X="23.25" Y="8.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>enums.cs</FileName>
|
||||||
|
<HashCode>AABACAAIAJNIJAIAAAAFAAGAAEBgAEAAjAAIAQkYCAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.TextDecorations" Collapsed="true">
|
||||||
|
<Position X="25" Y="10.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>enums.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAACAAAIAAAAAAAAACAAAAAAAAAAEAAAE=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.MediaType" Collapsed="true">
|
||||||
|
<Position X="26.75" Y="8.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>enums.cs</FileName>
|
||||||
|
<HashCode>QAAAAAEAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAEAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.MessageCharSet" Collapsed="true">
|
||||||
|
<Position X="28.5" Y="8.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>enums.cs</FileName>
|
||||||
|
<HashCode>AAAIAQAAABCABEACAEAAICAQABAAACAAAIAAEAIIiAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.MSNObjectType" Collapsed="true">
|
||||||
|
<Position X="33.75" Y="8.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>MSNObject.cs</FileName>
|
||||||
|
<HashCode>IACAAAAAEAAAAAAAAAYABAAAAABCAAFAAAAiAIAAABA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.SignedOffReason" Collapsed="true">
|
||||||
|
<Position X="23.25" Y="10.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>enums.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAABA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.DataTransfer.DataTransferType" Collapsed="true">
|
||||||
|
<Position X="25" Y="8.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\MSNSLPHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAIAABAAAAAAEAAAAAAAAAEAAABA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="MSNPSharp.DataTransfer.P2PFlag" Collapsed="true">
|
||||||
|
<Position X="26.75" Y="9.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>DataTransfer\P2PMessage.cs</FileName>
|
||||||
|
<HashCode>AgAAAAIIAgCAAAAAAAgAAAAAAAAMQACAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Enum Name="Org.Mentalis.Network.ProxySocket.ProxyTypes" Collapsed="true">
|
||||||
|
<Position X="33.75" Y="9.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ProxySocket\ProxySocket.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAEAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Enum>
|
||||||
|
<Delegate Name="MSNPSharp.ConversationCreatedEventHandler" Collapsed="true">
|
||||||
|
<Position X="28.5" Y="11.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>Messenger.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAgAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.ContactChangedEventHandler" Collapsed="true">
|
||||||
|
<Position X="23.25" Y="11.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>NSMessageHandler.cs</FileName>
|
||||||
|
<HashCode>EAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.ContactGroupChangedEventHandler" Collapsed="true">
|
||||||
|
<Position X="25" Y="11.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>NSMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAgAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.ContactStatusChangedEventHandler" Collapsed="true">
|
||||||
|
<Position X="26.75" Y="11.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>NSMessageHandler.cs</FileName>
|
||||||
|
<HashCode>ABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.ListReceivedEventHandler" Collapsed="true">
|
||||||
|
<Position X="26.75" Y="12" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>NSMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQ=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.SignedOffEventHandler" Collapsed="true">
|
||||||
|
<Position X="33.75" Y="12.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>NSMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAgAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.PingAnswerEventHandler" Collapsed="true">
|
||||||
|
<Position X="25" Y="12.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>NSMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAACAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.ListMutatedAddedEventHandler" Collapsed="true">
|
||||||
|
<Position X="25" Y="12" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>NSMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAIA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.SBCreatedEventHandler" Collapsed="true">
|
||||||
|
<Position X="30.25" Y="12.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>NSMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAQAACAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.MailboxStatusEventHandler" Collapsed="true">
|
||||||
|
<Position X="28.5" Y="12" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>NSMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAQAAAEAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.NewMailEventHandler" Collapsed="true">
|
||||||
|
<Position X="33.75" Y="12" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>NSMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAQAAAAAgAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.MailChangedEventHandler" Collapsed="true">
|
||||||
|
<Position X="30.25" Y="12" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>NSMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAgAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.SBChangedEventHandler" Collapsed="true">
|
||||||
|
<Position X="28.5" Y="12.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>SBMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAACAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.TextMessageReceivedEventHandler" Collapsed="true">
|
||||||
|
<Position X="23.25" Y="13.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>SBMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAQAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.EmoticonDefinitionReceivedEventHandler" Collapsed="true">
|
||||||
|
<Position X="30.25" Y="11.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>SBMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAACAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.WinkReceivedEventHandler" Collapsed="true">
|
||||||
|
<Position X="26.75" Y="13.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>SBMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAEAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.UserTypingEventHandler" Collapsed="true">
|
||||||
|
<Position X="25" Y="13.5" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>SBMessageHandler.cs</FileName>
|
||||||
|
<HashCode>EAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.Core.ErrorReceivedEventHandler" Collapsed="true">
|
||||||
|
<Position X="32" Y="11.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>IMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAACAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.Core.HandlerExceptionEventHandler" Collapsed="true">
|
||||||
|
<Position X="33.75" Y="11.25" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>IMessageHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAQAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.Core.ProcessorExceptionEventHandler" Collapsed="true">
|
||||||
|
<Position X="26.75" Y="12.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>MessageProcessor.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAQAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.DataTransfer.P2PTransferSessionChangedEventHandler" Collapsed="true">
|
||||||
|
<Position X="23.25" Y="12.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>MSNSLPHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAIAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.DataTransfer.MSNSLPInvitationReceivedEventHandler" Collapsed="true">
|
||||||
|
<Position X="32" Y="12" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>MSNSLPHandler.cs</FileName>
|
||||||
|
<HashCode>AAAACAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="MSNPSharp.DataTransfer.SessionChangedEventHandler" Collapsed="true">
|
||||||
|
<Position X="32" Y="12.75" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>P2PHandler.cs</FileName>
|
||||||
|
<HashCode>CAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
<Delegate Name="Org.Mentalis.Network.ProxySocket.HandShakeComplete" Collapsed="true">
|
||||||
|
<Position X="23.25" Y="12" Width="1.5" />
|
||||||
|
<TypeIdentifier>
|
||||||
|
<FileName>ProxySocket\SocksHandler.cs</FileName>
|
||||||
|
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAA=</HashCode>
|
||||||
|
</TypeIdentifier>
|
||||||
|
</Delegate>
|
||||||
|
</ClassDiagram>
|
||||||
85
MSNPSharp/Comparers.cs
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MSNPSharp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A comparer which treat siblings as the same contact.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TKey"></typeparam>
|
||||||
|
public class SiblingComparer<TKey> : IEqualityComparer<TKey>
|
||||||
|
{
|
||||||
|
#region IEqualityComparer<TKey> Members
|
||||||
|
|
||||||
|
public bool Equals(TKey x, TKey y)
|
||||||
|
{
|
||||||
|
return GetHashCode(x) == GetHashCode(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetHashCode(TKey obj)
|
||||||
|
{
|
||||||
|
if (obj is Contact)
|
||||||
|
{
|
||||||
|
return (obj as Contact).SiblingString.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Utilities
|
||||||
|
{
|
||||||
|
public class ConversationIDComparer : IEqualityComparer<ConversationID>
|
||||||
|
{
|
||||||
|
#region IEqualityComparer<ConversationID> Members
|
||||||
|
|
||||||
|
public bool Equals(ConversationID x, ConversationID y)
|
||||||
|
{
|
||||||
|
return x == y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetHashCode(ConversationID obj)
|
||||||
|
{
|
||||||
|
return obj.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
237
MSNPSharp/Configuration.cs
Normal file
|
|
@ -0,0 +1,237 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace MSNPSharp
|
||||||
|
{
|
||||||
|
using MSNPSharp.IO;
|
||||||
|
using MSNPSharp.Core;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public enum PublicPortPriority
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
First = 1,
|
||||||
|
Last = 9
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// General configuration options.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable()]
|
||||||
|
public static class Settings
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the verbosity of the trace messages.
|
||||||
|
/// </summary>
|
||||||
|
public static TraceSwitch TraceSwitch = new TraceSwitch("MSNPSharp", "MSNPSharp switch");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ports for DC to try bind. These ports aren't firewalled by ISS.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly ushort[] PublicPorts = new ushort[]
|
||||||
|
{
|
||||||
|
80, // http
|
||||||
|
21, // ftp
|
||||||
|
25, // smtp
|
||||||
|
110, // pop3
|
||||||
|
443, // https
|
||||||
|
8080 // webcache
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor.
|
||||||
|
/// </summary>
|
||||||
|
static Settings()
|
||||||
|
{
|
||||||
|
isMono = (null != Type.GetType("Mono.Runtime")); // http://www.mono-project.com/FAQ:_Technical
|
||||||
|
|
||||||
|
TraceSwitch.Level = TraceLevel.Verbose;
|
||||||
|
#if DEBUG
|
||||||
|
serializationType = MclSerialization.Compression | MclSerialization.Cryptography;
|
||||||
|
#else
|
||||||
|
serializationType = MclSerialization.Compression;
|
||||||
|
#endif
|
||||||
|
enableGzipCompressionForWebServices = (isMono == false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PublicPortPriority publicPortPriority = PublicPortPriority.First;
|
||||||
|
private static string savepath = Path.GetFullPath(".");
|
||||||
|
private static bool enableGzipCompressionForWebServices;
|
||||||
|
private static MclSerialization serializationType;
|
||||||
|
private static int msnTicketsCleanupInterval = 5;
|
||||||
|
private static int msnTicketLifeTime = 20;
|
||||||
|
private static bool noSave;
|
||||||
|
private static bool isMono;
|
||||||
|
|
||||||
|
public static PublicPortPriority PublicPortPriority
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return publicPortPriority;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
publicPortPriority = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates whether the runtime framework is currently mono or not.
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsMono
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return isMono;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// File serialization type when saving.
|
||||||
|
/// </summary>Compression saves spaces on disk, Encrypt protects your addressbook but eats some cpu<remarks>
|
||||||
|
/// </remarks>
|
||||||
|
public static MclSerialization SerializationType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return serializationType;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
serializationType = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Don't save addressbook files.
|
||||||
|
/// </summary>
|
||||||
|
public static bool NoSave
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return noSave;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
noSave = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Save directory
|
||||||
|
/// </summary>
|
||||||
|
public static string SavePath
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return savepath;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
savepath = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>MSNTicket lifetime in minutes for the internal cache. Default is 20 minutes.</summary>
|
||||||
|
/// <remarks>Keep small if the client will connect to the msn network for the short time.</remarks>
|
||||||
|
public static int MSNTicketLifeTime
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return msnTicketLifeTime;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value <= 0)
|
||||||
|
value = 20;
|
||||||
|
|
||||||
|
msnTicketLifeTime = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Run clean up code for the MSNTickets in every x minutes. Default is 5 minutes.
|
||||||
|
/// </summary>
|
||||||
|
public static int MSNTicketsCleanupInterval
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return msnTicketsCleanupInterval;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value <= 0)
|
||||||
|
value = 5;
|
||||||
|
|
||||||
|
msnTicketsCleanupInterval = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use Gzip compression for web services to save bandwidth.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Don't use this if you run .net framework on mono</remarks>
|
||||||
|
public static bool EnableGzipCompressionForWebServices
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return enableGzipCompressionForWebServices;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
enableGzipCompressionForWebServices = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Don't use compression when saving addressbook files.
|
||||||
|
/// </summary>
|
||||||
|
[Obsolete("Please use SerializationType", false)]
|
||||||
|
public static bool NoCompress
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (serializationType == MclSerialization.None);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
serializationType = value ? MclSerialization.None : MclSerialization.Compression;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
83
MSNPSharp/ConnectivityException.cs
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace MSNPSharp
|
||||||
|
{
|
||||||
|
using MSNPSharp.Core;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies an exception when a connection is setup.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable()]
|
||||||
|
public class ConnectivityException : MSNPSharpException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Basic constructor.
|
||||||
|
/// </summary>
|
||||||
|
public ConnectivityException()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies a ConnectivityException.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">A textual presentation of the exception message</param>
|
||||||
|
public ConnectivityException(string message)
|
||||||
|
: base(message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies a ConnectivityException which originates from another exception.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">A textual presentation of the exception message</param>
|
||||||
|
/// <param name="innerException">The (inner)exception which caused this exception. For example a SocketException</param>
|
||||||
|
public ConnectivityException(string message, Exception innerException)
|
||||||
|
: base(message, innerException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Serialization constructor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info"></param>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
protected ConnectivityException(SerializationInfo info, StreamingContext context)
|
||||||
|
: base(info, context)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
502
MSNPSharp/ConnectivitySettings.cs
Normal file
|
|
@ -0,0 +1,502 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Web;
|
||||||
|
using System.Net.Security;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
|
namespace MSNPSharp
|
||||||
|
{
|
||||||
|
using MSNPSharp.Core;
|
||||||
|
|
||||||
|
public class MSNServiceCertificatePolicy : ICertificatePolicy
|
||||||
|
{
|
||||||
|
public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the way how connections must be set up.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Via ConnectivitySettings the client can specify to which MSN server must be connected,
|
||||||
|
/// whether or not proxy servers are used for internet connections and whether
|
||||||
|
/// web proxys are used for accessing HTTP resources. The most common HTTP resource
|
||||||
|
/// is the authentication with Passport.com during the login phase.
|
||||||
|
/// </remarks>
|
||||||
|
[Serializable()]
|
||||||
|
public class ConnectivitySettings
|
||||||
|
{
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
static ConnectivitySettings()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate,
|
||||||
|
X509Chain chain, SslPolicyErrors sslPolicyErrors)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
#pragma warning disable 0618
|
||||||
|
ServicePointManager.CertificatePolicy = new MSNServiceCertificatePolicy();
|
||||||
|
#pragma warning restore 0618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor to instantiate a ConnectivitySettings object.
|
||||||
|
/// </summary>
|
||||||
|
public ConnectivitySettings()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Copy constructor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x"></param>
|
||||||
|
public ConnectivitySettings(ConnectivitySettings x)
|
||||||
|
: this(x.LocalHost, x.LocalPort, x.Host, x.Port, x.ProxyHost, x.Port, x.ProxyUsername, x.ProxyPassword, x.ProxyType, x.WebProxy)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a socks proxy in all direct TCP communications with the messenger servers. HTTP resources are accessed via the supplied WebProxy.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteEndPoint">Host endpoint of messenger server. Standard is msnmsgr.escargot.chat:1863</param>
|
||||||
|
public ConnectivitySettings(IPEndPoint remoteEndPoint)
|
||||||
|
: this(remoteEndPoint.Address.ToString(), remoteEndPoint.Port)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a socks proxy in all direct TCP communications with the messenger servers. HTTP resources are accessed via the supplied WebProxy.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="localEndPoint">Local endpoint you want to bind to.</param>
|
||||||
|
/// <param name="remoteEndPoint">Host endpoint of messenger server. Standard is msnmsgr.escargot.chat:1863</param>
|
||||||
|
public ConnectivitySettings(IPEndPoint localEndPoint, IPEndPoint remoteEndPoint)
|
||||||
|
: this(localEndPoint.Address.ToString(), localEndPoint.Port, remoteEndPoint.Address.ToString(), remoteEndPoint.Port)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings with custom host and port.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="host">Host of messenger server. Standard is msnmsgr.escargot.chat</param>
|
||||||
|
/// <param name="port">Port of messenger server. Standard is 1863</param>
|
||||||
|
public ConnectivitySettings(string host, int port)
|
||||||
|
: this(host, port, string.Empty, 0, string.Empty, string.Empty, ProxyType.None, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings with custom host and port.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="localHost">The local address you want to bind to.</param>
|
||||||
|
/// <param name="localPort">The local port you want to bind to.</param>
|
||||||
|
/// <param name="host">Host of messenger server. Standard is msnmsgr.escargot.chat</param>
|
||||||
|
/// <param name="port">Port of messenger server. Standard is 1863</param>
|
||||||
|
public ConnectivitySettings(string localHost, int localPort, string host, int port)
|
||||||
|
: this(localHost, localPort, host, port, string.Empty, 0, string.Empty, string.Empty, ProxyType.None, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a socks proxy in all direct TCP communications with the messenger servers. HTTP resources are accessed via the supplied WebProxy.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteEndPoint">Host endpoint of messenger server. Standard is msnmsgr.escargot.chat:1863</param>
|
||||||
|
/// <param name="webProxy">Webproxy to be used when accessing HTTP resources</param>
|
||||||
|
public ConnectivitySettings(IPEndPoint remoteEndPoint, WebProxy webProxy)
|
||||||
|
: this(remoteEndPoint.Address.ToString(), remoteEndPoint.Port, webProxy)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a socks proxy in all direct TCP communications with the messenger servers. HTTP resources are accessed via the supplied WebProxy.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="localEndPoint">Local endpoint you want to bind to.</param>
|
||||||
|
/// <param name="remoteEndPoint">Host endpoint of messenger server. Standard is msnmsgr.escargot.chat:1863</param>
|
||||||
|
/// <param name="webProxy">Webproxy to be used when accessing HTTP resources</param>
|
||||||
|
public ConnectivitySettings(IPEndPoint localEndPoint, IPEndPoint remoteEndPoint, WebProxy webProxy)
|
||||||
|
: this(localEndPoint.Address.ToString(), localEndPoint.Port, remoteEndPoint.Address.ToString(), remoteEndPoint.Port, webProxy)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a Web proxy for all HTTP connections made.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="host">Host of messenger server. Standard is msnmsgr.escargot.chat</param>
|
||||||
|
/// <param name="port">Port of messenger server. Standard is 1863</param>
|
||||||
|
/// <param name="webProxy">Webproxy to be used when accessing HTTP resources</param>
|
||||||
|
public ConnectivitySettings(string host, int port, WebProxy webProxy)
|
||||||
|
: this(host, port, string.Empty, 0, string.Empty, string.Empty, ProxyType.None, webProxy)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a Web proxy for all HTTP connections made.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="localHost">The local address you want to bind to.</param>
|
||||||
|
/// <param name="localPort">The local port you want to bind to.</param>
|
||||||
|
/// <param name="host">Host of messenger server. Standard is msnmsgr.escargot.chat</param>
|
||||||
|
/// <param name="port">Port of messenger server. Standard is 1863</param>
|
||||||
|
/// <param name="webProxy">Webproxy to be used when accessing HTTP resources</param>
|
||||||
|
public ConnectivitySettings(string localHost, int localPort, string host, int port, WebProxy webProxy)
|
||||||
|
: this(localHost, localPort, host, port, string.Empty, 0, string.Empty, string.Empty, ProxyType.None, webProxy)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a socks proxy in all direct TCP communications with the messenger servers. HTTP resources are accessed via the supplied WebProxy.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteEndPoint">Host endpoint of messenger server. Standard is msnmsgr.escargot.chat:1863</param>
|
||||||
|
/// <param name="proxyEndPoint">Host endpoint of the proxy server</param>
|
||||||
|
/// <param name="proxyUsername">Username, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyPassword">Password, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyType">The proxy version, Socks4 or Socks5</param>
|
||||||
|
public ConnectivitySettings(IPEndPoint remoteEndPoint, IPEndPoint proxyEndPoint, string proxyUsername, string proxyPassword, ProxyType proxyType)
|
||||||
|
: this(remoteEndPoint.Address.ToString(), remoteEndPoint.Port, proxyEndPoint.Address.ToString(), proxyEndPoint.Port, proxyUsername, proxyPassword, proxyType, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a socks proxy in all direct TCP communications with the messenger servers. HTTP resources are accessed via the supplied WebProxy.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="localEndPoint">Local endpoint you want to bind to.</param>
|
||||||
|
/// <param name="remoteEndPoint">Host endpoint of messenger server. Standard is msnmsgr.escargot.chat:1863</param>
|
||||||
|
/// <param name="proxyEndPoint">Host endpoint of the proxy server</param>
|
||||||
|
/// <param name="proxyUsername">Username, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyPassword">Password, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyType">The proxy version, Socks4 or Socks5</param>
|
||||||
|
public ConnectivitySettings(IPEndPoint localEndPoint, IPEndPoint remoteEndPoint, IPEndPoint proxyEndPoint, string proxyUsername, string proxyPassword, ProxyType proxyType)
|
||||||
|
: this(localEndPoint, remoteEndPoint, proxyUsername, proxyPassword, proxyType, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a proxy in all direct TCP communications with the messenger servers. This means HTTP resources for authenticating the user with Passport.com are accessed directly.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="host">Host of messenger server. Standard is msnmsgr.escargot.chat</param>
|
||||||
|
/// <param name="port">Port of messenger server. Standard is 1863</param>
|
||||||
|
/// <param name="proxyHost">Host of the proxy server</param>
|
||||||
|
/// <param name="proxyPort">Port of the proxy server</param>
|
||||||
|
/// <param name="proxyUsername">Username, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyPassword">Password, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyType">The proxy version, Socks4 or Socks5</param>
|
||||||
|
public ConnectivitySettings(string host, int port, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, ProxyType proxyType)
|
||||||
|
: this(host, port, proxyHost, proxyPort, proxyUsername, proxyPassword, proxyType, null)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a socks proxy in all direct TCP communications with the messenger servers. HTTP resources are accessed via the supplied WebProxy.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="localHost">The local address you want to bind to.</param>
|
||||||
|
/// <param name="localPort">The local port you want to bind to.</param>
|
||||||
|
/// <param name="host">Host of messenger server. Standard is msnmsgr.escargot.chat</param>
|
||||||
|
/// <param name="port">Port of messenger server. Standard is 1863</param>
|
||||||
|
/// <param name="proxyHost">Host of the proxy server</param>
|
||||||
|
/// <param name="proxyPort">Port of the proxy server</param>
|
||||||
|
/// <param name="proxyUsername">Username, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyPassword">Password, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyType">The proxy version, Socks4 or Socks5</param>
|
||||||
|
public ConnectivitySettings(string localHost, int localPort, string host, int port, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, ProxyType proxyType)
|
||||||
|
: this(localHost, localPort, host, port, proxyHost, proxyPort, proxyUsername, proxyPassword, proxyType, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a socks proxy in all direct TCP communications with the messenger servers. HTTP resources are accessed via the supplied WebProxy.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteEndPoint">Host endpoint of messenger server. Standard is msnmsgr.escargot.chat:1863</param>
|
||||||
|
/// <param name="proxyEndPoint">Host endpoint of the proxy server</param>
|
||||||
|
/// <param name="proxyUsername">Username, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyPassword">Password, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyType">The proxy version, Socks4 or Socks5</param>
|
||||||
|
/// <param name="webProxy">Webproxy to be used when accessing HTTP resources</param>
|
||||||
|
public ConnectivitySettings(IPEndPoint remoteEndPoint, IPEndPoint proxyEndPoint, string proxyUsername, string proxyPassword, ProxyType proxyType, WebProxy webProxy)
|
||||||
|
: this(remoteEndPoint.Address.ToString(), remoteEndPoint.Port, proxyEndPoint.Address.ToString(), proxyEndPoint.Port, proxyUsername, proxyPassword, proxyType, webProxy)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a socks proxy in all direct TCP communications with the messenger servers. HTTP resources are accessed via the supplied WebProxy.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="localEndPoint">Local endpoint you want to bind to.</param>
|
||||||
|
/// <param name="remoteEndPoint">Host endpoint of messenger server. Standard is msnmsgr.escargot.chat:1863</param>
|
||||||
|
/// <param name="proxyEndPoint">Host endpoint of the proxy server</param>
|
||||||
|
/// <param name="proxyUsername">Username, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyPassword">Password, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyType">The proxy version, Socks4 or Socks5</param>
|
||||||
|
/// <param name="webProxy">Webproxy to be used when accessing HTTP resources</param>
|
||||||
|
public ConnectivitySettings(IPEndPoint localEndPoint, IPEndPoint remoteEndPoint, IPEndPoint proxyEndPoint, string proxyUsername, string proxyPassword, ProxyType proxyType, WebProxy webProxy)
|
||||||
|
: this(localEndPoint.Address.ToString(), localEndPoint.Port, remoteEndPoint.Address.ToString(), remoteEndPoint.Port, proxyEndPoint.Address.ToString(), proxyEndPoint.Port, proxyUsername, proxyPassword, proxyType, webProxy)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a socks proxy in all direct TCP communications with the messenger servers. HTTP resources are accessed via the supplied WebProxy.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="host">Host of messenger server. Standard is msnmsgr.escargot.chat</param>
|
||||||
|
/// <param name="port">Port of messenger server. Standard is 1863</param>
|
||||||
|
/// <param name="proxyHost">Host of the proxy server</param>
|
||||||
|
/// <param name="proxyPort">Port of the proxy server</param>
|
||||||
|
/// <param name="proxyUsername">Username, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyPassword">Password, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyType">The proxy version, Socks4 or Socks5</param>
|
||||||
|
/// <param name="webProxy">Webproxy to be used when accessing HTTP resources</param>
|
||||||
|
public ConnectivitySettings(string host, int port, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, ProxyType proxyType, WebProxy webProxy)
|
||||||
|
:this(string.Empty, 0, host, port, proxyHost, proxyPort, proxyUsername, proxyPassword, proxyType, webProxy)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a ConnectivitySettings which uses a socks proxy in all direct TCP communications with the messenger servers. HTTP resources are accessed via the supplied WebProxy.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="localHost">The local address you want to bind to.</param>
|
||||||
|
/// <param name="localPort">The local port you want to bind to.</param>
|
||||||
|
/// <param name="host">Host of messenger server. Standard is msnmsgr.escargot.chat</param>
|
||||||
|
/// <param name="port">Port of messenger server. Standard is 1863</param>
|
||||||
|
/// <param name="proxyHost">Host of the proxy server</param>
|
||||||
|
/// <param name="proxyPort">Port of the proxy server</param>
|
||||||
|
/// <param name="proxyUsername">Username, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyPassword">Password, if any, used when accessing the proxyserver</param>
|
||||||
|
/// <param name="proxyType">The proxy version, Socks4 or Socks5</param>
|
||||||
|
/// <param name="webProxy">Webproxy to be used when accessing HTTP resources</param>
|
||||||
|
public ConnectivitySettings(string localHost, int localPort, string host, int port, string proxyHost, int proxyPort, string proxyUsername, string proxyPassword, ProxyType proxyType, WebProxy webProxy)
|
||||||
|
{
|
||||||
|
this.localHost = localHost;
|
||||||
|
this.localPort = localPort;
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
|
this.proxyHost = proxyHost;
|
||||||
|
this.proxyPort = proxyPort;
|
||||||
|
this.proxyUsername = proxyUsername;
|
||||||
|
this.proxyPassword = proxyPassword;
|
||||||
|
this.proxyType = proxyType;
|
||||||
|
this.webProxy = webProxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private members
|
||||||
|
|
||||||
|
private string host = "msnmsgr.escargot.chat";
|
||||||
|
private int port = 1863;
|
||||||
|
private string localHost = string.Empty;
|
||||||
|
private int localPort = 0;
|
||||||
|
private string proxyHost = string.Empty;
|
||||||
|
private int proxyPort = 0;
|
||||||
|
private string proxyUsername = string.Empty;
|
||||||
|
private string proxyPassword = string.Empty;
|
||||||
|
private ProxyType proxyType = ProxyType.None;
|
||||||
|
private WebProxy webProxy = null;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Hostname of the MSN server. Defaults is msnmsgr.escargot.chat
|
||||||
|
/// </summary>
|
||||||
|
public string Host
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
host = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Port of the MSN server. Default is 1863.
|
||||||
|
/// </summary>
|
||||||
|
public int Port
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
port = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The local ip you want to bind.
|
||||||
|
/// </summary>
|
||||||
|
public string LocalHost
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return localHost;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
localHost = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The local port you want to bind, default is 0 (which means the system will assign it automatically).
|
||||||
|
/// </summary>
|
||||||
|
public int LocalPort
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return localPort;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
localPort = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The host of the proxy. This must be filled in when ProxyType is set to something else than ProxyType.None.
|
||||||
|
/// </summary>
|
||||||
|
public string ProxyHost
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return proxyHost;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
proxyHost = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The port used to access the proxy. This must be filled in when ProxyType is set to something else than ProxyType.None.
|
||||||
|
/// </summary>
|
||||||
|
public int ProxyPort
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return proxyPort;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
proxyPort = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The username used when accessing the proxy. This must be filled in when ProxyType is set to something else than ProxyType.None.
|
||||||
|
/// </summary>
|
||||||
|
public string ProxyUsername
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return proxyUsername;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
proxyUsername = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The username used when accessing the proxy. This must be filled in when ProxyType is set to something else than ProxyType.None.
|
||||||
|
/// </summary>
|
||||||
|
public string ProxyPassword
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return proxyPassword;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
proxyPassword = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The ProxyType used. If ProxyType is set to something else than ProxyType.None a proxy server is used, using Socks4 or Socks 5 depending on the type. Read-only.
|
||||||
|
/// </summary>
|
||||||
|
public ProxyType ProxyType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return proxyType;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
proxyType = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If this is not null a webproxy is used in all HTTP request in the library. An important HTTP request is the authentication with Passport.com.
|
||||||
|
/// </summary>
|
||||||
|
public WebProxy WebProxy
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return webProxy;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
webProxy = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A string that shows the current host and port.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return "{Host=" + Host + ", Port=" + Port + "}";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
};
|
||||||
1380
MSNPSharp/Contact.cs
Normal file
210
MSNPSharp/ContactGroup.cs
Normal file
|
|
@ -0,0 +1,210 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace MSNPSharp
|
||||||
|
{
|
||||||
|
using MSNPSharp.Core;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used as event argument when a contactgroup is affected.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable()]
|
||||||
|
public class ContactGroupEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
private ContactGroup contactGroup;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The affected contact group
|
||||||
|
/// </summary>
|
||||||
|
public ContactGroup ContactGroup
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return contactGroup;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
contactGroup = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor, mostly used internal by the library.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="contactGroup"></param>
|
||||||
|
public ContactGroupEventArgs(ContactGroup contactGroup)
|
||||||
|
{
|
||||||
|
ContactGroup = contactGroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines a single contact group.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable()]
|
||||||
|
public class ContactGroup
|
||||||
|
{
|
||||||
|
#region Private
|
||||||
|
|
||||||
|
private string name;
|
||||||
|
private string guid;
|
||||||
|
private object clientData;
|
||||||
|
private bool isFavorite;
|
||||||
|
|
||||||
|
[NonSerialized]
|
||||||
|
private NSMessageHandler nsMessageHandler = null;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Internal
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor, used internally by the library.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="guid"></param>
|
||||||
|
/// <param name="isFavorite"></param>
|
||||||
|
/// <param name="nsMessageHandler"></param>
|
||||||
|
internal ContactGroup(string name, string guid, NSMessageHandler nsMessageHandler, bool isFavorite)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.guid = guid;
|
||||||
|
this.isFavorite = isFavorite;
|
||||||
|
this.nsMessageHandler = nsMessageHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ContactGroup()
|
||||||
|
: this(String.Empty, System.Guid.NewGuid().ToString(), null, false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used by nameserver.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
internal void SetName(string name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The notification message handler which controls this contact object
|
||||||
|
/// </summary>
|
||||||
|
internal NSMessageHandler NSMessageHandler
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return nsMessageHandler;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The custom data specified by the client programmer
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>The application programmer can define it's own data here. It is not used by MSNPSharp.</remarks>
|
||||||
|
public object ClientData
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return clientData;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
clientData = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the contactgroup
|
||||||
|
/// </summary>
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (NSMessageHandler != null)
|
||||||
|
{
|
||||||
|
NSMessageHandler.ContactService.RenameGroup(this, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The unique contactgroup ID assigned by MSN
|
||||||
|
/// </summary>
|
||||||
|
public string Guid
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return guid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsFavorite
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return isFavorite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the ID field as hashcode. This is necessary to compare contactgroups.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
override public int GetHashCode()
|
||||||
|
{
|
||||||
|
return guid.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Equals two contacgroups based on their ID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="obj"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
ContactGroup cg = obj as ContactGroup;
|
||||||
|
return cg != null && cg.Guid == guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
};
|
||||||
131
MSNPSharp/ContactGroupList.cs
Normal file
|
|
@ -0,0 +1,131 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace MSNPSharp
|
||||||
|
{
|
||||||
|
[Serializable()]
|
||||||
|
public class ContactGroupList : IEnumerable
|
||||||
|
{
|
||||||
|
List<ContactGroup> list = new List<ContactGroup>();
|
||||||
|
|
||||||
|
[NonSerialized]
|
||||||
|
NSMessageHandler nsMessageHandler = null;
|
||||||
|
|
||||||
|
internal void AddGroup(ContactGroup group)
|
||||||
|
{
|
||||||
|
if (this[group.Guid] == null)
|
||||||
|
list.Add(group);
|
||||||
|
else
|
||||||
|
this[group.Guid].SetName(group.Name);
|
||||||
|
}
|
||||||
|
internal void RemoveGroup(ContactGroup group)
|
||||||
|
{
|
||||||
|
list.Remove(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal ContactGroupList(NSMessageHandler handler)
|
||||||
|
{
|
||||||
|
nsMessageHandler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Add(string name)
|
||||||
|
{
|
||||||
|
if (nsMessageHandler == null)
|
||||||
|
throw new MSNPSharpException("No nameserver handler defined");
|
||||||
|
|
||||||
|
nsMessageHandler.ContactService.AddContactGroup(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Remove(ContactGroup group)
|
||||||
|
{
|
||||||
|
if (nsMessageHandler == null)
|
||||||
|
throw new MSNPSharpException("No nameserver handler defined");
|
||||||
|
|
||||||
|
if (this[group.Guid] != null)
|
||||||
|
nsMessageHandler.ContactService.RemoveContactGroup(group);
|
||||||
|
else
|
||||||
|
throw new MSNPSharpException("Contactgroup not defined in this list");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactGroup GetByName(string name)
|
||||||
|
{
|
||||||
|
foreach (ContactGroup group in list)
|
||||||
|
{
|
||||||
|
if (group.Name == name)
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactGroup this[string guid]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
foreach (ContactGroup group in list)
|
||||||
|
{
|
||||||
|
if (group.Guid.ToLower(CultureInfo.InvariantCulture) == guid.ToLower(CultureInfo.InvariantCulture))
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactGroup FavoriteGroup
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
foreach (ContactGroup group in list)
|
||||||
|
{
|
||||||
|
if (group.IsFavorite)
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator GetEnumerator()
|
||||||
|
{
|
||||||
|
return list.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
list.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
545
MSNPSharp/ContactList.cs
Normal file
|
|
@ -0,0 +1,545 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace MSNPSharp
|
||||||
|
{
|
||||||
|
using MSNPSharp.Core;
|
||||||
|
|
||||||
|
[Serializable()]
|
||||||
|
public class ContactList : Dictionary<int, Contact>
|
||||||
|
{
|
||||||
|
private static ClientType[] clientTypes = (ClientType[])Enum.GetValues(typeof(ClientType));
|
||||||
|
|
||||||
|
[NonSerialized]
|
||||||
|
private NSMessageHandler nsMessageHandler;
|
||||||
|
[NonSerialized]
|
||||||
|
private object syncRoot;
|
||||||
|
|
||||||
|
private Guid addressBookId = Guid.Empty;
|
||||||
|
private Owner owner = null;
|
||||||
|
|
||||||
|
private ContactList()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Initialize(NSMessageHandler handler, Owner owner)
|
||||||
|
{
|
||||||
|
nsMessageHandler = handler;
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactList(NSMessageHandler handler)
|
||||||
|
{
|
||||||
|
addressBookId = new Guid(WebServiceConstants.MessengerIndividualAddressBookId);
|
||||||
|
nsMessageHandler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactList(string abId, Owner owner, NSMessageHandler handler)
|
||||||
|
{
|
||||||
|
addressBookId = new Guid(abId);
|
||||||
|
Initialize(handler, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactList(Guid abId, Owner owner, NSMessageHandler handler)
|
||||||
|
{
|
||||||
|
addressBookId = abId;
|
||||||
|
Initialize(handler, owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region ListEnumerators
|
||||||
|
|
||||||
|
public class ListEnumerator : IEnumerator<Contact>
|
||||||
|
{
|
||||||
|
private Enumerator baseEnum;
|
||||||
|
private MSNLists listFilter;
|
||||||
|
|
||||||
|
public ListEnumerator(Enumerator listEnum, MSNLists filter)
|
||||||
|
{
|
||||||
|
baseEnum = listEnum;
|
||||||
|
listFilter = filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool MoveNext()
|
||||||
|
{
|
||||||
|
if (listFilter == MSNLists.None)
|
||||||
|
{
|
||||||
|
return baseEnum.MoveNext();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (baseEnum.MoveNext())
|
||||||
|
{
|
||||||
|
if (Current.HasLists(listFilter))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object IEnumerator.Current
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return baseEnum.Current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Contact Current
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return baseEnum.Current.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
baseEnum.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator<Contact> GetEnumerator()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class EmailListEnumerator : ContactList.ListEnumerator
|
||||||
|
{
|
||||||
|
public EmailListEnumerator(Enumerator listEnum)
|
||||||
|
: base(listEnum, MSNLists.None)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool MoveNext()
|
||||||
|
{
|
||||||
|
while (base.MoveNext())
|
||||||
|
{
|
||||||
|
if (Current.Guid != Guid.Empty && Current.IsMessengerUser == false)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Lists
|
||||||
|
|
||||||
|
public ContactList.ListEnumerator Forward
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new ContactList.ListEnumerator(GetEnumerator(), MSNLists.ForwardList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactList.ListEnumerator Allowed
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new ContactList.ListEnumerator(GetEnumerator(), MSNLists.AllowedList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactList.ListEnumerator BlockedList
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new ContactList.ListEnumerator(GetEnumerator(), MSNLists.BlockedList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactList.ListEnumerator Reverse
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new ContactList.ListEnumerator(GetEnumerator(), MSNLists.ReverseList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactList.ListEnumerator Pending
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new ContactList.ListEnumerator(GetEnumerator(), MSNLists.PendingList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactList.ListEnumerator All
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new ContactList.ListEnumerator(GetEnumerator(), MSNLists.None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ContactList.ListEnumerator Email
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new ContactList.EmailListEnumerator(GetEnumerator());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public object SyncRoot
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (syncRoot == null)
|
||||||
|
{
|
||||||
|
object newobj = new object();
|
||||||
|
Interlocked.CompareExchange(ref syncRoot, newobj, null);
|
||||||
|
}
|
||||||
|
return syncRoot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The addressbook identifier of this addressbook.
|
||||||
|
/// </summary>
|
||||||
|
public Guid AddressBookId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return addressBookId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The owner of the contactlist. This is the identity that logged into the messenger network.
|
||||||
|
/// </summary>
|
||||||
|
public Owner Owner
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the specified contact.
|
||||||
|
/// <remarks>If the contact does not exist, return null</remarks>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <returns>
|
||||||
|
/// If the contact does not exist, return null.
|
||||||
|
/// If the specified account has multi-clienttype, the contact with type
|
||||||
|
/// <see cref="ClientType.PassportMember"/> will be returned first.
|
||||||
|
/// If there's no PassportMember with the specified account, the contact with type
|
||||||
|
/// <see cref="ClientType.EmailMember"/> will be returned. Then the next is <see cref="ClientType.PhoneMember"/>
|
||||||
|
/// ,<see cref="ClientType.LCS"/> and so on...
|
||||||
|
/// </returns>
|
||||||
|
public Contact GetContact(string account)
|
||||||
|
{
|
||||||
|
if (HasContact(account, ClientType.PassportMember))
|
||||||
|
return GetContact(account, ClientType.PassportMember);
|
||||||
|
|
||||||
|
if (HasContact(account, ClientType.EmailMember))
|
||||||
|
return GetContact(account, ClientType.EmailMember);
|
||||||
|
|
||||||
|
if (HasContact(account, ClientType.PhoneMember))
|
||||||
|
return GetContact(account, ClientType.PhoneMember);
|
||||||
|
|
||||||
|
if (HasContact(account, ClientType.LCS))
|
||||||
|
return GetContact(account, ClientType.LCS);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the specified contact.
|
||||||
|
/// <para>This overload will set the contact name to a specified value (if the contact exists.).</para>
|
||||||
|
/// <remarks>If the contact does not exist, return null</remarks>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <returns>
|
||||||
|
/// If the contact does not exist, return null.
|
||||||
|
/// If the specified account has multi-clienttype, the contact with type
|
||||||
|
/// <see cref="ClientType.PassportMember"/> will be returned first.
|
||||||
|
/// If there's no PassportMember with the specified account, the contact with type
|
||||||
|
/// <see cref="ClientType.EmailMember"/> will be returned.Then the next is <see cref="ClientType.PhoneMember"/>
|
||||||
|
/// ,<see cref="ClientType.LCS"/> and so on...
|
||||||
|
/// </returns>
|
||||||
|
internal Contact GetContact(string account, string name)
|
||||||
|
{
|
||||||
|
Contact contact = GetContact(account);
|
||||||
|
if (contact != null)
|
||||||
|
lock (SyncRoot)
|
||||||
|
contact.SetName(name);
|
||||||
|
|
||||||
|
return contact;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a contact with specified account and client type, if the contact does not exist, create it.
|
||||||
|
/// <para>This overload will set the contact name to a specified value.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <param name="name">The new name you want to set.</param>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <returns>
|
||||||
|
/// A <see cref="Contact"/> object.
|
||||||
|
/// If the contact does not exist, create it.
|
||||||
|
/// </returns>
|
||||||
|
internal Contact GetContact(string account, string name, ClientType type)
|
||||||
|
{
|
||||||
|
Contact contact = GetContact(account, type);
|
||||||
|
|
||||||
|
lock (SyncRoot)
|
||||||
|
contact.SetName(name);
|
||||||
|
|
||||||
|
return contact;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a contact with specified account and client type, if the contact does not exist, create it.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account">Account (Mail) of a contact</param>
|
||||||
|
/// <param name="type">Contact type.</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A <see cref="Contact"/> object.
|
||||||
|
/// If the contact does not exist, create it.
|
||||||
|
/// </returns>
|
||||||
|
internal Contact GetContact(string account, ClientType type)
|
||||||
|
{
|
||||||
|
int hash = Contact.MakeHash(account, type, AddressBookId.ToString("D")).GetHashCode();
|
||||||
|
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
if (ContainsKey(hash))
|
||||||
|
{
|
||||||
|
return this[hash];
|
||||||
|
}
|
||||||
|
|
||||||
|
Contact tmpContact = new Contact(AddressBookId, account, type, 0, nsMessageHandler);
|
||||||
|
|
||||||
|
|
||||||
|
Add(hash, tmpContact);
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetContact(account, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Contact GetContactByGuid(Guid guid)
|
||||||
|
{
|
||||||
|
if (guid != Guid.Empty)
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
foreach (Contact contact in Values)
|
||||||
|
{
|
||||||
|
if (contact.Guid == guid)
|
||||||
|
return contact;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Contact GetContactByCID(long cid)
|
||||||
|
{
|
||||||
|
if (cid != 0)
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
foreach (Contact contact in Values)
|
||||||
|
{
|
||||||
|
if (contact.CID == cid)
|
||||||
|
return contact;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Contact this[string account]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetContact(account);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this[account, value.ClientType] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Contact this[string account, ClientType type]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return GetContact(account, type);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this[account, type] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check whether the specified account is in the contact list.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool HasContact(string account)
|
||||||
|
{
|
||||||
|
foreach (ClientType ct in clientTypes)
|
||||||
|
{
|
||||||
|
if (HasContact(account, ct))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check whether the account with specified client type is in the contact list.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool HasContact(string account, ClientType type)
|
||||||
|
{
|
||||||
|
return ContainsKey(Contact.MakeHash(account, type, AddressBookId.ToString("D")).GetHashCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyTo(Contact[] array, int index)
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
Values.CopyTo(array, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Copy the whole contact list out.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Contact[] ToArray()
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
Contact[] array = new Contact[Values.Count];
|
||||||
|
CopyTo(array, 0);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove all the contacts with the specified account.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
internal void Remove(string account)
|
||||||
|
{
|
||||||
|
foreach (ClientType ct in clientTypes)
|
||||||
|
{
|
||||||
|
if (HasContact(account, ct))
|
||||||
|
Remove(account, ct);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove a contact with specified account and client type.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
internal void Remove(string account, ClientType type)
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
Remove(Contact.MakeHash(account, type, AddressBookId.ToString("D")).GetHashCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set the owner for default addressbook. This funcation can be only called once.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="owner"></param>
|
||||||
|
internal void SetOwner(Owner owner)
|
||||||
|
{
|
||||||
|
if (AddressBookId != new Guid(WebServiceConstants.MessengerIndividualAddressBookId))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Only default addressbook can call this function.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Owner != null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Owner already set.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (owner.AddressBookId != new Guid(WebServiceConstants.MessengerIndividualAddressBookId))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Invalid owner: This is not the owner for default addressbook.");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasMultiType(string account)
|
||||||
|
{
|
||||||
|
int typecount = 0;
|
||||||
|
foreach (ClientType ct in clientTypes)
|
||||||
|
{
|
||||||
|
if (HasContact(account, ct) && ++typecount > 1)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reset the contact list and clear the owner.
|
||||||
|
/// </summary>
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
if (Owner != null)
|
||||||
|
{
|
||||||
|
Owner.Emoticons.Clear();
|
||||||
|
Owner.EndPointData.Clear();
|
||||||
|
Owner.LocalEndPointClientCapacities = ClientCapacities.None;
|
||||||
|
Owner.LocalEndPointClientCapacitiesEx = ClientCapacitiesEx.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
Clear();
|
||||||
|
owner = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
244
MSNPSharp/ContactManager.cs
Normal file
|
|
@ -0,0 +1,244 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MSNPSharp
|
||||||
|
{
|
||||||
|
internal sealed class ContactManager
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
private NSMessageHandler nsMessageHandler = null;
|
||||||
|
|
||||||
|
private Dictionary<string, Contact> defaultContactPage = new Dictionary<string, Contact>();
|
||||||
|
private Dictionary<string, Contact> otherContactPage = new Dictionary<string, Contact>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
internal NSMessageHandler NSMessageHandler
|
||||||
|
{
|
||||||
|
get { return nsMessageHandler; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
public ContactManager(NSMessageHandler handler)
|
||||||
|
{
|
||||||
|
nsMessageHandler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private functions
|
||||||
|
|
||||||
|
private string AddToDefaultContactPage(Contact contact)
|
||||||
|
{
|
||||||
|
string key = GetContactKey(contact);
|
||||||
|
if (contact.AddressBookId == new Guid(WebServiceConstants.MessengerIndividualAddressBookId))
|
||||||
|
{
|
||||||
|
|
||||||
|
lock (defaultContactPage)
|
||||||
|
defaultContactPage[key] = contact;
|
||||||
|
}
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DisplayImageChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Contact contact = sender as Contact;
|
||||||
|
if (contact == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SyncDisplayImage(contact);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string AddToOtherContactPage(Contact contact)
|
||||||
|
{
|
||||||
|
string key = GetContactKey(contact);
|
||||||
|
if (contact.AddressBookId != new Guid(WebServiceConstants.MessengerIndividualAddressBookId))
|
||||||
|
{
|
||||||
|
|
||||||
|
lock (otherContactPage)
|
||||||
|
{
|
||||||
|
if (!otherContactPage.ContainsKey(key))
|
||||||
|
{
|
||||||
|
otherContactPage[key] = contact;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
otherContactPage[key].AddSibling(contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NeedSync(key))
|
||||||
|
{
|
||||||
|
lock (defaultContactPage)
|
||||||
|
{
|
||||||
|
if (contact != defaultContactPage[key])
|
||||||
|
defaultContactPage[key].AddSibling(contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool NeedSync(Contact contact)
|
||||||
|
{
|
||||||
|
return NeedSync(GetContactKey(contact));
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool NeedSync(string key)
|
||||||
|
{
|
||||||
|
lock (defaultContactPage)
|
||||||
|
return defaultContactPage.ContainsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool Sync(string key)
|
||||||
|
{
|
||||||
|
lock (defaultContactPage)
|
||||||
|
{
|
||||||
|
if (!NeedSync(key))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Contact root = defaultContactPage[key];
|
||||||
|
|
||||||
|
if (root.Siblings.Count > 0)
|
||||||
|
{
|
||||||
|
SyncProperties(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public functions
|
||||||
|
|
||||||
|
public void SyncProperties(Contact root)
|
||||||
|
{
|
||||||
|
lock (root.SyncObject)
|
||||||
|
{
|
||||||
|
foreach (Contact sibling in root.Siblings.Values)
|
||||||
|
{
|
||||||
|
if (sibling == root)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sibling.SetList(root.Lists);
|
||||||
|
sibling.SetIsMessengerUser(root.IsMessengerUser);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SyncDisplayImage(Contact initator)
|
||||||
|
{
|
||||||
|
if (initator.AddressBookId == new Guid(WebServiceConstants.MessengerIndividualAddressBookId))
|
||||||
|
{
|
||||||
|
|
||||||
|
if (initator.Siblings.Count > 0)
|
||||||
|
{
|
||||||
|
lock (initator.SyncObject)
|
||||||
|
{
|
||||||
|
foreach (Contact sibling in initator.Siblings.Values)
|
||||||
|
{
|
||||||
|
if (sibling != initator)
|
||||||
|
sibling.DisplayImage = initator.DisplayImage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string key = GetContactKey(initator);
|
||||||
|
|
||||||
|
Contact root = null;
|
||||||
|
lock (otherContactPage)
|
||||||
|
{
|
||||||
|
if (!otherContactPage.ContainsKey(key))
|
||||||
|
return;
|
||||||
|
|
||||||
|
root = otherContactPage[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root.Siblings.Count > 0)
|
||||||
|
{
|
||||||
|
lock (root.SyncObject)
|
||||||
|
{
|
||||||
|
foreach (Contact sibling in root.Siblings.Values)
|
||||||
|
{
|
||||||
|
if (sibling != root)
|
||||||
|
sibling.DisplayImage = root.DisplayImage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(Contact contact)
|
||||||
|
{
|
||||||
|
string key = AddToDefaultContactPage(contact);
|
||||||
|
AddToOtherContactPage(contact);
|
||||||
|
contact.DisplayImageChanged += new EventHandler<DisplayImageChangedEventArgs>(DisplayImageChanged);
|
||||||
|
if (!NeedSync(key))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sync(key);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetContactKey(Contact contact)
|
||||||
|
{
|
||||||
|
return contact.ClientType.ToString().ToLowerInvariant() + ":" + contact.Mail.ToLowerInvariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
lock (defaultContactPage)
|
||||||
|
defaultContactPage.Clear();
|
||||||
|
lock (otherContactPage)
|
||||||
|
otherContactPage.Clear();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
1179
MSNPSharp/Conversation.cs
Normal file
200
MSNPSharp/ConversationID.cs
Normal file
|
|
@ -0,0 +1,200 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Utilities
|
||||||
|
{
|
||||||
|
public class ConversationID
|
||||||
|
{
|
||||||
|
private Conversation conversation = null;
|
||||||
|
private Contact remoteOwner = null;
|
||||||
|
|
||||||
|
private string hashString = string.Empty;
|
||||||
|
private string compareString = string.Empty;
|
||||||
|
private int hashCode = 0;
|
||||||
|
|
||||||
|
public Contact RemoteOwner
|
||||||
|
{
|
||||||
|
get { return remoteOwner; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Conversation Conversation
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return conversation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private object syncObject = new object();
|
||||||
|
|
||||||
|
internal void SetConversation(Conversation conv)
|
||||||
|
{
|
||||||
|
conversation = conv;
|
||||||
|
if (conversation != null)
|
||||||
|
{
|
||||||
|
if (conversation.RemoteOwner == null && RemoteOwner == null)
|
||||||
|
throw new ArgumentException("Invailid conversation.");
|
||||||
|
|
||||||
|
if (conversation.RemoteOwner != null)
|
||||||
|
remoteOwner = conversation.RemoteOwner;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientType NetworkType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!remoteOwner.IsMessengerUser)
|
||||||
|
return ClientType.None;
|
||||||
|
|
||||||
|
return remoteOwner.ClientType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConversationID(Conversation conversation)
|
||||||
|
{
|
||||||
|
if (conversation == null)
|
||||||
|
throw new ArgumentNullException("conversation is null.");
|
||||||
|
|
||||||
|
SetConversation(conversation);
|
||||||
|
|
||||||
|
hashString = ToString();
|
||||||
|
hashCode = hashString.GetHashCode();
|
||||||
|
|
||||||
|
|
||||||
|
conversation.ConversationEnded += delegate
|
||||||
|
{
|
||||||
|
lock (syncObject)
|
||||||
|
{
|
||||||
|
SetConversation(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
conversation.RemoteOwnerChanged += delegate(object sender, ConversationRemoteOwnerChangedEventArgs args)
|
||||||
|
{
|
||||||
|
lock (syncObject)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SetConversation(conversation);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "Remote owner changed to null.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConversationID(Contact remote)
|
||||||
|
{
|
||||||
|
if (remote == null)
|
||||||
|
throw new ArgumentNullException("remote is null.");
|
||||||
|
|
||||||
|
remoteOwner = remote;
|
||||||
|
hashString = ToString();
|
||||||
|
hashCode = hashString.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the two conversation are logically equals.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id1"></param>
|
||||||
|
/// <param name="other"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool operator ==(ConversationID id1, object other)
|
||||||
|
{
|
||||||
|
if (((object)id1 == null) && other == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (((object)id1) == null || other == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (other is ConversationID)
|
||||||
|
{
|
||||||
|
return id1.Equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (other is Conversation)
|
||||||
|
{
|
||||||
|
if (id1.conversation == null) return false;
|
||||||
|
return object.ReferenceEquals(id1.conversation, other);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator !=(ConversationID id1, object other)
|
||||||
|
{
|
||||||
|
return !(id1 == other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (object.ReferenceEquals(this, obj))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!(obj is ConversationID))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return ToString() == obj.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string remoteOwnerString = (remoteOwner == null ? "null" : remoteOwner.Mail.ToLowerInvariant());
|
||||||
|
string conversationString = string.Empty;
|
||||||
|
if (conversation != null)
|
||||||
|
{
|
||||||
|
if ((conversation.Type & ConversationType.MutipleUsers) > 0)
|
||||||
|
{
|
||||||
|
conversationString = conversation.Switchboard.SessionHash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return string.Join(";", new string[] { NetworkType.ToString().ToLowerInvariant(), remoteOwnerString, conversationString });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
267
MSNPSharp/Core/BitUtility.cs
Normal file
|
|
@ -0,0 +1,267 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
public static class BitUtility
|
||||||
|
{
|
||||||
|
public static short ToInt16(byte[] data, int startIndex, bool dataIsLittleEndian)
|
||||||
|
{
|
||||||
|
if (BitConverter.IsLittleEndian == dataIsLittleEndian)
|
||||||
|
{
|
||||||
|
return BitConverter.ToInt16(data, startIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BitConverter.ToInt16(GetSwappedByteArray(data, startIndex, 2), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ushort ToUInt16(byte[] data, int startIndex, bool dataIsLittleEndian)
|
||||||
|
{
|
||||||
|
if (BitConverter.IsLittleEndian == dataIsLittleEndian)
|
||||||
|
{
|
||||||
|
return BitConverter.ToUInt16(data, startIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BitConverter.ToUInt16(GetSwappedByteArray(data, startIndex, 2), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int ToInt32(byte[] data, int startIndex, bool dataIsLittleEndian)
|
||||||
|
{
|
||||||
|
if (BitConverter.IsLittleEndian == dataIsLittleEndian)
|
||||||
|
{
|
||||||
|
return BitConverter.ToInt32(data, startIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BitConverter.ToInt32(GetSwappedByteArray(data, startIndex, 4), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static uint ToUInt32(byte[] data, int startIndex, bool dataIsLittleEndian)
|
||||||
|
{
|
||||||
|
if (BitConverter.IsLittleEndian == dataIsLittleEndian)
|
||||||
|
{
|
||||||
|
return BitConverter.ToUInt32(data, startIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BitConverter.ToUInt32(GetSwappedByteArray(data, startIndex, 4), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long ToInt64(byte[] data, int startIndex, bool dataIsLittleEndian)
|
||||||
|
{
|
||||||
|
if (BitConverter.IsLittleEndian == dataIsLittleEndian)
|
||||||
|
{
|
||||||
|
return BitConverter.ToInt64(data, startIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BitConverter.ToInt64(GetSwappedByteArray(data, startIndex, 8), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ulong ToUInt64(byte[] data, int startIndex, bool dataIsLittleEndian)
|
||||||
|
{
|
||||||
|
if (BitConverter.IsLittleEndian == dataIsLittleEndian)
|
||||||
|
{
|
||||||
|
return BitConverter.ToUInt64(data, startIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BitConverter.ToUInt64(GetSwappedByteArray(data, startIndex, 8), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static byte[] GetBytes(short val, bool littleEndian)
|
||||||
|
{
|
||||||
|
byte[] bytes = BitConverter.GetBytes(val);
|
||||||
|
|
||||||
|
if (BitConverter.IsLittleEndian == littleEndian)
|
||||||
|
return bytes;
|
||||||
|
|
||||||
|
return GetSwappedByteArray(bytes, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] GetBytes(ushort val, bool littleEndian)
|
||||||
|
{
|
||||||
|
byte[] bytes = BitConverter.GetBytes(val);
|
||||||
|
|
||||||
|
if (BitConverter.IsLittleEndian == littleEndian)
|
||||||
|
return bytes;
|
||||||
|
|
||||||
|
return GetSwappedByteArray(bytes, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] GetBytes(int val, bool littleEndian)
|
||||||
|
{
|
||||||
|
byte[] bytes = BitConverter.GetBytes(val);
|
||||||
|
|
||||||
|
if (BitConverter.IsLittleEndian == littleEndian)
|
||||||
|
return bytes;
|
||||||
|
|
||||||
|
return GetSwappedByteArray(bytes, 0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] GetBytes(uint val, bool littleEndian)
|
||||||
|
{
|
||||||
|
byte[] bytes = BitConverter.GetBytes(val);
|
||||||
|
|
||||||
|
if (BitConverter.IsLittleEndian == littleEndian)
|
||||||
|
return bytes;
|
||||||
|
|
||||||
|
return GetSwappedByteArray(bytes, 0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] GetBytes(long val, bool littleEndian)
|
||||||
|
{
|
||||||
|
byte[] bytes = BitConverter.GetBytes(val);
|
||||||
|
|
||||||
|
if (BitConverter.IsLittleEndian == littleEndian)
|
||||||
|
return bytes;
|
||||||
|
|
||||||
|
return GetSwappedByteArray(bytes, 0, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] GetBytes(ulong val, bool littleEndian)
|
||||||
|
{
|
||||||
|
byte[] bytes = BitConverter.GetBytes(val);
|
||||||
|
|
||||||
|
if (BitConverter.IsLittleEndian == littleEndian)
|
||||||
|
return bytes;
|
||||||
|
|
||||||
|
return GetSwappedByteArray(bytes, 0, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] GetSwappedByteArray(byte[] data, int startIndex, int length)
|
||||||
|
{
|
||||||
|
byte[] swap = new byte[length];
|
||||||
|
int endIndex = 0;
|
||||||
|
while (--length >= 0)
|
||||||
|
{
|
||||||
|
swap[length] = data[startIndex + endIndex];
|
||||||
|
endIndex++;
|
||||||
|
}
|
||||||
|
return swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static ushort ToLittleEndian(ushort val)
|
||||||
|
{
|
||||||
|
if (BitConverter.IsLittleEndian)
|
||||||
|
return val;
|
||||||
|
|
||||||
|
return FlipEndian(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static uint ToLittleEndian(uint val)
|
||||||
|
{
|
||||||
|
if (BitConverter.IsLittleEndian)
|
||||||
|
return val;
|
||||||
|
|
||||||
|
return FlipEndian(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ulong ToLittleEndian(ulong val)
|
||||||
|
{
|
||||||
|
if (BitConverter.IsLittleEndian)
|
||||||
|
return val;
|
||||||
|
|
||||||
|
return FlipEndian(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ushort ToBigEndian(ushort val)
|
||||||
|
{
|
||||||
|
if (!BitConverter.IsLittleEndian)
|
||||||
|
return val;
|
||||||
|
|
||||||
|
return FlipEndian(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static uint ToBigEndian(uint val)
|
||||||
|
{
|
||||||
|
if (!BitConverter.IsLittleEndian)
|
||||||
|
return val;
|
||||||
|
|
||||||
|
return FlipEndian(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ulong ToBigEndian(ulong val)
|
||||||
|
{
|
||||||
|
if (!BitConverter.IsLittleEndian)
|
||||||
|
return val;
|
||||||
|
|
||||||
|
return FlipEndian(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ushort FlipEndian(ushort val)
|
||||||
|
{
|
||||||
|
return (ushort)
|
||||||
|
(((val & 0x00ff) << 8) +
|
||||||
|
((val & 0xff00) >> 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static uint FlipEndian(uint val)
|
||||||
|
{
|
||||||
|
return (uint)
|
||||||
|
(((val & 0x000000ff) << 24) +
|
||||||
|
((val & 0x0000ff00) << 8) +
|
||||||
|
((val & 0x00ff0000) >> 8) +
|
||||||
|
((val & 0xff000000) >> 24));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ulong FlipEndian(ulong val)
|
||||||
|
{
|
||||||
|
return (ulong)
|
||||||
|
(((val & 0x00000000000000ff) << 56) +
|
||||||
|
((val & 0x000000000000ff00) << 40) +
|
||||||
|
((val & 0x0000000000ff0000) << 24) +
|
||||||
|
((val & 0x00000000ff000000) << 8) +
|
||||||
|
((val & 0x000000ff00000000) >> 8) +
|
||||||
|
((val & 0x0000ff0000000000) >> 24) +
|
||||||
|
((val & 0x00ff000000000000) >> 40) +
|
||||||
|
((val & 0xff00000000000000) >> 56));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
458
MSNPSharp/Core/Converter.cs
Normal file
|
|
@ -0,0 +1,458 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Web;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
using MSNPSharp.DataTransfer;
|
||||||
|
|
||||||
|
internal enum EscapeType
|
||||||
|
{
|
||||||
|
EscapeAll,
|
||||||
|
EscapeExceptPlus
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides methods for encoding and decoding URLs when processing Web requests. This class cannot be inherited.
|
||||||
|
/// </summary>
|
||||||
|
public static class MSNHttpUtility
|
||||||
|
{
|
||||||
|
private enum UnSafe
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// For url encode
|
||||||
|
/// </summary>
|
||||||
|
UrlEscape = 0x1,
|
||||||
|
/// <summary>
|
||||||
|
/// For XML encode
|
||||||
|
/// </summary>
|
||||||
|
XMLEscape = 0x2,
|
||||||
|
/// <summary>
|
||||||
|
/// For HTML encode
|
||||||
|
/// </summary>
|
||||||
|
HTMLEscape = 0x4
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint[] ASCII_CLASS;
|
||||||
|
private static string strUrlUnsafe = " \"#%&+,/:;<=>?@[\\]^`{|}";
|
||||||
|
private static string strXmlUnsafe = "&:;<=>?[]\\^{|}";
|
||||||
|
private static string strHtmlUnsafe = "&'<> ;\"";
|
||||||
|
|
||||||
|
static MSNHttpUtility()
|
||||||
|
{
|
||||||
|
ASCII_CLASS = new uint[256];
|
||||||
|
int c = 0;
|
||||||
|
for (c = 0; c < ASCII_CLASS.Length; c++)
|
||||||
|
{
|
||||||
|
if ((c >= 0 && c <= 32) || c >= 126)
|
||||||
|
{
|
||||||
|
ASCII_CLASS[c] |= (uint)UnSafe.UrlEscape;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c >= 0 && c <= 32)
|
||||||
|
{
|
||||||
|
ASCII_CLASS[c] |= (uint)UnSafe.XMLEscape;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strUrlUnsafe.IndexOf((char)c) != -1)
|
||||||
|
{
|
||||||
|
ASCII_CLASS[c] |= (uint)UnSafe.UrlEscape;
|
||||||
|
}
|
||||||
|
if (strXmlUnsafe.IndexOf((char)c) != -1)
|
||||||
|
{
|
||||||
|
ASCII_CLASS[c] |= (uint)UnSafe.XMLEscape;
|
||||||
|
}
|
||||||
|
if (strHtmlUnsafe.IndexOf((char)c) != -1)
|
||||||
|
{
|
||||||
|
ASCII_CLASS[c] |= (uint)UnSafe.HTMLEscape;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Encodes a MSNObject description using UTF-8 encoding by default.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The MSNObject description to encode.</param>
|
||||||
|
/// <returns>An encoded string.</returns>
|
||||||
|
public static string MSNObjectUrlEncode(string str)
|
||||||
|
{
|
||||||
|
return UrlEncode(str, Encoding.UTF8, EscapeType.EscapeExceptPlus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replace space into %20.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The string to encode.</param>
|
||||||
|
/// <returns>An encoded string.</returns>
|
||||||
|
public static string NSEncode(string str)
|
||||||
|
{
|
||||||
|
return str.Replace(" ", "%20");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Encodes a URL string using UTF-8 encoding by default.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The text to encode.</param>
|
||||||
|
/// <returns>An encoded string.</returns>
|
||||||
|
public static string UrlEncode(string str)
|
||||||
|
{
|
||||||
|
return UrlEncode(str, Encoding.UTF8, EscapeType.EscapeAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Encodes a URL string using the specified encoding object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The text to encode.</param>
|
||||||
|
/// <param name="e">The <see cref="Encoding"/> object that specifies the encoding scheme. </param>
|
||||||
|
/// <returns>An encoded string.</returns>
|
||||||
|
public static string UrlEncode(string str, Encoding e)
|
||||||
|
{
|
||||||
|
return UrlEncode(str, e, EscapeType.EscapeAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string UrlEncode(string str, Encoding e, EscapeType type)
|
||||||
|
{
|
||||||
|
if (str == null)
|
||||||
|
return string.Empty;
|
||||||
|
byte[] byt = e.GetBytes(str);
|
||||||
|
StringBuilder result = new StringBuilder(256);
|
||||||
|
for (int c = 0; c < byt.Length; c++)
|
||||||
|
{
|
||||||
|
byte chr = byt[c];
|
||||||
|
if ((ASCII_CLASS[chr] & (uint)UnSafe.UrlEscape) != 0)
|
||||||
|
{
|
||||||
|
switch (chr)
|
||||||
|
{
|
||||||
|
case (byte)'+':
|
||||||
|
if (type == EscapeType.EscapeAll)
|
||||||
|
{
|
||||||
|
result.Append("%20");
|
||||||
|
}
|
||||||
|
else if (type == EscapeType.EscapeExceptPlus)
|
||||||
|
{
|
||||||
|
result.Append("%2B");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result.Append("%" + ((int)chr).ToString("X2"));
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result.Append((char)chr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Decode an encoded <see cref="MSNObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The encoded MSNObject description.</param>
|
||||||
|
/// <returns>A decoded string.</returns>
|
||||||
|
public static string MSNObjectUrlDecode(string str)
|
||||||
|
{
|
||||||
|
return UrlDecode(str, Encoding.UTF8, EscapeType.EscapeExceptPlus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a string that has been encoded for transmission in a URL into a decoded string using UTF-8 encoding by default.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The string to decode.</param>
|
||||||
|
/// <returns>A decoded string.</returns>
|
||||||
|
public static string UrlDecode(string str)
|
||||||
|
{
|
||||||
|
return UrlDecode(str, Encoding.UTF8, EscapeType.EscapeAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a URL-encoded string into a decoded string, using the specified encoding object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The string to decode.</param>
|
||||||
|
/// <param name="e">The <see cref="Encoding"/> that specifies the decoding scheme.</param>
|
||||||
|
/// <returns>A decoded string.</returns>
|
||||||
|
public static string UrlDecode(string str, Encoding e)
|
||||||
|
{
|
||||||
|
return UrlDecode(str, e, EscapeType.EscapeAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Replace "%20" into space.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The string to decode.</param>
|
||||||
|
/// <returns>A decoded string.</returns>
|
||||||
|
public static string NSDecode(string str)
|
||||||
|
{
|
||||||
|
return str.Replace("%20", " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string UrlDecode(string str, Encoding e, EscapeType type)
|
||||||
|
{
|
||||||
|
if (type == EscapeType.EscapeExceptPlus)
|
||||||
|
{
|
||||||
|
return HttpUtility.UrlDecode(str.Replace("%2b", "+").Replace("%2B", "+"), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return HttpUtility.UrlDecode(str.Replace("%20", "+"), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Encodes a Xml string.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The string to decode.</param>
|
||||||
|
/// <returns>A decoded string.</returns>
|
||||||
|
public static string XmlEncode(string str)
|
||||||
|
{
|
||||||
|
if (str == null)
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
char[] chrArr = str.ToCharArray();
|
||||||
|
char chr;
|
||||||
|
StringBuilder result = new StringBuilder(256);
|
||||||
|
for (int c = 0; c < chrArr.Length; c++)
|
||||||
|
{
|
||||||
|
chr = chrArr[c];
|
||||||
|
|
||||||
|
if (chr < 128)
|
||||||
|
{
|
||||||
|
if ((ASCII_CLASS[chr] & (uint)UnSafe.XMLEscape) != 0)
|
||||||
|
{
|
||||||
|
result.Append("&#x" + ((int)chr).ToString("X2") + ";");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Append(chr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Decode the QP encoded string.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">The string to decode.</param>
|
||||||
|
/// <returns>A decoded string.</returns>
|
||||||
|
public static string QPDecode(string str)
|
||||||
|
{
|
||||||
|
return QPDecode(str, Encoding.Default);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Decode the QP encoded string using an encoding
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The string to decode.</param>
|
||||||
|
/// <param name="encode">The <see cref="Encoding"/> that specifies the decoding scheme.</param>
|
||||||
|
/// <returns>A decoded string.</returns>
|
||||||
|
public static string QPDecode(string value, Encoding encode)
|
||||||
|
{
|
||||||
|
string inputString = value;
|
||||||
|
StringBuilder builder1 = new StringBuilder();
|
||||||
|
inputString = inputString.Replace("=\r\n", "");
|
||||||
|
for (int num1 = 0; num1 < inputString.Length; num1++)
|
||||||
|
{
|
||||||
|
if (inputString[num1] == '=')
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (HexToDec(inputString.Substring(num1 + 1, 2)) < 0x80)
|
||||||
|
{
|
||||||
|
if (HexToDec(inputString.Substring(num1 + 1, 2)) >= 0)
|
||||||
|
{
|
||||||
|
byte[] buffer1 = new byte[1] { (byte)HexToDec(inputString.Substring(num1 + 1, 2)) };
|
||||||
|
builder1.Append(encode.GetString(buffer1));
|
||||||
|
num1 += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (inputString[num1 + 1] != '=')
|
||||||
|
{
|
||||||
|
byte[] buffer2 = new byte[2] { (byte)HexToDec(inputString.Substring(num1 + 1, 2)), (byte)HexToDec(inputString.Substring(num1 + 4, 2)) };
|
||||||
|
builder1.Append(encode.GetString(buffer2));
|
||||||
|
num1 += 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
builder1.Append(inputString.Substring(num1, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder1.Append(inputString.Substring(num1, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder1.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int HexToDec(string hex)
|
||||||
|
{
|
||||||
|
int num1 = 0;
|
||||||
|
string text1 = "0123456789ABCDEF";
|
||||||
|
for (int num2 = 0; num2 < hex.Length; num2++)
|
||||||
|
{
|
||||||
|
if (text1.IndexOf(hex[num2]) == -1)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
num1 = (num1 * 0x10) + text1.IndexOf(hex[num2]);
|
||||||
|
}
|
||||||
|
return num1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static int IndexOf(byte[] input, byte[] pattern)
|
||||||
|
{
|
||||||
|
if (pattern.Length > input.Length)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (int i = 0; i <= input.Length - pattern.Length; i++)
|
||||||
|
{
|
||||||
|
bool found = true;
|
||||||
|
|
||||||
|
for (int j = 0; j < pattern.Length; j++)
|
||||||
|
{
|
||||||
|
if (input[i + j] != pattern[j])
|
||||||
|
{
|
||||||
|
found = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int IndexOf(byte[] input, string pattern)
|
||||||
|
{
|
||||||
|
return IndexOf(input, Encoding.UTF8.GetBytes(pattern));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class WebServiceDateTimeConverter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Convert the XML time to .net <see cref="DateTime"/> instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dateTime"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DateTime ConvertToDateTime(string dateTime)
|
||||||
|
{
|
||||||
|
if (dateTime == null || dateTime == string.Empty)
|
||||||
|
dateTime = WebServiceConstants.ZeroTime;
|
||||||
|
|
||||||
|
return XmlConvert.ToDateTime(dateTime, WebServiceConstants.XmlDateTimeFormats);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class HashedNonceGenerator
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates handshake guid using SHA1 hash algorithm.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="nonce"></param>
|
||||||
|
/// <returns>The output packed to handshake for direct connect</returns>
|
||||||
|
public static Guid HashNonce(Guid nonce)
|
||||||
|
{
|
||||||
|
// http://forums.fanatic.net.nz/index.php?showtopic=19372&view=findpost&p=108868
|
||||||
|
// {2B95F56D-9CA0-9A64-82CE-ADC1F3C55845} <-> [0x37,0x29,0x2d,0x12,0x86,0x5c,0x7b,0x4c,0x81,0xf5,0xe,0x5,0x1,0x78,0x80,0xc2]
|
||||||
|
// OUTPUT: 2b95f56d-9ca0-9a64-82ce-adc1f3c55845
|
||||||
|
// INPUT: 122d2937-5c86-4c7b-81f5-0e05017880c2
|
||||||
|
|
||||||
|
Guid handshakeNonce = Guid.Empty;
|
||||||
|
|
||||||
|
using (SHA1Managed sha1 = new SHA1Managed())
|
||||||
|
{
|
||||||
|
// Returns 20 bytes
|
||||||
|
byte[] hash = sha1.ComputeHash(nonce.ToByteArray());
|
||||||
|
|
||||||
|
handshakeNonce = CreateGuidFromData(P2PVersion.P2PV2, hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
return handshakeNonce;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Guid CreateGuidFromData(P2PVersion ver, byte[] data)
|
||||||
|
{
|
||||||
|
Guid ret = Guid.Empty;
|
||||||
|
|
||||||
|
if (ver == P2PVersion.P2PV1)
|
||||||
|
{
|
||||||
|
P2PMessage message = new P2PMessage(ver);
|
||||||
|
message.ParseBytes(data);
|
||||||
|
|
||||||
|
ret = new Guid(
|
||||||
|
(int)message.V1Header.AckSessionId,
|
||||||
|
|
||||||
|
(short)(message.Header.AckIdentifier & 0x0000FFFF),
|
||||||
|
(short)((message.Header.AckIdentifier & 0xFFFF0000) >> 16),
|
||||||
|
|
||||||
|
(byte)((message.V1Header.AckTotalSize & 0x00000000000000FF)),
|
||||||
|
(byte)((message.V1Header.AckTotalSize & 0x000000000000FF00) >> 8),
|
||||||
|
(byte)((message.V1Header.AckTotalSize & 0x0000000000FF0000) >> 16),
|
||||||
|
(byte)((message.V1Header.AckTotalSize & 0x00000000FF000000) >> 24),
|
||||||
|
(byte)((message.V1Header.AckTotalSize & 0x000000FF00000000) >> 32),
|
||||||
|
(byte)((message.V1Header.AckTotalSize & 0x0000FF0000000000) >> 40),
|
||||||
|
(byte)((message.V1Header.AckTotalSize & 0x00FF000000000000) >> 48),
|
||||||
|
(byte)((message.V1Header.AckTotalSize & 0xFF00000000000000) >> 56)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (ver == P2PVersion.P2PV2)
|
||||||
|
{
|
||||||
|
Int32 a = BitUtility.ToInt32(data, 0, BitConverter.IsLittleEndian);
|
||||||
|
Int16 b = BitUtility.ToInt16(data, 4, BitConverter.IsLittleEndian);
|
||||||
|
Int16 c = BitUtility.ToInt16(data, 6, BitConverter.IsLittleEndian);
|
||||||
|
byte d = data[8], e = data[9], f = data[10], g = data[11];
|
||||||
|
byte h = data[12], i = data[13], j = data[14], k = data[15];
|
||||||
|
|
||||||
|
ret = new Guid(a, b, c, d, e, f, g, h, i, j, k);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
64
MSNPSharp/Core/IMessageHandler.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// IMessageHandler defines the methods required to handle incoming network messages.
|
||||||
|
/// </summary>
|
||||||
|
public interface IMessageHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the processor of network messages.
|
||||||
|
/// Every message handler is associated with a single message processor.
|
||||||
|
/// This way the handler can initiate, or send, messages which are not a reply
|
||||||
|
/// on incoming messages.
|
||||||
|
/// </summary>
|
||||||
|
IMessageProcessor MessageProcessor
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A IMessageProcessor calls this method. The handler can then process the
|
||||||
|
/// message.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
void HandleMessage(IMessageProcessor sender, NetworkMessage message);
|
||||||
|
}
|
||||||
|
};
|
||||||
254
MSNPSharp/Core/MSNMessage.cs
Normal file
|
|
@ -0,0 +1,254 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
|
||||||
|
[Serializable()]
|
||||||
|
public class MSNMessage : NetworkMessage, ICloneable
|
||||||
|
{
|
||||||
|
protected int transactionID = -1;
|
||||||
|
private string command = "MSG";
|
||||||
|
private ArrayList commandValues;
|
||||||
|
private const string noTransactionIDCommands = "OUT PNG QNG RNG";
|
||||||
|
|
||||||
|
public MSNMessage()
|
||||||
|
{
|
||||||
|
commandValues = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MSNMessage(string command, ArrayList commandValues)
|
||||||
|
{
|
||||||
|
Command = command;
|
||||||
|
CommandValues = commandValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void PrepareMessage()
|
||||||
|
{
|
||||||
|
base.PrepareMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int TransactionID
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return transactionID;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
transactionID = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Command
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
command = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList CommandValues
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return commandValues;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
commandValues = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] GetBytes()
|
||||||
|
{
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder(128);
|
||||||
|
builder.Append(Command);
|
||||||
|
|
||||||
|
if (noTransactionIDCommands.IndexOf(Command) == -1)
|
||||||
|
{
|
||||||
|
if (TransactionID != -1)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(TransactionID.ToString(CultureInfo.InvariantCulture));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string val in CommandValues)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (InnerMessage != null)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(InnerMessage.GetBytes().Length);
|
||||||
|
builder.Append("\r\n");
|
||||||
|
return AppendArray(System.Text.Encoding.UTF8.GetBytes(builder.ToString()), InnerMessage.GetBytes());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.Append("\r\n");
|
||||||
|
return System.Text.Encoding.UTF8.GetBytes(builder.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ParseBytes(byte[] data)
|
||||||
|
{
|
||||||
|
|
||||||
|
int cnt = 0;
|
||||||
|
int bodyStart = 0;
|
||||||
|
|
||||||
|
while (data[cnt] != '\r')
|
||||||
|
{
|
||||||
|
cnt++;
|
||||||
|
|
||||||
|
// watch out for buffer overflow
|
||||||
|
if (cnt == data.Length)
|
||||||
|
throw new MSNPSharpException("Parsing of incoming command message failed. No newline was detected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
bodyStart = cnt + 1;
|
||||||
|
while (bodyStart < data.Length && (data[bodyStart] == '\r' || data[bodyStart] == '\n'))
|
||||||
|
{
|
||||||
|
bodyStart++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the command parameters
|
||||||
|
Command = System.Text.Encoding.UTF8.GetString(data, 0, 3);
|
||||||
|
string commandLine = Encoding.UTF8.GetString(data, 4, cnt - 4);
|
||||||
|
CommandValues = new ArrayList(commandLine.Split(new char[] { ' ' }));
|
||||||
|
|
||||||
|
|
||||||
|
//Filter those commands follow by a number but not transaction id.
|
||||||
|
if (noTransactionIDCommands.IndexOf(Command) == -1)
|
||||||
|
{
|
||||||
|
if (CommandValues.Count > 0)
|
||||||
|
{
|
||||||
|
if (!int.TryParse((string)CommandValues[0], out transactionID))
|
||||||
|
{
|
||||||
|
transactionID = -1; //if there's no transid, set to -1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CommandValues.RemoveAt(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the inner body contents, if it is available
|
||||||
|
if (bodyStart < data.Length)
|
||||||
|
{
|
||||||
|
if (CommandValues.Count > 0)
|
||||||
|
{
|
||||||
|
CommandValues.RemoveAt(CommandValues.Count - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int startIndex = bodyStart;
|
||||||
|
int newLength = data.Length - startIndex;
|
||||||
|
InnerBody = new byte[newLength];
|
||||||
|
Array.Copy(data, startIndex, InnerBody, 0, newLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the debug string representation of the message
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <remarks>
|
||||||
|
/// To futher developers:
|
||||||
|
/// You cannot simply apply Encoding.UTF8.GetString(GetByte()) in this function
|
||||||
|
/// since the InnerMessage of MSNMessage may contain binary data.
|
||||||
|
/// </remarks>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder(128);
|
||||||
|
builder.Append(Command);
|
||||||
|
|
||||||
|
|
||||||
|
if (noTransactionIDCommands.IndexOf(Command) == -1)
|
||||||
|
{
|
||||||
|
if (TransactionID != -1)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(TransactionID.ToString(CultureInfo.InvariantCulture));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach (string val in CommandValues)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (InnerMessage != null)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(InnerMessage.GetBytes().Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
//For toString, we do not return the inner message's string.
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region ICloneable Member
|
||||||
|
|
||||||
|
object ICloneable.Clone()
|
||||||
|
{
|
||||||
|
MSNMessage messageClone = new MSNMessage();
|
||||||
|
messageClone.ParseBytes(GetBytes());
|
||||||
|
return messageClone;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
};
|
||||||
78
MSNPSharp/Core/MessagePool.cs
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stores incoming messages in a buffer and releases them only when all contents are received.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// MessagePool buffers incoming raw byte data and releases this data only when the message is fully retrieved.
|
||||||
|
/// This supports when a single message is send in multiple packets.
|
||||||
|
/// The descendants of this class have simple knowledge of the used protocol to identify whether a message is fully retrieved or not.
|
||||||
|
/// </remarks>
|
||||||
|
public abstract class MessagePool
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor to instantiate a message pool.
|
||||||
|
/// </summary>
|
||||||
|
protected MessagePool()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines whether there is a message available to retrieve.
|
||||||
|
/// </summary>
|
||||||
|
public abstract bool MessageAvailable
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Buffers the incoming raw data internal. This method is often used after receiving incoming data from a socket or another source.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader"></param>
|
||||||
|
public abstract void BufferData(BinaryReader reader);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the next message data from the buffer.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public abstract byte[] GetNextMessageData();
|
||||||
|
}
|
||||||
|
};
|
||||||
69
MSNPSharp/Core/MessageProcessor.cs
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines methods to send network messages.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// IMessageProcessor is the abstraction of an object which can send network messages.
|
||||||
|
/// Network messages can be any kind of messages: text messages, data messages.
|
||||||
|
/// By using this interface a de-coupling is established between the handling of messages
|
||||||
|
/// and the I/O of messages.
|
||||||
|
/// IMessageProcessor is mostly used internal.
|
||||||
|
/// </remarks>
|
||||||
|
public interface IMessageProcessor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Sends a message to be processed by the processor.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
void SendMessage(NetworkMessage message);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers a handler that wants to receive incoming messages.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="handler"></param>
|
||||||
|
void RegisterHandler(IMessageHandler handler);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unregisters (removes) a handler that no lange wants to receive incoming messages.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="handler"></param>
|
||||||
|
void UnregisterHandler(IMessageHandler handler);
|
||||||
|
}
|
||||||
|
};
|
||||||
236
MSNPSharp/Core/MimeDictionary.cs
Normal file
|
|
@ -0,0 +1,236 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
public class MimeDictionary : SortedList<string, MimeValue>
|
||||||
|
{
|
||||||
|
public new MimeValue this[string name]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!ContainsKey(name))
|
||||||
|
return new MimeValue();
|
||||||
|
|
||||||
|
return (MimeValue)base[name];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base[name] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MimeDictionary()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public MimeDictionary(byte[] data)
|
||||||
|
{
|
||||||
|
Parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Parse(byte[] data)
|
||||||
|
{
|
||||||
|
int end = MSNHttpUtility.IndexOf(data, "\r\n\r\n");
|
||||||
|
int ret = end;
|
||||||
|
|
||||||
|
if (end < 0)
|
||||||
|
ret = end = data.Length;
|
||||||
|
else
|
||||||
|
ret += 4;
|
||||||
|
|
||||||
|
byte[] mimeData = new byte[end];
|
||||||
|
Array.Copy(data, mimeData, end);
|
||||||
|
|
||||||
|
string mimeStr = Encoding.UTF8.GetString(mimeData);
|
||||||
|
string[] lines = mimeStr.Trim().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while (i < lines.Length)
|
||||||
|
{
|
||||||
|
string line = lines[i];
|
||||||
|
|
||||||
|
while ((++i < lines.Length) && lines[i].StartsWith("\t"))
|
||||||
|
line += lines[i];
|
||||||
|
|
||||||
|
int nameEnd = line.IndexOf(":");
|
||||||
|
|
||||||
|
if (nameEnd < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string name = line.Substring(0, nameEnd).Trim();
|
||||||
|
MimeValue val = line.Substring(nameEnd + 1).Trim();
|
||||||
|
|
||||||
|
this[name] = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, MimeValue> pair in this)
|
||||||
|
{
|
||||||
|
sb.Append(pair.Key).Append(": ").Append(pair.Value.ToString()).Append("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MimeValue
|
||||||
|
{
|
||||||
|
string _val;
|
||||||
|
SortedList<object, string> _attributes = new SortedList<object, string>();
|
||||||
|
|
||||||
|
public string Value
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MimeValue(string main, SortedList<object, string> attributes)
|
||||||
|
{
|
||||||
|
if (attributes == null)
|
||||||
|
throw new ArgumentNullException("attributes");
|
||||||
|
|
||||||
|
_val = main;
|
||||||
|
_attributes = attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MimeValue(string main)
|
||||||
|
{
|
||||||
|
_val = main;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MimeValue()
|
||||||
|
{
|
||||||
|
_val = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string this[object attKey]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!_attributes.ContainsKey(attKey))
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
return _attributes[attKey].ToString();
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_attributes[attKey] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator string(MimeValue val)
|
||||||
|
{
|
||||||
|
return val.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator MimeValue(string str)
|
||||||
|
{
|
||||||
|
if (str == null)
|
||||||
|
str = string.Empty;
|
||||||
|
|
||||||
|
str = str.Trim();
|
||||||
|
|
||||||
|
string main = str;
|
||||||
|
SortedList<object, string> attributes = new SortedList<object, string>();
|
||||||
|
|
||||||
|
if (main.Contains(";"))
|
||||||
|
{
|
||||||
|
main = main.Substring(0, main.IndexOf(";")).Trim();
|
||||||
|
str = str.Substring(str.IndexOf(";") + 1);
|
||||||
|
|
||||||
|
string[] parameters = str.Split(';');
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
foreach (string param in parameters)
|
||||||
|
{
|
||||||
|
int index = param.IndexOf('=');
|
||||||
|
|
||||||
|
object key = i++;
|
||||||
|
string val = param; //string.Empty;
|
||||||
|
|
||||||
|
if (index > 0)
|
||||||
|
{
|
||||||
|
key = param.Substring(0, index).Trim();
|
||||||
|
val = param.Substring(index + 1).Trim();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes[key] = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new MimeValue(main, attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClearAttributes()
|
||||||
|
{
|
||||||
|
_attributes.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasAttribute(string name)
|
||||||
|
{
|
||||||
|
return _attributes.ContainsKey(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string str = _val;
|
||||||
|
|
||||||
|
foreach (KeyValuePair<object, string> att in _attributes)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(str))
|
||||||
|
str += ";";
|
||||||
|
|
||||||
|
str += (att.Key is int) ? att.Value : String.Format("{0}={1}", att.Key, att.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return str.Trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
193
MSNPSharp/Core/MimeMessage.cs
Normal file
|
|
@ -0,0 +1,193 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
using MSNPSharp.DataTransfer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Message with MIME headers.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable()]
|
||||||
|
public class MimeMessage : NetworkMessage
|
||||||
|
{
|
||||||
|
StrDictionary mimeHeader;
|
||||||
|
|
||||||
|
public MimeMessage()
|
||||||
|
{
|
||||||
|
mimeHeader = new StrDictionary();
|
||||||
|
MimeHeader.Add("MIME-Version", "1.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
public MimeMessage(bool autoAppendHeaderVersion)
|
||||||
|
{
|
||||||
|
mimeHeader = new StrDictionary();
|
||||||
|
|
||||||
|
if (autoAppendHeaderVersion)
|
||||||
|
MimeHeader.Add("MIME-Version", "1.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
public StrDictionary MimeHeader
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mimeHeader;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] GetBytes()
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
foreach (StrKeyValuePair entry in MimeHeader)
|
||||||
|
builder.Append(entry.Key).Append(": ").Append(entry.Value).Append("\r\n");
|
||||||
|
|
||||||
|
builder.Append("\r\n");
|
||||||
|
|
||||||
|
if (InnerMessage != null)
|
||||||
|
return AppendArray(System.Text.Encoding.UTF8.GetBytes(builder.ToString()), InnerMessage.GetBytes());
|
||||||
|
|
||||||
|
return System.Text.Encoding.UTF8.GetBytes(builder.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static StrDictionary ParseMime(IEnumerator enumerator, byte[] data)
|
||||||
|
{
|
||||||
|
StrDictionary table = new StrDictionary();
|
||||||
|
|
||||||
|
string name = null;
|
||||||
|
string val = null;
|
||||||
|
|
||||||
|
int startpos = 0;
|
||||||
|
int endpos = 0;
|
||||||
|
bool gettingval = false;
|
||||||
|
|
||||||
|
while (enumerator.MoveNext())
|
||||||
|
{
|
||||||
|
if ((byte)enumerator.Current == 13)
|
||||||
|
{
|
||||||
|
// no name specified -> end of header (presumably \r\n\r\n)
|
||||||
|
if (startpos == endpos && !gettingval)
|
||||||
|
{
|
||||||
|
enumerator.MoveNext();
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
val = Encoding.UTF8.GetString(data, startpos, endpos - startpos);
|
||||||
|
|
||||||
|
if (!table.ContainsKey(name))
|
||||||
|
table.Add(name, val);
|
||||||
|
|
||||||
|
startpos = endpos + 2;
|
||||||
|
gettingval = false;
|
||||||
|
}
|
||||||
|
else if ((byte)enumerator.Current == 58) //:
|
||||||
|
{
|
||||||
|
if (!gettingval)
|
||||||
|
{
|
||||||
|
gettingval = true;
|
||||||
|
name = Encoding.UTF8.GetString(data, startpos, endpos - startpos);
|
||||||
|
startpos = endpos + 2;
|
||||||
|
enumerator.MoveNext();
|
||||||
|
endpos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
endpos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ParseBytes(byte[] data)
|
||||||
|
{
|
||||||
|
// parse the header
|
||||||
|
IEnumerator enumerator = data.GetEnumerator();
|
||||||
|
mimeHeader = ParseMime(enumerator, data);
|
||||||
|
|
||||||
|
// get the rest of the message
|
||||||
|
MemoryStream memStream = new MemoryStream();
|
||||||
|
BinaryWriter writer = new BinaryWriter(memStream);
|
||||||
|
while (enumerator.MoveNext())
|
||||||
|
writer.Write((byte)enumerator.Current);
|
||||||
|
InnerBody = memStream.ToArray();
|
||||||
|
memStream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
foreach (StrKeyValuePair entry in MimeHeader)
|
||||||
|
{
|
||||||
|
builder.Append(entry.Key).Append(": ").Append(entry.Value).Append("\r\n");
|
||||||
|
}
|
||||||
|
builder.Append("\r\n");
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class P2PMimeMessage : MimeMessage
|
||||||
|
{
|
||||||
|
public P2PMimeMessage(string destString, string srcString, NetworkMessage payLoad)
|
||||||
|
:base()
|
||||||
|
{
|
||||||
|
MimeHeader["P2P-Dest"] = destString;
|
||||||
|
MimeHeader["P2P-Src"] = srcString;
|
||||||
|
MimeHeader[MimeHeaderStrings.Content_Type] = "application/x-msnmsgrp2p";
|
||||||
|
|
||||||
|
InnerMessage = payLoad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] GetBytes()
|
||||||
|
{
|
||||||
|
return base.GetBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ParseBytes(byte[] data)
|
||||||
|
{
|
||||||
|
base.ParseBytes(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return base.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
105
MSNPSharp/Core/NSMessage.cs
Normal file
|
|
@ -0,0 +1,105 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
|
||||||
|
[Serializable()]
|
||||||
|
public class NSMessage : MSNMessage, ICloneable
|
||||||
|
{
|
||||||
|
public NSMessage()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public NSMessage(string command, ArrayList commandValues)
|
||||||
|
: base(command, commandValues)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public NSMessage(string command, string[] commandValues)
|
||||||
|
: base(command, new ArrayList(commandValues))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public NSMessage(string command)
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
Command = command;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override byte[] GetBytes()
|
||||||
|
{
|
||||||
|
switch (Command)
|
||||||
|
{
|
||||||
|
case "PNG":
|
||||||
|
return System.Text.Encoding.UTF8.GetBytes("PNG\r\n");
|
||||||
|
|
||||||
|
default:
|
||||||
|
return base.GetBytes();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return base.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region ICloneable ³ÉÔ±
|
||||||
|
|
||||||
|
object ICloneable.Clone()
|
||||||
|
{
|
||||||
|
NSMessage messageClone = new NSMessage();
|
||||||
|
messageClone.ParseBytes(GetBytes());
|
||||||
|
|
||||||
|
if (messageClone.InnerBody == null && InnerBody != null)
|
||||||
|
{
|
||||||
|
messageClone.InnerBody = new byte[InnerBody.Length];
|
||||||
|
Array.Copy(InnerBody, messageClone.InnerBody, InnerBody.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return messageClone;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
};
|
||||||
290
MSNPSharp/Core/NSMessagePool.cs
Normal file
|
|
@ -0,0 +1,290 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Buffers the incoming data from the notification server (NS).
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The main purpose of this class is to ensure that MSG, IPG and NOT payload commands are processed
|
||||||
|
/// only when they are complete. Payload commands can be quite large and may be larger
|
||||||
|
/// than the socket buffer. This pool will buffer the data and release the messages, or commands,
|
||||||
|
/// when they are fully retrieved from the server.
|
||||||
|
/// </remarks>
|
||||||
|
public class NSMessagePool : MessagePool, IDisposable
|
||||||
|
{
|
||||||
|
Queue<MemoryStream> messageQueue = new Queue<MemoryStream>();
|
||||||
|
MemoryStream bufferStream;
|
||||||
|
BinaryWriter bufferWriter;
|
||||||
|
int remainingBuffer;
|
||||||
|
|
||||||
|
public NSMessagePool()
|
||||||
|
{
|
||||||
|
CreateNewBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
~NSMessagePool()
|
||||||
|
{
|
||||||
|
Dispose(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Is true when there are message available to retrieve.
|
||||||
|
/// </summary>
|
||||||
|
public override bool MessageAvailable
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return messageQueue.Count > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Queue<MemoryStream> MessageQueue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return messageQueue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This points to the current message we are writing to.
|
||||||
|
/// </summary>
|
||||||
|
protected MemoryStream BufferStream
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return bufferStream;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
bufferStream = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is the interface to the bufferStream.
|
||||||
|
/// </summary>
|
||||||
|
protected BinaryWriter BufferWriter
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return bufferWriter;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
bufferWriter = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new memorystream to server as the buffer.
|
||||||
|
/// </summary>
|
||||||
|
private void CreateNewBuffer()
|
||||||
|
{
|
||||||
|
bufferStream = new MemoryStream(64);
|
||||||
|
bufferWriter = new BinaryWriter(bufferStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enques the current buffer memorystem when a message is completely retrieved.
|
||||||
|
/// </summary>
|
||||||
|
private void EnqueueCurrentBuffer()
|
||||||
|
{
|
||||||
|
messageQueue.Enqueue(bufferStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the next message as a byte array. The returned data includes all newlines which seperate the commands ("\r\n")
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override byte[] GetNextMessageData()
|
||||||
|
{
|
||||||
|
return messageQueue.Dequeue().ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stores the raw data in a buffer. When a full message is detected it is inserted on the internal stack.
|
||||||
|
/// You can retrieve these messages bij calling GetNextMessageData().
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="reader"></param>
|
||||||
|
public override void BufferData(BinaryReader reader)
|
||||||
|
{
|
||||||
|
int length = (int)(reader.BaseStream.Length - reader.BaseStream.Position);
|
||||||
|
|
||||||
|
// there is nothing in the bufferstream so we expect a command right away
|
||||||
|
while (length > 0)
|
||||||
|
{
|
||||||
|
// should we buffer the current message
|
||||||
|
if (remainingBuffer > 0)
|
||||||
|
{
|
||||||
|
// read as much as possible in the current message stream
|
||||||
|
int readLength = Math.Min(remainingBuffer, length);
|
||||||
|
byte[] msgBuffer = reader.ReadBytes(readLength);
|
||||||
|
bufferStream.Write(msgBuffer, 0, msgBuffer.Length);
|
||||||
|
|
||||||
|
// subtract what we have read from the total length
|
||||||
|
remainingBuffer -= readLength;
|
||||||
|
length = (int)(reader.BaseStream.Length - reader.BaseStream.Position);
|
||||||
|
|
||||||
|
// when we have read everything we can start a new message
|
||||||
|
if (remainingBuffer == 0)
|
||||||
|
{
|
||||||
|
EnqueueCurrentBuffer();
|
||||||
|
CreateNewBuffer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// read until we come across a newline
|
||||||
|
byte val = reader.ReadByte();
|
||||||
|
|
||||||
|
if (val != '\n')
|
||||||
|
bufferWriter.Write(val);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// write the last newline
|
||||||
|
bufferWriter.Write(val);
|
||||||
|
|
||||||
|
// check if it's a payload command
|
||||||
|
bufferStream.Position = 0;
|
||||||
|
string cmd3 = System.Text.Encoding.ASCII.GetString(new byte[3] {
|
||||||
|
(byte)bufferStream.ReadByte(),
|
||||||
|
(byte)bufferStream.ReadByte(),
|
||||||
|
(byte)bufferStream.ReadByte()
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (cmd3)
|
||||||
|
{
|
||||||
|
case "MSG": // MSG payload command
|
||||||
|
case "NOT": // NOT notification command
|
||||||
|
case "GCF": // GCF privacy settings
|
||||||
|
case "UBN": // UBN Unified Budy Notification (for SIP requests)
|
||||||
|
case "FQY": // FQY Federated QuerY command
|
||||||
|
case "DEL": // DEL
|
||||||
|
case "GET": // GET
|
||||||
|
case "PUT": // PUT
|
||||||
|
case "NFY": // NFY
|
||||||
|
case "SDG": // SDG circle messaging
|
||||||
|
case "IPG": // IPG pager command
|
||||||
|
case "UBX": // UBX personal message
|
||||||
|
case "UBM": // UBM Yahoo messenger message
|
||||||
|
case "UUN": // UUN Unified User Notification
|
||||||
|
case "ADL": // ADL Add List command
|
||||||
|
case "RML": // RML Remove List command
|
||||||
|
case "203": // 203
|
||||||
|
case "204": // 204 Invalid contact network in ADL/RML
|
||||||
|
case "205": // 205
|
||||||
|
case "210": // 210
|
||||||
|
case "234": // 234
|
||||||
|
case "241": // 241 Invalid membership for ADL/RML
|
||||||
|
case "508": // 508
|
||||||
|
case "509": // 509 UpsFailure, when sending mobile message
|
||||||
|
case "511": // 511
|
||||||
|
case "933": // 933
|
||||||
|
{
|
||||||
|
bufferStream.Seek(-3, SeekOrigin.End);
|
||||||
|
|
||||||
|
// calculate the length by reading backwards from the end
|
||||||
|
remainingBuffer = 0;
|
||||||
|
int size = 0;
|
||||||
|
|
||||||
|
for (int i = 0; ((size = bufferStream.ReadByte()) > 0) && size >= '0' && size <= '9'; i++)
|
||||||
|
{
|
||||||
|
remainingBuffer += (int)((size - '0') * Math.Pow(10, i));
|
||||||
|
bufferStream.Seek(-2, SeekOrigin.Current);
|
||||||
|
}
|
||||||
|
|
||||||
|
// move to the end of the stream before we are going to write
|
||||||
|
bufferStream.Seek(0, SeekOrigin.End);
|
||||||
|
|
||||||
|
if (remainingBuffer == 0)
|
||||||
|
{
|
||||||
|
EnqueueCurrentBuffer();
|
||||||
|
CreateNewBuffer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
// it was just a plain command start a new message
|
||||||
|
EnqueueCurrentBuffer();
|
||||||
|
CreateNewBuffer();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
length--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
// Dispose managed resources
|
||||||
|
if (bufferWriter != null)
|
||||||
|
((IDisposable)bufferWriter).Dispose();
|
||||||
|
|
||||||
|
if (bufferStream != null)
|
||||||
|
bufferStream.Dispose();
|
||||||
|
|
||||||
|
if (messageQueue.Count > 0)
|
||||||
|
messageQueue.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Free native resources
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
};
|
||||||
134
MSNPSharp/Core/NSPayLoadMessage.cs
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// NS payload message class, such as ADL and FQY
|
||||||
|
/// <para>The format of these mseeages is: COMMAND TRANSID [PARAM1] [PARAM2] .. PAYLOADLENGTH\r\nPAYLOAD</para>
|
||||||
|
/// <remarks>
|
||||||
|
/// DONOT pass the payload length as command value, the payload length will be calculated automatically
|
||||||
|
/// <para>
|
||||||
|
/// <list type="bullet">
|
||||||
|
/// List of NS payload commands:
|
||||||
|
/// <item>
|
||||||
|
/// RML
|
||||||
|
/// <description>Remove contact </description>
|
||||||
|
/// </item>
|
||||||
|
/// <item>
|
||||||
|
/// ADL
|
||||||
|
/// <description>Add users to your contact lists.</description>
|
||||||
|
/// </item>
|
||||||
|
/// <item>
|
||||||
|
/// FQY
|
||||||
|
/// <description>Query client's network types except PassportMember</description>
|
||||||
|
/// </item>
|
||||||
|
/// <item>
|
||||||
|
/// QRY
|
||||||
|
/// <description>Response to CHL by client </description>
|
||||||
|
/// </item>
|
||||||
|
/// <item>NOT</item>
|
||||||
|
/// <item>UBX</item>
|
||||||
|
/// <item>GCF</item>
|
||||||
|
/// <item>IPG</item>
|
||||||
|
/// <item>UUX</item>
|
||||||
|
/// <item>MSG</item>
|
||||||
|
/// <item>UBN</item>
|
||||||
|
/// </list>
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
/// </summary>
|
||||||
|
[Serializable()]
|
||||||
|
public class NSPayLoadMessage : NSMessage
|
||||||
|
{
|
||||||
|
private string payLoad = string.Empty;
|
||||||
|
|
||||||
|
public string PayLoad
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (InnerMessage == null)
|
||||||
|
return string.Empty;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (InnerMessage as TextPayloadMessage).Text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public NSPayLoadMessage()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public NSPayLoadMessage(string command, ArrayList commandValues, string payload)
|
||||||
|
: base(command, commandValues)
|
||||||
|
{
|
||||||
|
InnerMessage = new TextPayloadMessage(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NSPayLoadMessage(string command, string[] commandValues, string payload)
|
||||||
|
: base(command, new ArrayList(commandValues))
|
||||||
|
{
|
||||||
|
InnerMessage = new TextPayloadMessage(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NSPayLoadMessage(string command, string payload)
|
||||||
|
: base(command)
|
||||||
|
{
|
||||||
|
InnerMessage = new TextPayloadMessage(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ParseBytes(byte[] data)
|
||||||
|
{
|
||||||
|
base.ParseBytes(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] GetBytes()
|
||||||
|
{
|
||||||
|
return base.GetBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return base.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
148
MSNPSharp/Core/NetworkMessage.cs
Normal file
|
|
@ -0,0 +1,148 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
|
||||||
|
public abstract class NetworkMessage
|
||||||
|
{
|
||||||
|
byte[] innerBody;
|
||||||
|
NetworkMessage parentMessage;
|
||||||
|
NetworkMessage innerMessage;
|
||||||
|
|
||||||
|
protected NetworkMessage()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void CreateFromParentMessage(NetworkMessage containerMessage)
|
||||||
|
{
|
||||||
|
ParentMessage = containerMessage;
|
||||||
|
ParentMessage.InnerMessage = this;
|
||||||
|
|
||||||
|
if (ParentMessage.InnerBody != null)
|
||||||
|
ParseBytes(ParentMessage.InnerBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnInnerMessageSet()
|
||||||
|
{
|
||||||
|
if (InnerMessage != null && InnerMessage.ParentMessage != this)
|
||||||
|
InnerMessage.ParentMessage = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnParentMessageSet()
|
||||||
|
{
|
||||||
|
if (ParentMessage != null && ParentMessage.InnerMessage != this)
|
||||||
|
ParentMessage.InnerMessage = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The byte array contains in the message stream
|
||||||
|
/// </summary>
|
||||||
|
public byte[] InnerBody
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return innerBody;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
innerBody = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Usually the payload of a payload message.
|
||||||
|
/// </summary>
|
||||||
|
public NetworkMessage InnerMessage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return innerMessage;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
innerMessage = value;
|
||||||
|
OnInnerMessageSet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public NetworkMessage ParentMessage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return parentMessage;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
parentMessage = value;
|
||||||
|
OnParentMessageSet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Format the message and make it ready to send.
|
||||||
|
/// </summary>
|
||||||
|
public virtual void PrepareMessage()
|
||||||
|
{
|
||||||
|
if (InnerMessage != null)
|
||||||
|
InnerMessage.PrepareMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract byte[] GetBytes();
|
||||||
|
public abstract void ParseBytes(byte[] data);
|
||||||
|
|
||||||
|
public string ToDebugString()
|
||||||
|
{
|
||||||
|
if (InnerMessage != null)
|
||||||
|
return ToString() + "\r\n" + InnerMessage.ToDebugString();
|
||||||
|
else
|
||||||
|
return ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] AppendArray(byte[] originalArray, byte[] appendingArray)
|
||||||
|
{
|
||||||
|
if (appendingArray != null)
|
||||||
|
{
|
||||||
|
byte[] newArray = new byte[originalArray.Length + appendingArray.Length];
|
||||||
|
Array.Copy(originalArray, 0, newArray, 0, originalArray.Length);
|
||||||
|
Array.Copy(appendingArray, 0, newArray, originalArray.Length, appendingArray.Length);
|
||||||
|
return newArray;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return originalArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
528
MSNPSharp/Core/NotificationMessage.cs
Normal file
|
|
@ -0,0 +1,528 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Text;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a single NOT or IPG message.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// These messages are receid from, and send to, a nameserver. NOT messages are rececived for MSN-Calendar or MSN-Alert notifications.
|
||||||
|
/// IPG commands are received/send to exchange pager (sms) messages.
|
||||||
|
/// </remarks>
|
||||||
|
[Serializable()]
|
||||||
|
public class NotificationMessage : MSNMessage
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor.
|
||||||
|
/// </summary>
|
||||||
|
public NotificationMessage()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a NotificationMessage from the inner body contents of the specified message object.
|
||||||
|
/// This will also set the InnerMessage property of the message object to the newly created NotificationMessage.
|
||||||
|
/// </summary>
|
||||||
|
public NotificationMessage(NetworkMessage message)
|
||||||
|
{
|
||||||
|
ParseBytes(message.InnerBody);
|
||||||
|
message.InnerMessage = this;
|
||||||
|
}
|
||||||
|
/* Example notification
|
||||||
|
* <NOTIFICATION ver="1" siteid="111100200" siteurl="http://calendar.msn.com" id="1">\r\n
|
||||||
|
<TO pid="0x00060000:0x81ee5a43" name="example@passport.com" />\r\n
|
||||||
|
<MSG pri="" id="1">\r\n
|
||||||
|
<ACTION url="/calendar/isapi.dll?request=action&operation=modify&objectID=1&uicode1=modifyreminder&locale=2052"/>\r\n
|
||||||
|
<SUBSCR url="/calendar/isapi.dll?request=action&operation=modify&objectID=1&uicode1=modifyreminder&locale=2052"/><CAT id="111100201" />\r\n
|
||||||
|
<BODY lang="2052" icon="/En/img/calendar.png">\r\n
|
||||||
|
<TEXT>goto club 7. 2002 21:15 - 22:15 </TEXT>\r\n
|
||||||
|
</BODY>\r\n
|
||||||
|
</MSG>\r\n
|
||||||
|
</NOTIFICATION>\r\n
|
||||||
|
*/
|
||||||
|
|
||||||
|
#region Private
|
||||||
|
|
||||||
|
private bool notificationTypeSpecified = false;
|
||||||
|
|
||||||
|
public bool NotificationTypeSpecified
|
||||||
|
{
|
||||||
|
get { return notificationTypeSpecified; }
|
||||||
|
set { notificationTypeSpecified = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
NotificationType notificationType = NotificationType.Alert;
|
||||||
|
|
||||||
|
public NotificationType NotificationType
|
||||||
|
{
|
||||||
|
get { return notificationType; }
|
||||||
|
set { notificationType = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private int id = 0;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get { return id; }
|
||||||
|
set { id = value; }
|
||||||
|
}
|
||||||
|
private int siteId = 0;
|
||||||
|
|
||||||
|
public int SiteId
|
||||||
|
{
|
||||||
|
get { return siteId; }
|
||||||
|
set { siteId = value; }
|
||||||
|
}
|
||||||
|
private string siteUrl = string.Empty;
|
||||||
|
|
||||||
|
public string SiteUrl
|
||||||
|
{
|
||||||
|
get { return siteUrl; }
|
||||||
|
set { siteUrl = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string receiverAccount = string.Empty;
|
||||||
|
|
||||||
|
public string ReceiverAccount
|
||||||
|
{
|
||||||
|
get { return receiverAccount; }
|
||||||
|
set { receiverAccount = value; }
|
||||||
|
}
|
||||||
|
private string receiverOfflineMail = string.Empty;
|
||||||
|
|
||||||
|
public string ReceiverOfflineMail
|
||||||
|
{
|
||||||
|
get { return receiverOfflineMail; }
|
||||||
|
set { receiverOfflineMail = value; }
|
||||||
|
}
|
||||||
|
private string receiverMemberIdLow = string.Empty;
|
||||||
|
|
||||||
|
public string ReceiverMemberIdLow
|
||||||
|
{
|
||||||
|
get { return receiverMemberIdLow; }
|
||||||
|
set { receiverMemberIdLow = value; }
|
||||||
|
}
|
||||||
|
private string receiverMemberIdHigh = string.Empty;
|
||||||
|
|
||||||
|
public string ReceiverMemberIdHigh
|
||||||
|
{
|
||||||
|
get { return receiverMemberIdHigh; }
|
||||||
|
set { receiverMemberIdHigh = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string senderAccount = string.Empty;
|
||||||
|
|
||||||
|
public string SenderAccount
|
||||||
|
{
|
||||||
|
get { return senderAccount; }
|
||||||
|
set { senderAccount = value; }
|
||||||
|
}
|
||||||
|
private string senderMemberIdLow = string.Empty;
|
||||||
|
|
||||||
|
public string SenderMemberIdLow
|
||||||
|
{
|
||||||
|
get { return senderMemberIdLow; }
|
||||||
|
set { senderMemberIdLow = value; }
|
||||||
|
}
|
||||||
|
private string senderMemberIdHigh = string.Empty;
|
||||||
|
|
||||||
|
public string SenderMemberIdHigh
|
||||||
|
{
|
||||||
|
get { return senderMemberIdHigh; }
|
||||||
|
set { senderMemberIdHigh = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string sendDevice = string.Empty;
|
||||||
|
|
||||||
|
public string SendDevice
|
||||||
|
{
|
||||||
|
get { return sendDevice; }
|
||||||
|
set { sendDevice = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private int messageId = 0;
|
||||||
|
|
||||||
|
public int MessageId
|
||||||
|
{
|
||||||
|
get { return messageId; }
|
||||||
|
set { messageId = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string pri = string.Empty;
|
||||||
|
|
||||||
|
public string Pri
|
||||||
|
{
|
||||||
|
get { return pri; }
|
||||||
|
set { pri = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string actionUrl = string.Empty;
|
||||||
|
|
||||||
|
public string ActionUrl
|
||||||
|
{
|
||||||
|
get { return actionUrl; }
|
||||||
|
set { actionUrl = value; }
|
||||||
|
}
|
||||||
|
private string subcriptionUrl = string.Empty;
|
||||||
|
|
||||||
|
public string SubcriptionUrl
|
||||||
|
{
|
||||||
|
get { return subcriptionUrl; }
|
||||||
|
set { subcriptionUrl = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string catId = "110110001";
|
||||||
|
|
||||||
|
public string CatId
|
||||||
|
{
|
||||||
|
get { return catId; }
|
||||||
|
set { catId = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string language = string.Empty;
|
||||||
|
|
||||||
|
public string Language
|
||||||
|
{
|
||||||
|
get { return language; }
|
||||||
|
set { language = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string iconUrl = string.Empty;
|
||||||
|
|
||||||
|
public string IconUrl
|
||||||
|
{
|
||||||
|
get { return iconUrl; }
|
||||||
|
set { iconUrl = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string text = string.Empty;
|
||||||
|
|
||||||
|
public string Text
|
||||||
|
{
|
||||||
|
get { return text; }
|
||||||
|
set { text = value; }
|
||||||
|
}
|
||||||
|
private string offlineText = string.Empty;
|
||||||
|
|
||||||
|
public string OfflineText
|
||||||
|
{
|
||||||
|
get { return offlineText; }
|
||||||
|
set { offlineText = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string bodyPayload = string.Empty;
|
||||||
|
|
||||||
|
public string BodyPayload
|
||||||
|
{
|
||||||
|
get { return bodyPayload; }
|
||||||
|
set { bodyPayload = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a xml message based on the data in the object. It is used before the message is send to the server.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual XmlDocument CreateXmlMessage()
|
||||||
|
{
|
||||||
|
XmlDocument doc = new XmlDocument();
|
||||||
|
XmlElement root = doc.CreateElement("NOTIFICATION");
|
||||||
|
|
||||||
|
if (NotificationTypeSpecified)
|
||||||
|
root.Attributes.Append(doc.CreateAttribute("ver")).Value = ((int)NotificationType).ToString();
|
||||||
|
|
||||||
|
root.Attributes.Append(doc.CreateAttribute("id")).Value = Id.ToString();
|
||||||
|
if (siteId > 0)
|
||||||
|
root.Attributes.Append(doc.CreateAttribute("siteid")).Value = SiteId.ToString();
|
||||||
|
if (siteUrl.Length > 0)
|
||||||
|
root.Attributes.Append(doc.CreateAttribute("siteurl")).Value = SiteUrl;
|
||||||
|
|
||||||
|
XmlElement to = doc.CreateElement("TO");
|
||||||
|
if (ReceiverMemberIdLow.Length > 0 && ReceiverMemberIdHigh.Length > 0)
|
||||||
|
to.Attributes.Append(doc.CreateAttribute("pid")).Value = ReceiverMemberIdLow.ToString() + ":" + ReceiverMemberIdHigh.ToString();
|
||||||
|
if (ReceiverAccount.Length > 0)
|
||||||
|
to.Attributes.Append(doc.CreateAttribute("name")).Value = ReceiverAccount;
|
||||||
|
if (ReceiverOfflineMail.Length > 0)
|
||||||
|
to.Attributes.Append(doc.CreateAttribute("email")).Value = ReceiverOfflineMail;
|
||||||
|
if (SendDevice.Length > 0)
|
||||||
|
{
|
||||||
|
XmlElement via = doc.CreateElement("VIA");
|
||||||
|
via.Attributes.Append(doc.CreateAttribute("agent")).Value = SendDevice;
|
||||||
|
to.AppendChild(via);
|
||||||
|
}
|
||||||
|
root.AppendChild(to);
|
||||||
|
|
||||||
|
XmlElement from = doc.CreateElement("FROM");
|
||||||
|
if (SenderMemberIdLow.Length > 0 && SenderMemberIdHigh.Length > 0)
|
||||||
|
from.Attributes.Append(doc.CreateAttribute("pid")).Value = SenderMemberIdLow.ToString() + ":" + SenderMemberIdHigh.ToString();
|
||||||
|
if (SenderAccount.Length > 0)
|
||||||
|
from.Attributes.Append(doc.CreateAttribute("name")).Value = SenderAccount;
|
||||||
|
root.AppendChild(from);
|
||||||
|
|
||||||
|
XmlElement msg = doc.CreateElement("MSG");
|
||||||
|
if (Pri.Length > 0)
|
||||||
|
msg.Attributes.Append(doc.CreateAttribute("pri")).Value = Pri.ToString();
|
||||||
|
|
||||||
|
msg.Attributes.Append(doc.CreateAttribute("id")).Value = MessageId.ToString();
|
||||||
|
|
||||||
|
if (ActionUrl.Length > 0)
|
||||||
|
{
|
||||||
|
XmlElement action = doc.CreateElement("ACTION");
|
||||||
|
action.Attributes.Append(doc.CreateAttribute("url")).Value = ActionUrl;
|
||||||
|
msg.AppendChild(action);
|
||||||
|
}
|
||||||
|
if (SubcriptionUrl.Length > 0)
|
||||||
|
{
|
||||||
|
XmlElement subscr = doc.CreateElement("SUBSCR");
|
||||||
|
subscr.Attributes.Append(doc.CreateAttribute("url")).Value = SubcriptionUrl;
|
||||||
|
msg.AppendChild(subscr);
|
||||||
|
}
|
||||||
|
if (CatId.Length > 0)
|
||||||
|
{
|
||||||
|
XmlElement cat = doc.CreateElement("CAT");
|
||||||
|
cat.Attributes.Append(doc.CreateAttribute("id")).Value = CatId.ToString();
|
||||||
|
msg.AppendChild(cat);
|
||||||
|
}
|
||||||
|
|
||||||
|
XmlElement body = doc.CreateElement("BODY");
|
||||||
|
if (Language.Length > 0)
|
||||||
|
body.Attributes.Append(doc.CreateAttribute("id")).Value = Language;
|
||||||
|
if (IconUrl.Length > 0)
|
||||||
|
body.Attributes.Append(doc.CreateAttribute("icon")).Value = IconUrl;
|
||||||
|
if (Text.Length > 0)
|
||||||
|
{
|
||||||
|
XmlElement textEl = doc.CreateElement("TEXT");
|
||||||
|
textEl.AppendChild(doc.CreateTextNode(Text));
|
||||||
|
body.AppendChild(textEl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OfflineText.Length > 0)
|
||||||
|
{
|
||||||
|
XmlElement emailTextEl = doc.CreateElement("EMAILTEXT");
|
||||||
|
emailTextEl.AppendChild(doc.CreateTextNode(OfflineText));
|
||||||
|
body.AppendChild(emailTextEl);
|
||||||
|
}
|
||||||
|
msg.AppendChild(body);
|
||||||
|
|
||||||
|
root.AppendChild(msg);
|
||||||
|
|
||||||
|
doc.AppendChild(root);
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the command message as a byte array. This can be directly send over a networkconnection.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Remember to set the transaction ID before calling this method.
|
||||||
|
/// Uses UTF8 Encoding.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override byte[] GetBytes()
|
||||||
|
{
|
||||||
|
return new byte[] { 0x00 };
|
||||||
|
//throw new MSNPSharpException("You can't send notification messages yourself. It is only possible to retrieve them.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses incoming byte data send from the network.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The raw message as received from the server</param>
|
||||||
|
public override void ParseBytes(byte[] data)
|
||||||
|
{
|
||||||
|
if (data != null)
|
||||||
|
{
|
||||||
|
// retrieve the innerbody
|
||||||
|
XmlDocument xmlDoc = new XmlDocument();
|
||||||
|
|
||||||
|
TextReader reader = new StreamReader(new MemoryStream(data), new System.Text.UTF8Encoding(false));
|
||||||
|
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, reader.ReadToEnd(), GetType().Name);
|
||||||
|
|
||||||
|
reader = new StreamReader(new MemoryStream(data), new System.Text.UTF8Encoding(false));
|
||||||
|
xmlDoc.Load(reader);
|
||||||
|
|
||||||
|
// Root node: NOTIFICATION
|
||||||
|
XmlNode node = xmlDoc.SelectSingleNode("//NOTIFICATION");
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
if (node.Attributes.GetNamedItem("ver") != null)
|
||||||
|
{
|
||||||
|
NotificationType = (NotificationType)int.Parse(node.Attributes.GetNamedItem("ver").Value);
|
||||||
|
NotificationTypeSpecified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.Attributes.GetNamedItem("id") != null)
|
||||||
|
Id = int.Parse(node.Attributes.GetNamedItem("id").Value);
|
||||||
|
if (node.Attributes.GetNamedItem("siteid") != null)
|
||||||
|
SiteId = int.Parse(node.Attributes.GetNamedItem("siteid").Value);
|
||||||
|
if (node.Attributes.GetNamedItem("siteurl") != null)
|
||||||
|
SiteUrl = node.Attributes.GetNamedItem("siteurl").Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TO element
|
||||||
|
node = xmlDoc.SelectSingleNode("/NOTIFICATION/TO");
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
if (node.Attributes.GetNamedItem("pid") != null)
|
||||||
|
{
|
||||||
|
string[] values = node.Attributes.GetNamedItem("pid").Value.Split(':');
|
||||||
|
ReceiverMemberIdLow = values[0];
|
||||||
|
ReceiverMemberIdHigh = values[1];
|
||||||
|
}
|
||||||
|
if (node.Attributes.GetNamedItem("name") != null)
|
||||||
|
ReceiverAccount = node.Attributes.GetNamedItem("name").Value;
|
||||||
|
if (node.Attributes.GetNamedItem("email") != null)
|
||||||
|
ReceiverOfflineMail = node.Attributes.GetNamedItem("email").Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// VIA element
|
||||||
|
node = xmlDoc.SelectSingleNode("/NOTIFICATION/TO/VIA");
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
if (node.Attributes.GetNamedItem("agent") != null)
|
||||||
|
SendDevice = node.Attributes.GetNamedItem("agent").Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FROM element
|
||||||
|
node = xmlDoc.SelectSingleNode("/NOTIFICATION/FROM");
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
if (node.Attributes.GetNamedItem("pid") != null)
|
||||||
|
{
|
||||||
|
string[] values = node.Attributes.GetNamedItem("pid").Value.Split(':');
|
||||||
|
SenderMemberIdLow = values[0];
|
||||||
|
SenderMemberIdHigh = values[1];
|
||||||
|
}
|
||||||
|
if (node.Attributes.GetNamedItem("name") != null)
|
||||||
|
SenderAccount = node.Attributes.GetNamedItem("name").Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MSG element
|
||||||
|
node = xmlDoc.SelectSingleNode("/NOTIFICATION/MSG");
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
if (node.Attributes.GetNamedItem("pri") != null)
|
||||||
|
Pri = node.Attributes.GetNamedItem("pri").Value;
|
||||||
|
if (node.Attributes.GetNamedItem("id") != null)
|
||||||
|
MessageId = int.Parse(node.Attributes.GetNamedItem("id").Value);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ACTION element
|
||||||
|
node = xmlDoc.SelectSingleNode("/NOTIFICATION/MSG/ACTION");
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
if (node.Attributes.GetNamedItem("url") != null)
|
||||||
|
ActionUrl = node.Attributes.GetNamedItem("url").Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SUBSCR element
|
||||||
|
node = xmlDoc.SelectSingleNode("/NOTIFICATION/MSG/SUBSCR");
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
if (node.Attributes.GetNamedItem("url") != null)
|
||||||
|
SubcriptionUrl = node.Attributes.GetNamedItem("url").Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CAT element
|
||||||
|
node = xmlDoc.SelectSingleNode("/NOTIFICATION/MSG/CAT");
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
if (node.Attributes.GetNamedItem("id") != null)
|
||||||
|
CatId = node.Attributes.GetNamedItem("id").Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BODY element
|
||||||
|
node = xmlDoc.SelectSingleNode("/NOTIFICATION/MSG/BODY");
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
if (node.Attributes.GetNamedItem("lang") != null)
|
||||||
|
Language = node.Attributes.GetNamedItem("lang").Value;
|
||||||
|
if (node.Attributes.GetNamedItem("icon") != null)
|
||||||
|
IconUrl = node.Attributes.GetNamedItem("icon").Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NotificationTypeSpecified && Id == 0 && node != null)
|
||||||
|
{
|
||||||
|
bodyPayload = node.InnerText;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TEXT element
|
||||||
|
node = xmlDoc.SelectSingleNode("/NOTIFICATION/MSG/BODY/TEXT");
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
Text = node.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// EMAILTEXT element
|
||||||
|
node = xmlDoc.SelectSingleNode("/NOTIFICATION/MSG/BODY/EMAILTEXT");
|
||||||
|
if (node != null)
|
||||||
|
{
|
||||||
|
OfflineText = node.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw new MSNPSharpException("NotificationMessage expected payload data, but not InnerBody is present.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return System.Text.UTF8Encoding.UTF8.GetString(this.GetBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
};
|
||||||
244
MSNPSharp/Core/PersistentStream.cs
Normal file
|
|
@ -0,0 +1,244 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Security.Permissions;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A multi-user stream.
|
||||||
|
/// </summary>
|
||||||
|
public class PersistentStream : Stream
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
private Stream innerStream = null;
|
||||||
|
|
||||||
|
#region Stream overrides
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||||
|
{
|
||||||
|
return innerStream.BeginRead(buffer, offset, count, callback, state);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
||||||
|
{
|
||||||
|
return innerStream.BeginWrite(buffer, offset, count, callback, state);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override bool CanRead
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return innerStream.CanRead;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override bool CanSeek
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return innerStream.CanSeek;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override bool CanWrite
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return innerStream.CanWrite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
|
||||||
|
public override System.Runtime.Remoting.ObjRef CreateObjRef(Type requestedType)
|
||||||
|
{
|
||||||
|
return innerStream.CreateObjRef(requestedType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override int EndRead(IAsyncResult asyncResult)
|
||||||
|
{
|
||||||
|
return innerStream.EndRead(asyncResult);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override void EndWrite(IAsyncResult asyncResult)
|
||||||
|
{
|
||||||
|
innerStream.EndWrite(asyncResult);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
return innerStream.Equals(obj);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override void Flush()
|
||||||
|
{
|
||||||
|
innerStream.Flush();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return innerStream.GetHashCode();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
|
||||||
|
public override object InitializeLifetimeService()
|
||||||
|
{
|
||||||
|
return innerStream.InitializeLifetimeService();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override long Length
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return innerStream.Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override long Position
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return innerStream.Position;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
innerStream.Position = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override int Read(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
return innerStream.Read(buffer, offset, count);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override int ReadByte()
|
||||||
|
{
|
||||||
|
return innerStream.ReadByte();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override long Seek(long offset, SeekOrigin origin)
|
||||||
|
{
|
||||||
|
return innerStream.Seek(offset, origin);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override void SetLength(long value)
|
||||||
|
{
|
||||||
|
innerStream.SetLength(value);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return innerStream.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override void Write(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
innerStream.Write(buffer, offset, count);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public override void WriteByte(byte value)
|
||||||
|
{
|
||||||
|
innerStream.WriteByte(value);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Keeps track of the number of users using the stream.
|
||||||
|
/// </summary>
|
||||||
|
private int users;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The number of users using the stream.
|
||||||
|
/// </summary>
|
||||||
|
public int Users
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Increases the number of users using this stream with 1.
|
||||||
|
/// </summary>
|
||||||
|
public void Open()
|
||||||
|
{
|
||||||
|
users++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Decreases the number of users using this stream with 1. If the number of users is below 0 the stream will really be closed.
|
||||||
|
/// </summary>
|
||||||
|
public override void Close()
|
||||||
|
{
|
||||||
|
users--;
|
||||||
|
if (users <= 0)
|
||||||
|
innerStream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public PersistentStream(Stream stream)
|
||||||
|
{
|
||||||
|
innerStream = stream;
|
||||||
|
Open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
169
MSNPSharp/Core/SBMessage.cs
Normal file
|
|
@ -0,0 +1,169 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SBMessage : MSNMessage
|
||||||
|
{
|
||||||
|
private string acknowledgement = "N";
|
||||||
|
protected bool hasAckField = false;
|
||||||
|
|
||||||
|
public string Acknowledgement
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return acknowledgement;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (Command == "MSG")
|
||||||
|
hasAckField = true;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
acknowledgement = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SBMessage()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public SBMessage(string command, string[] commandValues)
|
||||||
|
: base(command, new ArrayList(commandValues))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public SBMessage(string command, ArrayList commandValues)
|
||||||
|
: base(command, commandValues)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] GetBytes()
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder(128);
|
||||||
|
builder.Append(Command);
|
||||||
|
|
||||||
|
if (Command != "OUT")
|
||||||
|
{
|
||||||
|
if (TransactionID != -1)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(TransactionID.ToString(CultureInfo.InvariantCulture));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Command == "MSG" && hasAckField)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(Acknowledgement);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach (string val in CommandValues)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (InnerMessage != null && InnerBody == null) //This is a message created locally.
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(InnerMessage.GetBytes().Length.ToString(CultureInfo.InvariantCulture));
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.Append("\r\n");
|
||||||
|
|
||||||
|
if (InnerMessage != null)
|
||||||
|
return AppendArray(System.Text.Encoding.UTF8.GetBytes(builder.ToString()), InnerMessage.GetBytes());
|
||||||
|
else
|
||||||
|
return System.Text.Encoding.UTF8.GetBytes(builder.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder(128);
|
||||||
|
builder.Append(Command);
|
||||||
|
|
||||||
|
if (Command != "OUT")
|
||||||
|
{
|
||||||
|
if (TransactionID != -1)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(TransactionID.ToString(CultureInfo.InvariantCulture));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Command == "MSG" && hasAckField)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(Acknowledgement);
|
||||||
|
|
||||||
|
foreach (string val in CommandValues)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach (string val in CommandValues)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (InnerMessage != null && InnerBody == null)
|
||||||
|
{
|
||||||
|
builder.Append(' ');
|
||||||
|
builder.Append(InnerMessage.GetBytes().Length.ToString(CultureInfo.InvariantCulture));
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.Append("\r\n");
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
68
MSNPSharp/Core/SBMessagePool.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Buffers and releases the messages for a switchboard
|
||||||
|
/// </summary>
|
||||||
|
public class SBMessagePool : NSMessagePool
|
||||||
|
{
|
||||||
|
public SBMessagePool()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Buffers data.
|
||||||
|
public override void BufferData(BinaryReader reader)
|
||||||
|
{
|
||||||
|
base.BufferData(reader);
|
||||||
|
|
||||||
|
if (Settings.TraceSwitch.TraceVerbose)
|
||||||
|
{
|
||||||
|
if (MessageAvailable)
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "Message Available: ", GetType().Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "Buffering data...: ", GetType().Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
576
MSNPSharp/Core/SocketMessageProcessor.cs
Normal file
|
|
@ -0,0 +1,576 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Org.Mentalis.Network.ProxySocket;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
|
||||||
|
public abstract class SocketMessageProcessor : IMessageProcessor, IDisposable
|
||||||
|
{
|
||||||
|
private ConnectivitySettings connectivitySettings = new ConnectivitySettings();
|
||||||
|
private byte[] socketBuffer = new byte[8192];
|
||||||
|
private bool hasFiredDisconnectEvent = false;
|
||||||
|
private IPEndPoint proxyEndPoint = null;
|
||||||
|
private ProxySocket socket = null;
|
||||||
|
private MessagePool messagePool = null;
|
||||||
|
private List<IMessageHandler> messageHandlers = new List<IMessageHandler>();
|
||||||
|
|
||||||
|
public event EventHandler<EventArgs> ConnectionEstablished;
|
||||||
|
public event EventHandler<EventArgs> ConnectionClosed;
|
||||||
|
public event EventHandler<ExceptionEventArgs> ConnectingException;
|
||||||
|
public event EventHandler<ExceptionEventArgs> ConnectionException;
|
||||||
|
|
||||||
|
public SocketMessageProcessor(ConnectivitySettings connectivitySettings)
|
||||||
|
{
|
||||||
|
ConnectivitySettings = connectivitySettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
~SocketMessageProcessor()
|
||||||
|
{
|
||||||
|
Dispose(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IPEndPoint ProxyEndPoint
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return proxyEndPoint;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
proxyEndPoint = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MessagePool MessagePool
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return messagePool;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
messagePool = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual ProxySocket GetPreparedSocket(IPAddress address, int port)
|
||||||
|
{
|
||||||
|
//Creates the Socket for sending data over TCP.
|
||||||
|
ProxySocket socket = new ProxySocket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||||
|
|
||||||
|
// incorporate the connection settings like proxy's
|
||||||
|
// Note: ProxyType is in MSNPSharp namespace, ProxyTypes in ProxySocket namespace.
|
||||||
|
if (ConnectivitySettings.ProxyType != ProxyType.None)
|
||||||
|
{
|
||||||
|
// set the proxy type
|
||||||
|
socket.ProxyType = (ConnectivitySettings.ProxyType == ProxyType.Socks4)
|
||||||
|
? Org.Mentalis.Network.ProxySocket.ProxyTypes.Socks4
|
||||||
|
: Org.Mentalis.Network.ProxySocket.ProxyTypes.Socks5;
|
||||||
|
|
||||||
|
socket.ProxyUser = ConnectivitySettings.ProxyUsername;
|
||||||
|
socket.ProxyPass = ConnectivitySettings.ProxyPassword;
|
||||||
|
|
||||||
|
// resolve the proxy host
|
||||||
|
if (proxyEndPoint == null)
|
||||||
|
{
|
||||||
|
bool worked = false;
|
||||||
|
int retries = 0;
|
||||||
|
Exception exp = null;
|
||||||
|
|
||||||
|
//we retry a few times, because dns resolve failure is quite common
|
||||||
|
do
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
System.Net.IPHostEntry ipHostEntry = System.Net.Dns.GetHostEntry(ConnectivitySettings.ProxyHost);
|
||||||
|
System.Net.IPAddress ipAddress = ipHostEntry.AddressList[0];
|
||||||
|
|
||||||
|
// assign to the connection object so other sockets can make use of it quickly
|
||||||
|
proxyEndPoint = new IPEndPoint(ipAddress, ConnectivitySettings.ProxyPort);
|
||||||
|
|
||||||
|
worked = true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
retries++;
|
||||||
|
exp = e;
|
||||||
|
}
|
||||||
|
} while (!worked && retries < 3);
|
||||||
|
|
||||||
|
if (!worked)
|
||||||
|
throw new ConnectivityException("DNS Resolve for the proxy server failed: " + ConnectivitySettings.ProxyHost + " failed.", exp);
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.ProxyEndPoint = proxyEndPoint;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
socket.ProxyType = ProxyTypes.None;
|
||||||
|
|
||||||
|
//Send operations will timeout of confirmation is not received within 3000 milliseconds.
|
||||||
|
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 3000);
|
||||||
|
|
||||||
|
//Socket will linger for 2 seconds after close is called.
|
||||||
|
LingerOption lingerOption = new LingerOption(true, 2);
|
||||||
|
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, lingerOption);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
socket.Bind(new IPEndPoint(address, port));
|
||||||
|
}
|
||||||
|
catch (SocketException ex)
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "An error occured while trying to bind to a local address, error code: " + ex.ErrorCode + ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
return socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void EndSendCallback(IAsyncResult ar)
|
||||||
|
{
|
||||||
|
ProxySocket socket = (ProxySocket)ar.AsyncState;
|
||||||
|
socket.EndSend(ar);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void SendSocketData(byte[] data)
|
||||||
|
{
|
||||||
|
if (socket == null || !Connected)
|
||||||
|
{
|
||||||
|
// the connection is closed
|
||||||
|
OnDisconnected();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SendSocketData(socket, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void SendSocketData(Socket psocket, byte[] data)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (psocket != null && IsSocketConnected(psocket))
|
||||||
|
{
|
||||||
|
lock (psocket)
|
||||||
|
{
|
||||||
|
psocket.Send(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnDisconnected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SocketException sex)
|
||||||
|
{
|
||||||
|
if (sex.NativeErrorCode != 10035) //10035: WSAEWOULDBLOCK
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "Error while sending network message. Error message: " + sex.Message);
|
||||||
|
OnDisconnected();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (ObjectDisposedException)
|
||||||
|
{
|
||||||
|
// the connection is closed
|
||||||
|
OnDisconnected();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new MSNPSharpException("Error while sending network message. See the inner exception for more details.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void EndReceiveCallback(IAsyncResult ar)
|
||||||
|
{
|
||||||
|
int cnt = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.Assert(messagePool != null, "Field messagepool must be defined in derived class of SocketMessageProcessor.");
|
||||||
|
|
||||||
|
Socket socket = (Socket)ar.AsyncState;
|
||||||
|
cnt = socket.EndReceive(ar);
|
||||||
|
if (cnt == 0)
|
||||||
|
{
|
||||||
|
// No data is received. We are disconnected.
|
||||||
|
OnDisconnected();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// read the messages and dispatch to handlers
|
||||||
|
using (BinaryReader reader = new BinaryReader(new MemoryStream(socketBuffer, 0, cnt)))
|
||||||
|
{
|
||||||
|
messagePool.BufferData(reader);
|
||||||
|
}
|
||||||
|
while (messagePool.MessageAvailable)
|
||||||
|
{
|
||||||
|
// retrieve the message
|
||||||
|
byte[] incomingMessage = messagePool.GetNextMessageData();
|
||||||
|
|
||||||
|
|
||||||
|
// call the virtual method to perform polymorphism, descendant classes can take care of it
|
||||||
|
OnMessageReceived(incomingMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
// start a new read
|
||||||
|
BeginDataReceive(socket);
|
||||||
|
}
|
||||||
|
catch (SocketException e)
|
||||||
|
{
|
||||||
|
// close the socket upon a exception
|
||||||
|
if (socket != null && Connected)
|
||||||
|
socket.Close();
|
||||||
|
|
||||||
|
OnDisconnected();
|
||||||
|
|
||||||
|
// an exception Occurred, pass it through
|
||||||
|
if (ConnectionException != null)
|
||||||
|
ConnectionException(this, new ExceptionEventArgs(new ConnectivityException("SocketMessageProcessor encountered a socket exception while retrieving data. See the inner exception for more information.", e)));
|
||||||
|
}
|
||||||
|
catch (ObjectDisposedException)
|
||||||
|
{
|
||||||
|
// the connection is closed
|
||||||
|
OnDisconnected();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// close the socket upon a exception
|
||||||
|
if (socket != null && Connected)
|
||||||
|
socket.Close();
|
||||||
|
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceError, e.ToString() + "\r\n" + e.StackTrace + "\r\n", GetType().Name);
|
||||||
|
|
||||||
|
OnDisconnected();
|
||||||
|
|
||||||
|
if (ConnectionException != null)
|
||||||
|
ConnectionException(this, new ExceptionEventArgs(new ConnectivityException("SocketMessageProcessor encountered a general exception while retrieving data. See the inner exception for more information.", e)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected virtual void EndConnectCallback(IAsyncResult ar)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "End Connect Callback", GetType().Name);
|
||||||
|
|
||||||
|
((ProxySocket)socket).EndConnect(ar);
|
||||||
|
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "End Connect Callback Daarna", GetType().Name);
|
||||||
|
|
||||||
|
hasFiredDisconnectEvent = false;
|
||||||
|
OnConnected();
|
||||||
|
|
||||||
|
// Begin receiving data
|
||||||
|
BeginDataReceive(socket);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceError, "** EndConnectCallback exception **" + e.ToString(), GetType().Name);
|
||||||
|
|
||||||
|
if (ConnectingException != null)
|
||||||
|
ConnectingException(this, new ExceptionEventArgs(new ConnectivityException("SocketMessageProcessor failed to connect to the specified endpoint. See the inner exception for more information.", e)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void BeginDataReceive(Socket socket)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
socketBuffer = new byte[socketBuffer.Length];
|
||||||
|
socket.BeginReceive(socketBuffer, 0, socketBuffer.Length, SocketFlags.None, new AsyncCallback(EndReceiveCallback), socket);
|
||||||
|
}
|
||||||
|
catch (ObjectDisposedException)
|
||||||
|
{
|
||||||
|
OnDisconnected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnConnected()
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceInfo, "Connected", GetType().Name);
|
||||||
|
|
||||||
|
if (ConnectionEstablished != null)
|
||||||
|
ConnectionEstablished(this, new EventArgs());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnDisconnected()
|
||||||
|
{
|
||||||
|
if (hasFiredDisconnectEvent)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hasFiredDisconnectEvent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceInfo, "Disconnected", GetType().Name);
|
||||||
|
|
||||||
|
if (ConnectionClosed != null)
|
||||||
|
ConnectionClosed(this, new EventArgs());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConnectivitySettings ConnectivitySettings
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return connectivitySettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (Connected)
|
||||||
|
{
|
||||||
|
string errorString = "Cannot set the ConnectivitySettings property of a connected " + GetType().ToString() + ".";
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceError, errorString);
|
||||||
|
throw new InvalidOperationException(errorString);
|
||||||
|
}
|
||||||
|
|
||||||
|
connectivitySettings = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Connected
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (socket == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
lock (socket)
|
||||||
|
{
|
||||||
|
return IsSocketConnected(socket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Show whether the socket is connected at a certain moment.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="socket"></param>
|
||||||
|
/// <returns>true if socket is connected, false if socket is disconnected.</returns>
|
||||||
|
public static bool IsSocketConnected(Socket socket)
|
||||||
|
{
|
||||||
|
bool returnValue = false;
|
||||||
|
|
||||||
|
if (socket != null)
|
||||||
|
{
|
||||||
|
// Socket.Connected doesn't tell us if the socket is actually connected...
|
||||||
|
// http://msdn2.microsoft.com/en-us/library/system.net.sockets.socket.connected.aspx
|
||||||
|
|
||||||
|
bool disposed = false;
|
||||||
|
bool blocking = socket.Blocking;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
socket.Blocking = false;
|
||||||
|
|
||||||
|
int pollWait = 1;
|
||||||
|
|
||||||
|
if (socket.Poll(pollWait, SelectMode.SelectRead) && socket.Available == 0)
|
||||||
|
{
|
||||||
|
returnValue = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnValue = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SocketException ex)
|
||||||
|
{
|
||||||
|
// 10035 == WSAEWOULDBLOCK
|
||||||
|
if (ex.NativeErrorCode.Equals(10035))
|
||||||
|
returnValue = true;
|
||||||
|
}
|
||||||
|
catch (ObjectDisposedException)
|
||||||
|
{
|
||||||
|
disposed = true;
|
||||||
|
returnValue = false;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (!disposed)
|
||||||
|
{
|
||||||
|
socket.Blocking = blocking;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EndPoint LocalEndPoint
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return socket.LocalEndPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<IMessageHandler> MessageHandlers
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return messageHandlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void RegisterHandler(IMessageHandler handler)
|
||||||
|
{
|
||||||
|
if (handler != null && !messageHandlers.Contains(handler))
|
||||||
|
{
|
||||||
|
lock (messageHandlers)
|
||||||
|
{
|
||||||
|
messageHandlers.Add(handler);
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceInfo,
|
||||||
|
handler.ToString() + " added to handler list.", GetType().Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void UnregisterHandler(IMessageHandler handler)
|
||||||
|
{
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
lock (messageHandlers)
|
||||||
|
{
|
||||||
|
while (messageHandlers.Remove(handler))
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceInfo,
|
||||||
|
handler.ToString() + " removed from handler list.", GetType().Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Connect to the target through ConnectivitySettins.
|
||||||
|
/// </summary>
|
||||||
|
/// <exception cref="InvalidOperationException">Socket already connected.</exception>
|
||||||
|
public virtual void Connect()
|
||||||
|
{
|
||||||
|
if (socket != null && Connected)
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceWarning, "Connect() called, but already a socket available.", GetType().Name);
|
||||||
|
|
||||||
|
// If you have to fail, fail noisily and as soon as possible.
|
||||||
|
throw new InvalidOperationException("Socket already connected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Create a socket
|
||||||
|
socket = GetPreparedSocket((ConnectivitySettings.LocalHost == string.Empty) ? IPAddress.Any : IPAddress.Parse(ConnectivitySettings.LocalHost), ConnectivitySettings.LocalPort);
|
||||||
|
|
||||||
|
IPAddress hostIP = null;
|
||||||
|
|
||||||
|
if (IPAddress.TryParse(ConnectivitySettings.Host, out hostIP))
|
||||||
|
{
|
||||||
|
// start connecting
|
||||||
|
((ProxySocket)socket).BeginConnect(new System.Net.IPEndPoint(IPAddress.Parse(ConnectivitySettings.Host), ConnectivitySettings.Port), new AsyncCallback(EndConnectCallback), socket);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
((ProxySocket)socket).BeginConnect(ConnectivitySettings.Host, ConnectivitySettings.Port, new AsyncCallback(EndConnectCallback), socket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "Connecting exception: " + e.ToString(), GetType().Name);
|
||||||
|
|
||||||
|
if (ConnectingException != null)
|
||||||
|
ConnectingException(this, new ExceptionEventArgs(e));
|
||||||
|
|
||||||
|
// re-throw the exception since the exception is thrown while in a blocking call
|
||||||
|
throw; //RethrowToPreserveStackDetails (without e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Disconnect()
|
||||||
|
{
|
||||||
|
// clean up the socket properly
|
||||||
|
if (socket != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Connected)
|
||||||
|
{
|
||||||
|
socket.Shutdown(SocketShutdown.Both);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
socket.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
socket = null;
|
||||||
|
// We don't need to call OnDisconnect here since EndReceiveCallback will be call automatically later on. (This is not valid if disconnected remotelly)
|
||||||
|
// We need to call OnDisconnect after EndReceiveCallback if disconnected locally.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void SendMessage(NetworkMessage message);
|
||||||
|
protected abstract void OnMessageReceived(byte[] data);
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
// Dispose managed resources
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Free native resources
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
111
MSNPSharp/Core/TextPayloadMessage.cs
Normal file
|
|
@ -0,0 +1,111 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MSNPSharp.Core
|
||||||
|
{
|
||||||
|
public class TextPayloadMessage : NetworkMessage
|
||||||
|
{
|
||||||
|
private string text = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The payload text.
|
||||||
|
/// </summary>
|
||||||
|
public string Text
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
text = value;
|
||||||
|
InnerBody = Encoding.GetBytes(Text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Encoding encoding = Encoding.UTF8;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The encoding used when parsing the payload text.
|
||||||
|
/// </summary>
|
||||||
|
public Encoding Encoding
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
encoding = value;
|
||||||
|
InnerBody = Encoding.GetBytes(Text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextPayloadMessage(string txt)
|
||||||
|
{
|
||||||
|
Text = txt;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextPayloadMessage(string txt, Encoding encode)
|
||||||
|
{
|
||||||
|
Text = txt;
|
||||||
|
Encoding = encode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override byte[] GetBytes()
|
||||||
|
{
|
||||||
|
return Encoding.GetBytes(Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ParseBytes(byte[] data)
|
||||||
|
{
|
||||||
|
Text = Encoding.GetString(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void PrepareMessage()
|
||||||
|
{
|
||||||
|
InnerBody = Encoding.GetBytes(Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Text.Replace("\r", "\\r").Replace("\n", "\\n\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
229
MSNPSharp/Credentials.cs
Normal file
|
|
@ -0,0 +1,229 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace MSNPSharp
|
||||||
|
{
|
||||||
|
using MSNPSharp.Core;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies the user credentials. These settings are used when authentication
|
||||||
|
/// is required on the network.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The client identifier, together with the client code, represents
|
||||||
|
/// a unique way of identifying the client connected to the network.
|
||||||
|
///
|
||||||
|
/// Third party softwarehouses can request their own identifier/code combination
|
||||||
|
/// for their software. These values have to be stored in the properties before connecting
|
||||||
|
/// to the network.
|
||||||
|
/// When you want to emulate the Microsoft MSN Messenger client, you can use any of the following
|
||||||
|
/// values:
|
||||||
|
/// <c>
|
||||||
|
/// ClientID ClientCode Client Version Acknowledgement
|
||||||
|
/// msmsgs@msnmsgr.com Q1P7W2E4J9R8U3S5
|
||||||
|
/// PROD0038W!61ZTF9 VT6PX?UQTM4WM%YR
|
||||||
|
/// PROD0058#7IL2{QD QHDCY@7R1TB6W?5B
|
||||||
|
/// PROD0061VRRZH@4F JXQ6J@TUOGYV@N0M
|
||||||
|
/// PROD0119GSJUC$18 ILTXC!4IXB5FB*PX
|
||||||
|
/// PROD0120PW!CCV9@ C1BX{V4W}Q3*10SM WLM 2009 v14.0.8050.1202 http://twitter.com/mynetx
|
||||||
|
/// </c>
|
||||||
|
///
|
||||||
|
/// Note that officially you must use an obtained license (client id and client code) from Microsoft in order to access the network legally!
|
||||||
|
/// After you have received your own license you can set the client id and client code in this class.
|
||||||
|
/// </remarks>
|
||||||
|
[Serializable]
|
||||||
|
public class Credentials
|
||||||
|
{
|
||||||
|
private ClientInfo clientInfo = new ClientInfo();
|
||||||
|
private string password;
|
||||||
|
private string account;
|
||||||
|
|
||||||
|
public ClientInfo ClientInfo
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return clientInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Msn protocol
|
||||||
|
/// </summary>
|
||||||
|
public MsnProtocol MsnProtocol
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return clientInfo.MsnProtocol;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The client identifier used to identify the clientsoftware.
|
||||||
|
/// </summary>
|
||||||
|
public string ClientID
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return clientInfo.ProductID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The client code used to identify the clientsoftware.
|
||||||
|
/// </summary>
|
||||||
|
public string ClientCode
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return clientInfo.ProductKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Password for the account. Used when logging into the network.
|
||||||
|
/// </summary>
|
||||||
|
public string Password
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
password = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The account the identity uses. A typical messenger account is specified as name@hotmail.com.
|
||||||
|
/// </summary>
|
||||||
|
public string Account
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
account = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor to instantiate a Credentials object.
|
||||||
|
/// </summary>
|
||||||
|
protected Credentials()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Credentials(MsnProtocol msnp)
|
||||||
|
: this(string.Empty, string.Empty)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Credentials(string account, string password)
|
||||||
|
: this(account, password, MsnProtocol.MSNP18)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Credentials(string account, string password, MsnProtocol msnp)
|
||||||
|
{
|
||||||
|
this.account = account;
|
||||||
|
this.password = password;
|
||||||
|
this.clientInfo = (ClientInfo)DefaultCredentials[msnp].Clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor to instantiate a Credentials object with the specified values.
|
||||||
|
/// </summary>
|
||||||
|
public Credentials(string account, string password, string clientID, string clientCode)
|
||||||
|
: this(account, password, clientID, clientCode, MsnProtocol.MSNP18)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor to instantiate a Credentials object with the specified values and msn protocol speaking.
|
||||||
|
/// </summary>
|
||||||
|
public Credentials(string account, string password, string clientID, string clientCode, MsnProtocol msnp)
|
||||||
|
: this(account, password, msnp)
|
||||||
|
{
|
||||||
|
clientInfo.ProductID = clientID;
|
||||||
|
clientInfo.ProductKey = clientCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
static readonly Dictionary<MsnProtocol, ClientInfo> DefaultCredentials = new Dictionary<MsnProtocol, ClientInfo>();
|
||||||
|
static Credentials()
|
||||||
|
{
|
||||||
|
// MSNP18
|
||||||
|
ClientInfo msnp18 = new ClientInfo();
|
||||||
|
msnp18.MsnProtocol = MsnProtocol.MSNP18;
|
||||||
|
msnp18.ProductID = "PROD0120PW!CCV9@";
|
||||||
|
msnp18.ProductKey = "C1BX{V4W}Q3*10SM";
|
||||||
|
msnp18.MessengerClientName = "MSNMSGR";
|
||||||
|
msnp18.MessengerClientBuildVer = "14.0.8117.0416";
|
||||||
|
msnp18.ApplicationId = "AAD9B99B-58E6-4F23-B975-D9EC1F9EC24A";
|
||||||
|
msnp18.MessengerClientBrand = "msmsgs";
|
||||||
|
DefaultCredentials[msnp18.MsnProtocol] = msnp18;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public struct ClientInfo : ICloneable
|
||||||
|
{
|
||||||
|
public MsnProtocol MsnProtocol;
|
||||||
|
public string ApplicationId;
|
||||||
|
public string MessengerClientBuildVer;
|
||||||
|
public string MessengerClientName;
|
||||||
|
public string ProductID;
|
||||||
|
public string ProductKey;
|
||||||
|
public string MessengerClientBrand;
|
||||||
|
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
ClientInfo ci = new ClientInfo();
|
||||||
|
ci.MsnProtocol = MsnProtocol;
|
||||||
|
ci.ApplicationId = String.Copy(ApplicationId);
|
||||||
|
ci.MessengerClientBuildVer = String.Copy(MessengerClientBuildVer);
|
||||||
|
ci.MessengerClientName = String.Copy(MessengerClientName);
|
||||||
|
ci.ProductID = String.Copy(ProductID);
|
||||||
|
ci.ProductKey = String.Copy(ProductKey);
|
||||||
|
ci.MessengerClientBrand = MessengerClientBrand;
|
||||||
|
|
||||||
|
return ci;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
1937
MSNPSharp/DataTransfer/MSNSLPHandler.cs
Normal file
226
MSNPSharp/DataTransfer/MSNSLPInvitationEventArgs.cs
Normal file
|
|
@ -0,0 +1,226 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace MSNPSharp.DataTransfer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Used as event argument when an invitation is received.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The client programmer must set the Accept property to true (accept) or false (reject) to response
|
||||||
|
/// to the invitation. By default the invitation is rejected.
|
||||||
|
/// </remarks>
|
||||||
|
[Serializable]
|
||||||
|
public class MSNSLPInvitationEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
private MSNSLPTransferProperties transferProperties;
|
||||||
|
private SLPMessage invitationMessage;
|
||||||
|
private ActivityInfo activity;
|
||||||
|
private MSNObject msnObject;
|
||||||
|
private string filename;
|
||||||
|
private long fileSize;
|
||||||
|
private bool accept;
|
||||||
|
private bool delayprocess;
|
||||||
|
|
||||||
|
[NonSerialized]
|
||||||
|
private P2PTransferSession transferSession = null;
|
||||||
|
[NonSerialized]
|
||||||
|
private MSNSLPHandler transferhandler = null;
|
||||||
|
|
||||||
|
|
||||||
|
public MSNSLPInvitationEventArgs(
|
||||||
|
MSNSLPTransferProperties transferProperties,
|
||||||
|
SLPMessage invitationMessage,
|
||||||
|
P2PTransferSession transferSession,
|
||||||
|
MSNSLPHandler handler)
|
||||||
|
{
|
||||||
|
this.transferProperties = transferProperties;
|
||||||
|
this.invitationMessage = invitationMessage;
|
||||||
|
this.transferSession = transferSession;
|
||||||
|
this.transferhandler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The affected transfer session
|
||||||
|
/// </summary>
|
||||||
|
public MSNSLPTransferProperties TransferProperties
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return transferProperties;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
transferProperties = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The affected transfer session
|
||||||
|
/// </summary>
|
||||||
|
public SLPMessage InvitationMessage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return invitationMessage;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
invitationMessage = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The activity properties.
|
||||||
|
/// </summary>
|
||||||
|
public ActivityInfo Activity
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
activity = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The corresponding msnobject defined in the invitation. Only available in case of an msn object
|
||||||
|
/// transfer (image display, emoticons).
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Created from the Context property of the <see cref="MSNSLPTransferProperties"/> object.
|
||||||
|
/// </remarks>
|
||||||
|
public MSNObject MSNObject
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return msnObject;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
msnObject = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the file the remote contact wants to send. Only available in case of a filetransfer session.
|
||||||
|
/// </summary>
|
||||||
|
public string Filename
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
filename = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The total size of the file in bytes. Only available in case of a filetransfer session.
|
||||||
|
/// </summary>
|
||||||
|
public long FileSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return fileSize;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
fileSize = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines if the transfer is accepted. This must be set by the client programmer in a event handler.
|
||||||
|
/// By default this property is set to false, which means the invitation is rejected. If this
|
||||||
|
/// property is set to true, the invitation is accepted.
|
||||||
|
/// </summary>
|
||||||
|
public bool Accept
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return accept;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
accept = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether process the invitation request right after the event was fired.
|
||||||
|
/// </summary>
|
||||||
|
public bool DelayProcess
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return delayprocess;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
delayprocess = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The p2p transfer session that will transfer the session data.
|
||||||
|
/// </summary>
|
||||||
|
public P2PTransferSession TransferSession
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return transferSession;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
transferSession = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Master session (SLP Handler)
|
||||||
|
/// </summary>
|
||||||
|
public MSNSLPHandler TransferHandler
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return transferhandler;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
589
MSNPSharp/DataTransfer/MSNSLPMessage.cs
Normal file
|
|
@ -0,0 +1,589 @@
|
||||||
|
#region Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions (http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice
|
||||||
|
/*
|
||||||
|
Copyright (c) 2002-2011, Bas Geertsema, Xih Solutions
|
||||||
|
(http://www.xihsolutions.net), Thiago.Sayao, Pang Wu, Ethem Evlice.
|
||||||
|
All rights reserved. http://code.google.com/p/msnp-sharp/
|
||||||
|
|
||||||
|
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 names of Bas Geertsema or Xih Solutions 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.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace MSNPSharp.DataTransfer
|
||||||
|
{
|
||||||
|
using MSNPSharp;
|
||||||
|
using MSNPSharp.Core;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Base SLP message for SLPStatusMessage and SLPRequestMessage.
|
||||||
|
/// Usually this message is contained in a P2P Message.
|
||||||
|
/// </summary>
|
||||||
|
[Serializable]
|
||||||
|
public abstract class SLPMessage : NetworkMessage
|
||||||
|
{
|
||||||
|
private Encoding encoding = Encoding.UTF8;
|
||||||
|
private MimeDictionary mimeHeaders = new MimeDictionary();
|
||||||
|
private MimeDictionary mimeBodies = new MimeDictionary();
|
||||||
|
|
||||||
|
private Guid GetEndPointIDFromMailEPIDString(string mailEPID)
|
||||||
|
{
|
||||||
|
if (mailEPID.Contains(";"))
|
||||||
|
{
|
||||||
|
return new Guid(mailEPID.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Guid.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected SLPMessage()
|
||||||
|
{
|
||||||
|
Via = "MSNSLP/1.0/TLP ";
|
||||||
|
Branch = Guid.NewGuid().ToString("B").ToUpperInvariant();
|
||||||
|
CSeq = 0;
|
||||||
|
CallId = Guid.NewGuid();
|
||||||
|
MaxForwards = 0;
|
||||||
|
ContentType = "text/unknown";
|
||||||
|
mimeHeaders[MimeHeaderStrings.Content_Length] = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SLPMessage(byte[] data)
|
||||||
|
{
|
||||||
|
ParseBytes(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract string StartLine
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defaults to UTF8
|
||||||
|
/// </summary>
|
||||||
|
public Encoding Encoding
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return encoding;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
encoding = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int MaxForwards
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return int.Parse(mimeHeaders[MimeHeaderStrings.Max_Forwards], System.Globalization.CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
mimeHeaders[MimeHeaderStrings.Max_Forwards] = value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string To
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mimeHeaders[MimeHeaderStrings.To];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string From
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mimeHeaders[MimeHeaderStrings.From];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Guid FromEndPoint
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string mailEpID = From.Replace("<msnmsgr:", String.Empty).Replace(">", String.Empty);
|
||||||
|
return GetEndPointIDFromMailEPIDString(mailEpID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Guid ToEndPoint
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string mailEpID = To.Replace("<msnmsgr:", String.Empty).Replace(">", String.Empty);
|
||||||
|
return GetEndPointIDFromMailEPIDString(mailEpID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The contact that send the message.
|
||||||
|
/// </summary>
|
||||||
|
public string FromMail
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return From.Replace("<msnmsgr:", String.Empty).Replace(">", String.Empty);
|
||||||
|
}
|
||||||
|
internal set
|
||||||
|
{
|
||||||
|
mimeHeaders[MimeHeaderStrings.From] = String.Format("<msnmsgr:{0}>", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The contact that receives the message.
|
||||||
|
/// </summary>
|
||||||
|
public string ToMail
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return To.Replace("<msnmsgr:", String.Empty).Replace(">", String.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal set
|
||||||
|
{
|
||||||
|
mimeHeaders[MimeHeaderStrings.To] = String.Format("<msnmsgr:{0}>", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Via
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mimeHeaders["Via"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
mimeHeaders["Via"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current branch this message applies to.
|
||||||
|
/// </summary>
|
||||||
|
public string Branch
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mimeHeaders["Via"]["branch"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
mimeHeaders["Via"]["branch"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sequence count of this message.
|
||||||
|
/// </summary>
|
||||||
|
public int CSeq
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return int.Parse(mimeHeaders["CSeq"], System.Globalization.CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
mimeHeaders["CSeq"] = value.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Guid CallId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new Guid(mimeHeaders["Call-ID"]);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
mimeHeaders["Call-ID"] = value.ToString("B").ToUpper(System.Globalization.CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ContentType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mimeHeaders[MimeHeaderStrings.Content_Type];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
mimeHeaders[MimeHeaderStrings.Content_Type] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains all name/value combinations of non-header fields in the message
|
||||||
|
/// </summary>
|
||||||
|
public MimeDictionary BodyValues
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return mimeBodies;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Builds the entire message and returns it as a byte array. Ready to be used in a P2P Message.
|
||||||
|
/// This function adds the 0x00 at the end of the message.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override byte[] GetBytes()
|
||||||
|
{
|
||||||
|
return GetBytes(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] GetBytes(bool appendNull)
|
||||||
|
{
|
||||||
|
string body = mimeBodies.ToString();
|
||||||
|
|
||||||
|
// Update the Content-Length header, +1 the additional 0x00
|
||||||
|
// mimeBodylength + \r\n\0
|
||||||
|
mimeHeaders[MimeHeaderStrings.Content_Length] = (body.Length + (appendNull ? 3 : 2)).ToString();
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder(512);
|
||||||
|
builder.Append(StartLine.Trim());
|
||||||
|
builder.Append("\r\n");
|
||||||
|
builder.Append(mimeHeaders.ToString());
|
||||||
|
builder.Append("\r\n");
|
||||||
|
builder.Append(body);
|
||||||
|
builder.Append("\r\n");
|
||||||
|
|
||||||
|
// get the bytes
|
||||||
|
byte[] message = Encoding.GetBytes(builder.ToString());
|
||||||
|
|
||||||
|
// add the additional 0x00
|
||||||
|
if (appendNull)
|
||||||
|
{
|
||||||
|
byte[] totalMessage = new byte[message.Length + 1];
|
||||||
|
message.CopyTo(totalMessage, 0);
|
||||||
|
totalMessage[message.Length] = 0x00;
|
||||||
|
|
||||||
|
return totalMessage;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses an MSNSLP message and stores the values in the object's fields.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The messagedata to parse</param>
|
||||||
|
public override void ParseBytes(byte[] data)
|
||||||
|
{
|
||||||
|
int lineLen = MSNHttpUtility.IndexOf(data, "\r\n");
|
||||||
|
byte[] lineData = new byte[lineLen];
|
||||||
|
Array.Copy(data, lineData, lineLen);
|
||||||
|
StartLine = Encoding.GetString(lineData).Trim();
|
||||||
|
|
||||||
|
byte[] header = new byte[data.Length - lineLen - 2];
|
||||||
|
Array.Copy(data, lineLen + 2, header, 0, header.Length);
|
||||||
|
|
||||||
|
mimeHeaders.Clear();
|
||||||
|
int mimeEnd = mimeHeaders.Parse(header);
|
||||||
|
|
||||||
|
byte[] body = new byte[header.Length - mimeEnd];
|
||||||
|
Array.Copy(header, mimeEnd, body, 0, body.Length);
|
||||||
|
|
||||||
|
mimeBodies.Clear();
|
||||||
|
mimeBodies.Parse(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Textual presentation.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Encoding.GetString(GetBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SLPMessage Parse(byte[] data)
|
||||||
|
{
|
||||||
|
int lineLen = MSNHttpUtility.IndexOf(data, "\r\n");
|
||||||
|
|
||||||
|
if (lineLen < 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte[] lineData = new byte[lineLen];
|
||||||
|
Array.Copy(data, lineData, lineLen);
|
||||||
|
string line = Encoding.UTF8.GetString(lineData);
|
||||||
|
|
||||||
|
if (!line.Contains("MSNSLP"))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (line.StartsWith("MSNSLP/1.0"))
|
||||||
|
return new SLPStatusMessage(data);
|
||||||
|
else
|
||||||
|
return new SLPRequestMessage(data);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The MSNSLP INVITE (request to create transfer),
|
||||||
|
/// BYE (request to close transfer),
|
||||||
|
/// ACK message (request for acknowledgement).
|
||||||
|
/// </summary>
|
||||||
|
public class SLPRequestMessage : SLPMessage
|
||||||
|
{
|
||||||
|
string method = "UNKNOWN";
|
||||||
|
string version = "MSNSLP/1.0";
|
||||||
|
|
||||||
|
public string Method
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return method;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
method = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Version
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
version = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string StartLine
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return String.Format("{0} {1}:{2} {3}", method, "MSNMSGR", ToMail, version);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
string[] chunks = value.Split(new string[] { " ", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
method = chunks[0];
|
||||||
|
version = chunks[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SLPRequestMessage(string to, string method)
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
this.ToMail = to;
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SLPRequestMessage(byte[] data)
|
||||||
|
: base(data)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a message which is send directly after the last data message.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static SLPRequestMessage CreateClosingMessage(MSNSLPTransferProperties transferProperties)
|
||||||
|
{
|
||||||
|
SLPRequestMessage slpMessage = new SLPRequestMessage(transferProperties.RemoteContactEPIDString, MSNSLPRequestMethod.BYE);
|
||||||
|
slpMessage.ToMail = transferProperties.RemoteContactEPIDString;
|
||||||
|
slpMessage.FromMail = transferProperties.LocalContactEPIDString;
|
||||||
|
|
||||||
|
slpMessage.Branch = transferProperties.LastBranch;
|
||||||
|
slpMessage.CSeq = 0;
|
||||||
|
slpMessage.CallId = transferProperties.CallId;
|
||||||
|
slpMessage.MaxForwards = 0;
|
||||||
|
slpMessage.ContentType = "application/x-msnmsgr-sessionclosebody";
|
||||||
|
|
||||||
|
slpMessage.BodyValues["SessionID"] = transferProperties.SessionId.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
if (transferProperties.DataType == DataTransferType.Activity)
|
||||||
|
{
|
||||||
|
slpMessage.BodyValues["Context"] = "dAMAgQ==";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return slpMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The MSNSLP OK, Decline, Internal Error message.
|
||||||
|
/// </summary>
|
||||||
|
public class SLPStatusMessage : SLPMessage
|
||||||
|
{
|
||||||
|
string version = "MSNSLP/1.0";
|
||||||
|
int code = 0;
|
||||||
|
string phrase = "Unknown";
|
||||||
|
|
||||||
|
public int Code
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
code = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Phrase
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return phrase;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
phrase = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Version
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
version = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string StartLine
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format("{0} {1} {2}", version, code, phrase);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
string[] chunks = value.Split(new string[] { " ", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
|
version = chunks[0];
|
||||||
|
int.TryParse(chunks[1], out code);
|
||||||
|
phrase = string.Empty;
|
||||||
|
|
||||||
|
for (int i = 2; i < chunks.Length; i++)
|
||||||
|
phrase += chunks[i] + " ";
|
||||||
|
|
||||||
|
phrase = phrase.Trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SLPStatusMessage(string to, int code, string phrase)
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
this.ToMail = to;
|
||||||
|
this.code = code;
|
||||||
|
this.phrase = phrase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SLPStatusMessage(byte[] data)
|
||||||
|
: base(data)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an 500 internal error message.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="transferProperties"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static SLPStatusMessage CreateInternalErrorMessage(MSNSLPTransferProperties transferProperties)
|
||||||
|
{
|
||||||
|
SLPStatusMessage slpMessage = new SLPStatusMessage(transferProperties.RemoteContactEPIDString, 500, "Internal Error");
|
||||||
|
slpMessage.ToMail = transferProperties.RemoteContactEPIDString;
|
||||||
|
slpMessage.FromMail = transferProperties.LocalContactEPIDString;
|
||||||
|
slpMessage.Branch = transferProperties.LastBranch;
|
||||||
|
slpMessage.CSeq = transferProperties.LastCSeq;
|
||||||
|
slpMessage.CallId = transferProperties.CallId;
|
||||||
|
slpMessage.MaxForwards = 0;
|
||||||
|
slpMessage.ContentType = "application/x-msnmsgr-sessionreqbody";
|
||||||
|
slpMessage.BodyValues["SessionID"] = transferProperties.SessionId.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||||
|
slpMessage.BodyValues["SChannelState"] = "0";
|
||||||
|
return slpMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a 200 OK message. This is called by the handler after the client-programmer
|
||||||
|
/// has accepted the invitation.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static SLPStatusMessage CreateAcceptanceMessage(MSNSLPTransferProperties properties)
|
||||||
|
{
|
||||||
|
SLPStatusMessage newMessage = new SLPStatusMessage(properties.RemoteContactEPIDString, 200, "OK");
|
||||||
|
newMessage.ToMail = properties.RemoteContactEPIDString;
|
||||||
|
newMessage.FromMail = properties.LocalContactEPIDString;
|
||||||
|
newMessage.Branch = properties.LastBranch;
|
||||||
|
newMessage.CSeq = 1;
|
||||||
|
newMessage.CallId = properties.CallId;
|
||||||
|
newMessage.ContentType = "application/x-msnmsgr-sessionreqbody";
|
||||||
|
newMessage.BodyValues["SessionID"] = properties.SessionId.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||||
|
return newMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a 603 Decline message.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static SLPStatusMessage CreateDeclineMessage(MSNSLPTransferProperties properties)
|
||||||
|
{
|
||||||
|
SLPStatusMessage newMessage = new SLPStatusMessage(properties.RemoteContactEPIDString, 603, "Decline");
|
||||||
|
newMessage.ToMail = properties.RemoteContactEPIDString;
|
||||||
|
newMessage.FromMail = properties.LocalContactEPIDString;
|
||||||
|
newMessage.Branch = properties.LastBranch;
|
||||||
|
newMessage.CSeq = 1;
|
||||||
|
newMessage.CallId = properties.CallId;
|
||||||
|
newMessage.ContentType = "application/x-msnmsgr-sessionreqbody";
|
||||||
|
newMessage.BodyValues["SessionID"] = properties.SessionId.ToString(System.Globalization.CultureInfo.InvariantCulture);
|
||||||
|
return newMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||