Agents.cs :  » Network-Clients » Jabber-Net » jabber » protocol » iq » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Network Clients » Jabber Net 
Jabber Net » jabber » protocol » iq » Agents.cs
/* --------------------------------------------------------------------------
 *
 * License
 *
 * The contents of this file are subject to the Jabber Open Source License
 * Version 1.0 (the "License").  You may not copy or use this file, in either
 * source code or executable form, except in compliance with the License.  You
 * may obtain a copy of the License at http://www.jabber.com/license/ or at
 * http://www.opensource.org/.  
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * Copyrights
 * 
 * Portions created by or assigned to Cursive Systems, Inc. are 
 * Copyright (c) 2002 Cursive Systems, Inc.  All Rights Reserved.  Contact
 * information for Cursive Systems, Inc. is available at http://www.cursive.net/.
 *
 * Portions Copyright (c) 2002 Joe Hildebrand.
 * 
 * Acknowledgements
 * 
 * Special thanks to the Jabber Open Source Contributors for their
 * suggestions and support of Jabber.
 * 
 * --------------------------------------------------------------------------*/
using System;
using System.Xml;

using bedrock.util;

namespace jabber.protocol.iq{
    // <pre>
    // <iq from='jabber.org' id='jcl_17' to='hildjj@jabber.org/Work' type='result'>
    //   <query xmlns='jabber:iq:agents'>
    //     <agent jid='users.jabber.org'>
    //       <name>Jabber User Directory</name>
    //       <service>jud</service>
    //       <search/>
    //       <register/>
    //     </agent>
    //   </query>
    // </iq>
    // </pre>
    /// <summary>
    /// IQ packet with an agents query element inside.
    /// </summary>
    [RCS(@"$Header: /home/cvs/jabber-net/jabber/protocol/iq/Agents.cs,v 1.1 2002/07/11 21:59:37 hildjj Exp $")]
    public class AgentsIQ : jabber.protocol.client.IQ
    {
        /// <summary>
        /// Create an agents IQ packet.
        /// </summary>
        /// <param name="doc"></param>
        public AgentsIQ(XmlDocument doc) : base(doc)
        {
            this.Query = new AgentsQuery(doc);
        }
    }
    /// <summary>
    /// An agents query element.
    /// </summary>
    [RCS(@"$Header: /home/cvs/jabber-net/jabber/protocol/iq/Agents.cs,v 1.1 2002/07/11 21:59:37 hildjj Exp $")]
    public class AgentsQuery : Element
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="doc"></param>
        public AgentsQuery(XmlDocument doc) : base("query", URI.AGENTS, doc)
        {
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="prefix"></param>
        /// <param name="qname"></param>
        /// <param name="doc"></param>
        public AgentsQuery(string prefix, XmlQualifiedName qname, XmlDocument doc) :
            base(prefix, qname, doc)
        {
        }

        /// <summary>
        /// Add an agent to the list
        /// </summary>
        /// <returns></returns>
        public Agent AddAgent()
        {
            Agent i = new Agent(this.OwnerDocument);
            AddChild(i);
            return i;
        }

        /// <summary>
        /// Get the list of agents
        /// </summary>
        /// <returns></returns>
        public Agent[] GetAgents()
        {
            XmlNodeList nl = GetElementsByTagName("agent", URI.AGENTS);
            Agent[] items = new Agent[nl.Count];
            int i=0;
            foreach (XmlNode n in nl)
            {
                items[i] = (Agent) n;
                i++;
            }
            return items;
        }
    }

    /// <summary>
    /// Agent items
    /// </summary>
    [RCS(@"$Header: /home/cvs/jabber-net/jabber/protocol/iq/Agents.cs,v 1.1 2002/07/11 21:59:37 hildjj Exp $")]
    public class Agent : Element
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="doc"></param>
        public Agent(XmlDocument doc) : base("agent", URI.AGENTS, doc)
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="prefix"></param>
        /// <param name="qname"></param>
        /// <param name="doc"></param>
        public Agent(string prefix, XmlQualifiedName qname, XmlDocument doc) :
            base(prefix, qname, doc)
        {
        }

        /// <summary>
        /// The agent's JID
        /// </summary>
        public JID JID
        {
            get { return new JID(GetAttribute("jid")); }
            set { this.SetAttribute("jid", value.ToString()); }
        }

        /// <summary>
        /// The agent's name
        /// </summary>
        public string AgentName
        {
            get { return GetElem("name"); }
            set { SetElem("name", value); }
        }

        /// <summary>
        /// The agent's description
        /// </summary>
        public string Description
        {
            get { return GetElem("description"); }
            set { SetElem("description", value); }
        }

        /// <summary>
        /// Is the agent a transport?
        /// </summary>
        public bool Transport 
        {
            get { return GetElem("transport") != null; }
            set 
            { 
                if (value)
                {
                    SetElem("transport", null);
                }
                else
                {
                    RemoveElem("transport");
                }
            }
        }

        /// <summary>
        /// Is the agent for groupchat?
        /// </summary>
        public bool Groupchat 
        {
            get { return GetElem("groupchat") != null; }
            set 
            { 
                if (value)
                {
                    SetElem("groupchat", null);
                }
                else
                {
                    RemoveElem("groupchat");
                }
            }
        }

        /// <summary>
        /// The agent service name.
        /// </summary>
        public string Service 
        {
            get { return GetElem("service"); }
            set { SetElem("service", value); }
        }

        /// <summary>
        /// Is the agent a registrar?
        /// </summary>
        public bool Register 
        {
            get { return GetElem("register") != null; }
            set 
            { 
                if (value)
                {
                    SetElem("register", null);
                }
                else
                {
                    RemoveElem("register");
                }
            }
        }

        /// <summary>
        /// Is the agent for JUD?
        /// </summary>
        public bool Search 
        {
            get { return GetElem("search") != null; }
            set 
            { 
                if (value)
                {
                    SetElem("search", null);
                }
                else
                {
                    RemoveElem("search");
                }
            }
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.