Ejemplo n.º 1
0
        /// <summary>
        /// 
        /// *************BUSCAR CAMPOS********************
        /// Efectua una busqueda al server de los campos por los cuales buscar
        /// cboServices.SelectedItem.ToString()
        /// </summary>
        private void RequestSearchFields(string jidServiceName)
        {
            //Example 1. Requesting Search Fields

            //<iq type='get'
            //    from='[email protected]/home'
            //    to='characters.shakespeare.lit'
            //    id='search1'
            //    xml:lang='en'>
            //  <query xmlns='jabber:iq:search'/>
            //</iq>


            cmdSearch.Enabled = false;

            SearchIq siq = new SearchIq();
            siq.Type = agsXMPP.protocol.client.IqType.get;
            //siq.To = new Jid(cboServices.SelectedItem.ToString());
            siq.To = new Jid(jidServiceName);

            // Remuevo alguna consulta pendiente si hay
            if (_IdFieldRequest != null)
                Util.XmppServices.XmppCon.IqGrabber.Remove(_IdFieldRequest);

            //guardo el Id de la nueva consulta 
            _IdFieldRequest = siq.Id;

            // Envio la consulta
            Util.XmppServices.XmppCon.IqGrabber.SendIq(siq, new IqCB(OnSearchFieldsResult), null);
        }
Ejemplo n.º 2
0
        private void RequestSearchFields()
        {
            //Example 1. Requesting Search Fields

            //<iq type='get'
            //    from='[email protected]/home'
            //    to='characters.shakespeare.lit'
            //    id='search1'
            //    xml:lang='en'>
            //  <query xmlns='jabber:iq:search'/>
            //</iq>

            // Disable the Search Button until we habe a Form to submit
            cmdSearch.Enabled = false;

            SearchIq siq = new SearchIq();
            siq.Type = agsXMPP.protocol.client.IqType.get;
            siq.To = new Jid(cboServices.SelectedItem.ToString());

            // dicard the pending requests if there is one
            if (_IdFieldRequest != null)
                m_XmppCon.IqGrabber.Remove(_IdFieldRequest);

            // and cache the id of the new pending request
            _IdFieldRequest = siq.Id;

            // finally send the query
            m_XmppCon.IqGrabber.SendIq(siq, new IqCB(OnSearchFieldsResult), null);
        }
