Snippets: Msnp - PersonCreation

// SOCKSArmor Snippets - MSNP.
// Author: Felipe Kellermann <felipek@socksarmor.org>
// Revision: $Revision: 5395 $
// Date: $Date: 2008-01-03 18:05:06 -0200 (Thu, 03 Jan 2008) $
//
// This snippet shows the creation of *three* person objects, one being
// a regular user, the other being a profile (a super) and the last one
// being a contact object.  All these object "facets" differ only based
// on the *handle* format used in the object's construction.
//
// IMPORTANT:
// Note that all the properties being set to the objects are *optional*
// and do not represent all the possible properties for these objects.

using System;
using SocksArmor;
using SocksArmor.Plugins.Msnp;

class SocksArmorSnippet
{
    static void Main(string[] args)
    {
        // Remote SOCKSArmor server.
        RemoteServer server = new RemoteServer();
        server.Connect("127.0.0.1", 10842, "username", "password");

        // Msnp plugin interface.
        MsnpPlugin msnp = server.Plugins["msnp"].Interface as MsnpPlugin;

        // This instance will represent an *user*.
        // Note that its handle is a "fully qualified address".
        MsnpPerson user = new MsnpPerson("TestingUser", "user@mail.com");
        user.Description = "Just a testing user";
        user.Disabled = true;
        user.FixedFriendly = true;
        user.Friendly = "Testing%20User";

        // Registers the instance on the server.
        msnp.Objects.Add(user);

        // This instance will represent a *super* (profile).
        // Note that it has no handle.
        MsnpPerson profile = new MsnpPerson("TestingProfile");
        profile.Description = "Just a testing profile";

        // Registers the instance on the server.
        msnp.Objects.Add(profile);

        // This instance will represent a *contact*.
        // Note that its handle is represented by a regular expression.
        MsnpPerson contact = new MsnpPerson("TestingContact", "/.*@mail.com/");
        contact.Description = "Just a testing contact";

        // Registers the instance on the server.
        msnp.Objects.Add(contact);

        server.Disconnect();
    }
}