Ejemplo n.º 3
0
            //SEND: 
            //<iq xmlns="jabber:client" id="agsXMPP_14" type="get" to="users.localhost">
            //    <query xmlns="jabber:iq:search" />
            //</iq>

            //RECV: 
            //<iq xmlns="jabber:client" from="users.localhost" to="test@localhost/MF" type="result" id="agsXMPP_14">
            //    <query xmlns="jabber:iq:search">
            //        <instructions />
            //        <x xmlns="jabber:x:data" type="form">
            //            <instructions>Use this form to search for users in the SoapBox User Directory.  Use '*' as a wildcard character.</instructions>
            //            <title>SoapBox User Directory</title>
            //            <field type="list-single" label="Group" var="role">
            //            <desc>Search for Users in the Group</desc>
            //            <option label="All"><value>0</value></option>
            //            <option label="Administrator"><value>103</value></option>
            //            </field>
            //            <field type="text-single" label="User Name" var="userName">
            //            <desc>User Name to Search for</desc>
            //            </field>
            //        </x>
            //    </query>
            //</iq>

            //SEND: 
            //<iq xmlns="jabber:client" id="agsXMPP_16" to="users.localhost" type="set">
            //    <query xmlns="jabber:iq:search">
            //        <x xmlns="jabber:x:data" type="submit">
            //            <field type="text-single" var="userName">
            //                <value>test</value>
            //            </field>
            //            <field type="list-single" var="role">
            //                <value>0</value>
            //            </field>
            //        </x>
            //    </query>
            //</iq>

            //RECV: 
            //<iq xmlns="jabber:client" from="users.localhost" to="test@localhost/MF" type="result" id="agsXMPP_16">
            //    <query xmlns="jabber:iq:search">
            //        <x xmlns="jabber:x:data" type="result">
            //            <title>UserRecords</title>
            //            <reported>
            //                <field type="hidden" label="JabberID" var="jid"/>
            //                <field type="text-single" label="User Name" var="UserJIDNode"/>
            //                <field type="text-single" label="Domain" var="UserJIDDomain"/>
            //                <field type="boolean" label="MessageLogging" var="MessageLogging">
            //                    <value>0</value>
            //                </field>
            //                <field type="int32-single" label="ActualMaxRecords" var="ActualMaxRecords"/>
            //            </reported>
            //            <item>
            //                <field type="hidden" label="JabberID" var="jid">
            //                    <value>test@localhost</value>
            //                </field>
            //                <field type="text-single" label="User Name" var="UserJIDNode">
            //                    <value>test</value>
            //                </field>
            //                <field type="text-single" label="Domain" var="UserJIDDomain">
            //                    <value>localhost</value>
            //                </field>
            //                <field type="boolean" label="MessageLogging" var="MessageLogging">
            //                    <value>0</value>
            //                </field>
            //                <field type="int32-single" label="ActualMaxRecords" var="ActualMaxRecords">
            //                    <value>3</value>
            //                </field>
            //            </item>
            //            <item>
            //                <field type="hidden" label="JabberID" var="jid">
            //                    <value>test2@localhost</value>
            //                </field>
            //                <field type="text-single" label="User Name" var="UserJIDNode">
            //                    <value>test2</value>
            //                </field>
            //                <field type="text-single" label="Domain" var="UserJIDDomain">
            //                    <value>localhost</value>
            //                </field>
            //                <field type="boolean" label="MessageLogging" var="MessageLogging">
            //                    <value>0</value>
            //                </field>
            //                <field type="int32-single" label="ActualMaxRecords" var="ActualMaxRecords">
            //                    <value>3</value>
            //                </field>
            //            </item>
            //            <item>
            //                <field type="hidden" label="JabberID" var="jid">
            //                    <value>test3@localhost</value>
            //                </field>
            //                <field type="text-single" label="User Name" var="UserJIDNode">
            //                    <value>test3</value>
            //                </field>
            //                <field type="text-single" label="Domain" var="UserJIDDomain">
            //                    <value>localhost</value>
            //                </field>
            //                <field type="boolean" label="MessageLogging" var="MessageLogging">
            //                    <value>0</value>
            //                </field>
            //                <field type="int32-single" label="ActualMaxRecords" var="ActualMaxRecords">
            //                    <value>3</value>
            //                </field>
            //            </item>
            //        </x>
            //    </query>
            //</iq>
            private void ProcessSearchIQ(IQ iq)
            {
                agsXMPP.protocol.iq.search.SearchIq searchIq = new SearchIq(IqType.result);
                searchIq.Id = iq.Id;
                searchIq.From = iq.To;
                searchIq.To = this.m_ClientAccount.JID;

                if (iq.Type == IqType.get)
                {
                    searchIq.Query.Instructions = "Fill in a field to search for any matching Jabber User";

                    //  <UserID>test</UserID>
                    //  <UserName>test</UserName>
                    //  <Password>test</Password>
                    //  <Role>0</Role>
                    //  <Privacy></Privacy>
                    //  <Privilege>0</Privilege>

                    Data data = new Data(XDataFormType.form);
                    data.Instructions = "Use this form to search for users in the SiteView MF User Directory.  Use '*' as a wildcard character.";
                    data.Title = "SiteView MF User Directory";

                    searchIq.Query.Data = data;

                    Field field = null;
                    Option option = null;

                    //field = new Field();
                    //field.Type = FieldType.List_Single;
                    //field.Label = "Group";
                    //field.Var = "Group";
                    //field.Description = "Search for Users in the Group";

                    //option = new Option("All", "0");
                    //field.AddOption(option);

                    //option = new Option("SiteView", "1");
                    //field.AddOption(option);

                    //data.AddField(field);

                    field = new Field();
                    field.Type = FieldType.Text_Single;
                    field.Label = "User ID";
                    field.Var = "UserID";
                    field.Description = "User ID to Search for";
                    data.AddField(field);

                    field = new Field();
                    field.Type = FieldType.Text_Single;
                    field.Label = "User Name";
                    field.Var = "UserName";
                    field.Description = "User Name to Search for";
                    data.AddField(field);

                    //searchIq.Query.AddTag("Role");
                    //searchIq.Query.AddTag("Group");
                    //searchIq.Query.AddTag("Privilege");

                }
                else if (iq.Type == IqType.set)
                {
                    Search search = iq.Query as Search;
                    Data xOldData = search.Data;

                    if (xOldData.Type == XDataFormType.submit)
                    {

                        string strUserID = xOldData.GetField("UserID").GetValue();
                        string strUserName = xOldData.GetField("UserName").GetValue();

                        //string strGroup = xOldData.GetField("Group").GetValue();
                        //if (strGroup == "0")
                        //{
                        //    strGroup = string.Empty;
                        //}
                        //else if (strGroup == "1")
                        //{
                        //    strGroup = "SiteView";
                        //}
                        //else
                        //{
                        //    strGroup = null;
                        //}

                        Data data = new Data(XDataFormType.result);
                        data.Title = "UserRecords";

                        searchIq.Query.Data = data;

                        Reported reported = new Reported();
                        data.Reported = reported;

                        Field field = null;

                        field = new Field();
                        field.Type = FieldType.Hidden;
                        field.Label = "Jabber ID";
                        field.Var = "JID";
                        reported.AddField(field);

                        //field = new Field();
                        //field.Type = FieldType.Text_Single;
                        //field.Label = "Group";
                        //field.Var = "Group";
                        //reported.AddField(field);

                        field = new Field();
                        field.Type = FieldType.Text_Single;
                        field.Label = "User ID";
                        field.Var = "UserID";
                        reported.AddField(field);

                        field = new Field();
                        field.Type = FieldType.Text_Single;
                        field.Label = "User Name";
                        field.Var = "UserName";
                        reported.AddField(field);

                        //company........continue....
                        foreach (Account account in this.m_Server.AccountManager.Accounts)
                        {
                            if (account.Type != AccountType.User)
                            {
                                continue;
                            }

                            if (strUserID != null && account.UserID.IndexOf(strUserID) < 0)
                            {
                                continue;
                            }

                            if (strUserName != null && account.UserName.IndexOf(strUserName) < 0)
                            {
                                continue;
                            }

                            //if (strGroup != null && account.Group.IndexOf(strGroup) < 0)
                            //{
                            //    continue;
                            //}

                            Item item = data.AddItem();

                            field = item.AddField();
                            field.Type = FieldType.Hidden;
                            field.Label = "Jabber ID";
                            field.Var = "JID";
                            field.SetValue(account.JID.ToString());

                            //field = item.AddField();
                            //field.Type = FieldType.Text_Single;
                            //field.Label = "Group";
                            //field.Var = "Group";
                            //field.SetValue(account.Group);

                            field = item.AddField();
                            field.Type = FieldType.Text_Single;
                            field.Label = "User ID";
                            field.Var = "UserID";
                            field.SetValue(account.UserID);

                            field = item.AddField();
                            field.Type = FieldType.Text_Single;
                            field.Label = "User Name";
                            field.Var = "UserName";
                            field.SetValue(account.UserName);

                        }
                    }
                }

                Send(searchIq);
            }
Ejemplo n.º 4
0
        private void cmdSearch_Click(object sender, EventArgs e)
        {
            /*

             Example 8. Entity Submits Search Form

             <iq type='set'
                 from='[email protected]/balcony'
                 to='characters.shakespeare.lit'
                 id='search4'
                 xml:lang='en'>
               <query xmlns='jabber:iq:search'>
                 <x xmlns='jabber:x:data' type='submit'>
                   <field type='hidden' var='FORM_TYPE'>
                     <value>jabber:iq:search</value>
                   </field>
                   <field var='gender'>
                     <value>male</value>
                   </field>
                 </x>
               </query>
             </iq>
             */

            IQ siq = null;
            if (!_IsOldSearch)
            {
                // Validate the Form before we submit it
                if (xDataControl.Validate())
                {
                    siq = new SearchIq();
                    //siq.To = xDataControl.From;
                    //siq.Type = IqType.set;
                    ((SearchIq)siq).Query.Data = xDataControl.CreateResponse();
                }
            }
            else
            {
                siq = new IQ();
                siq.GenerateId();
                siq.Query = xDataControl.CreateSearchResponse();
            }

            siq.To = xDataControl.From;
            siq.Type = IqType.set;
            // dicard the pending requests if there is one
            if (_IdSearchRequest != null)
                m_XmppCon.IqGrabber.Remove(_IdSearchRequest);

            // and cache the id of the new pending request
            _IdSearchRequest = siq.Id;

            // finally send the query
            m_XmppCon.IqGrabber.SendIq(siq, new IqCB(OnSearchResult), null);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Efectuar consulta 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdSearch_Click(object sender, EventArgs e)
        {
            /*
            
             Ejemlo Entity Submits Search Form

             <iq type='set'
                 from='[email protected]/balcony'
                 to='characters.shakespeare.lit'
                 id='search4'
                 xml:lang='en'>
               <query xmlns='jabber:iq:search'>
                 <x xmlns='jabber:x:data' type='submit'>
                   <field type='hidden' var='FORM_TYPE'>
                     <value>jabber:iq:search</value>
                   </field>
                   <field var='gender'>
                     <value>male</value>
                   </field>
                 </x>
               </query>
             </iq>
             */

            IQ searchIQ = null;
            if (!_IsOldSearch)
            {
                // validar entrada de datos
                if (xDataControl.Validate())
                {
                    searchIQ = new SearchIq();
                    //siq.To = xDataControl.From;
                    //siq.Type = IqType.set;
                    ((SearchIq)searchIQ).Query.Data = xDataControl.CreateResponse();
                }
            }
            else
            {
                searchIQ = new IQ();
                searchIQ.GenerateId();
                searchIQ.Query = xDataControl.CreateSearchResponse();
            }

            searchIQ.To = xDataControl.From;
            searchIQ.Type = IqType.set;
            // Elimino alguna antigua si existe
            if (_IdSearchRequest != null)
                Util.XmppServices.XmppCon.IqGrabber.Remove(_IdSearchRequest);

            // Guardo la actual consulta
            _IdSearchRequest = searchIQ.Id;

            // Envio el Iq
            Util.XmppServices.XmppCon.IqGrabber.SendIq(searchIQ, new IqCB(OnSearchResult), null);
        }