Exemplo n.º 1
0
        public FileTransfer(XmppClientConnection XmppCon, IQ iq)
        {
            Console.WriteLine("Accepting a file from " + iq.From.ToString());

            siIq = iq;
            si   = iq.SelectSingleElement(typeof(agsXMPP.protocol.extensions.si.SI)) as agsXMPP.protocol.extensions.si.SI;
            // get SID for file transfer
            m_Sid  = si.Id;
            m_From = iq.From;

            file          = si.File;
            m_lFileLength = file.Size;

            m_XmppCon = XmppCon;

            XmppCon.OnIq += new IqHandler(XmppCon_OnIq);

            agsXMPP.protocol.extensions.featureneg.FeatureNeg fNeg = si.FeatureNeg;
            if (fNeg != null)
            {
                agsXMPP.protocol.x.data.Data data = fNeg.Data;
                if (data != null)
                {
                    agsXMPP.protocol.x.data.Field[] field = data.GetFields();
                    if (field.Length == 1)
                    {
                        Dictionary <string, string> methods = new Dictionary <string, string>();
                        foreach (agsXMPP.protocol.x.data.Option o in field[0].GetOptions())
                        {
                            string val = o.GetValue();
                            methods.Add(val, val);
                        }
                        if (methods.ContainsKey(agsXMPP.Uri.BYTESTREAMS))
                        {
                            // supports bytestream, so choose this option
                            agsXMPP.protocol.extensions.si.SIIq sIq = new agsXMPP.protocol.extensions.si.SIIq();
                            sIq.Id   = siIq.Id;
                            sIq.To   = siIq.From;
                            sIq.Type = IqType.result;

                            sIq.SI.Id         = si.Id;
                            sIq.SI.FeatureNeg = new agsXMPP.protocol.extensions.featureneg.FeatureNeg();

                            Data xdata = new Data();
                            xdata.Type = XDataFormType.submit;
                            Field f = new Field();
                            //f.Type = FieldType.List_Single;
                            f.Var = "stream-method";
                            f.AddValue(agsXMPP.Uri.BYTESTREAMS);
                            xdata.AddField(f);
                            sIq.SI.FeatureNeg.Data = xdata;

                            m_XmppCon.Send(sIq);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void addFieldInDataIQ(agsXMPP.protocol.x.data.Data data, string fieldname, string value)
        {
            Field field = new Field();

            field.Var = fieldname;
            agsXMPP.Xml.Dom.Element e = new agsXMPP.Xml.Dom.Element("value", value);
            field.AddChild(e);
            data.AddChild(field);
        }
Exemplo n.º 3
0
		public frmXData(Data data)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			this.xDataControl1.CreateForm(data);
		}
        public agsXMPP.protocol.x.data.Data GetResult()
        {
            agsXMPP.protocol.x.data.Data data = new agsXMPP.protocol.x.data.Data(XDataFormType.submit);

            foreach ( XDataControl control in _container.Children )
            {
                data.AddChild( control.GetResult() ) ;
            }

            return data ;
        }
Exemplo n.º 5
0
        private void cmdAccept_Click(object sender, EventArgs e)
        {
            cmdAccept.Enabled = false;
            cmdRefuse.Enabled = false;

            agsXMPP.protocol.extensions.featureneg.FeatureNeg fNeg = si.FeatureNeg;
            if (fNeg != null)
            {
                agsXMPP.protocol.x.data.Data data = fNeg.Data;
                if (data != null)
                {
                    agsXMPP.protocol.x.data.Field[] field = data.GetFields();
                    if (field.Length == 1)
                    {
                        Dictionary <string, string> methods = new Dictionary <string, string>();
                        foreach (agsXMPP.protocol.x.data.Option o in field[0].GetOptions())
                        {
                            string val = o.GetValue();
                            methods.Add(val, val);
                        }
                        if (methods.ContainsKey(agsXMPP.Uri.BYTESTREAMS))
                        {
                            // supports bytestream, so choose this option
                            agsXMPP.protocol.extensions.si.SIIq sIq = new agsXMPP.protocol.extensions.si.SIIq();
                            sIq.Id   = siIq.Id;
                            sIq.To   = siIq.From;
                            sIq.Type = IqType.result;

                            sIq.SI.Id         = si.Id;
                            sIq.SI.FeatureNeg = new agsXMPP.protocol.extensions.featureneg.FeatureNeg();

                            Data xdata = new Data();
                            xdata.Type = XDataFormType.submit;
                            Field f = new Field();
                            //f.Type = FieldType.List_Single;
                            f.Var = "stream-method";
                            f.AddValue(agsXMPP.Uri.BYTESTREAMS);
                            xdata.AddField(f);
                            sIq.SI.FeatureNeg.Data = xdata;

                            m_XmppCon.Send(sIq);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void OnRequestConfiguration(object sender, IQ iq, object obj)
        {
            agsXMPP.protocol.x.muc.iq.owner.OwnerIq oIq = new agsXMPP.protocol.x.muc.iq.owner.OwnerIq();
            oIq.Type = IqType.set;
            oIq.To   = iq.From;
            agsXMPP.protocol.x.data.Data data = new agsXMPP.protocol.x.data.Data(XDataFormType.submit);

            addFieldInDataIQ(data, "FORM_TYPE", "http://jabber.org/protocol/muc#roomconfig");
            addFieldInDataIQ(data, "muc#roomconfig_roomname", roomName);
            addFieldInDataIQ(data, "muc#roomconfig_roomdesc", roomDesc);
            addFieldInDataIQ(data, "muc#roomconfig_persistentroom", persistRoom);
            addFieldInDataIQ(data, "muc#roomconfig_publicroom", "1");
            addFieldInDataIQ(data, "public_list", "1");
            addFieldInDataIQ(data, "muc#roomconfig_passwordprotectedroom", (password == "") ? "0" : "1");
            addFieldInDataIQ(data, "muc#roomconfig_roomsecret", "");
            addFieldInDataIQ(data, "muc#roomconfig_maxusers", "1000");
            addFieldInDataIQ(data, "muc#roomconfig_whois", "moderators");
            addFieldInDataIQ(data, "muc#roomconfig_membersonly", "0");
            addFieldInDataIQ(data, "muc#roomconfig_moderatedroom", "1");
            addFieldInDataIQ(data, "members_by_default", "0");
            addFieldInDataIQ(data, "muc#roomconfig_membersonly", "0");
            addFieldInDataIQ(data, "muc#roomconfig_membersonly", "0");
            addFieldInDataIQ(data, "muc#roomconfig_changesubject", "1");
            addFieldInDataIQ(data, "allow_private_messages", "1");
            addFieldInDataIQ(data, "allow_private_messages_from_visitors", "anyone");
            addFieldInDataIQ(data, "allow_query_users", "1");
            addFieldInDataIQ(data, "muc#roomconfig_allowinvites", "0");
            addFieldInDataIQ(data, "muc#roomconfig_allowvisitorstatus", "1");
            addFieldInDataIQ(data, "muc#roomconfig_allowvisitornickchange", "0");
            addFieldInDataIQ(data, "muc#roomconfig_allowvoicerequests", "1");
            addFieldInDataIQ(data, "muc#roomconfig_voicerequestmininterval", "1800");
            addFieldInDataIQ(data, "muc#roomconfig_captcha_whitelist", "");
            addFieldInDataIQ(data, "muc#roomconfig_enablelogging", savingHistory);

            oIq.Query.AddChild(data);
            Settings.xmpp.IqGrabber.SendIq(oIq, new IqCB(OnGetFieldsResult), null);
        }
Exemplo n.º 7
0
        public void Accept()
        {
            FeatureNeg fNeg = _si.FeatureNeg;

            bool ok = false;

            if (fNeg != null)
            {
                agsXMPP.protocol.x.data.Data data = fNeg.Data;

                if (data != null)
                {
                    Field[] field = data.GetFields();

                    if (field.Length == 1)
                    {
                        Dictionary<string, string> methods = new Dictionary<string, string>();
                        foreach (Option o in field[0].GetOptions())
                        {
                            string val = o.GetValue();
                            methods.Add(val, val);
                        }

                        if (methods.ContainsKey(Uri.BYTESTREAMS))
                        {
                            // supports bytestream, so choose this option
                            SIIq sIq = new SIIq();
                            sIq.Id = _siIq.Id;
                            sIq.To = _siIq.From;
                            sIq.Type = IqType.result;

                            sIq.SI.Id = _si.Id;
                            sIq.SI.FeatureNeg = new FeatureNeg();

                            agsXMPP.protocol.x.data.Data xdata = new agsXMPP.protocol.x.data.Data();
                            xdata.Type = XDataFormType.submit;
                            Field f = new Field();
                            //f.Type = FieldType.List_Single;
                            f.Var = "stream-method";
                            f.AddValue(Uri.BYTESTREAMS);
                            xdata.AddField(f);
                            sIq.SI.FeatureNeg.Data = xdata;

                            _xmppConnection.OnIq += _xmppConnection_OnIq;
                            _xmppConnection.Send(sIq);

                            ok = true;
                        }
                    }
                }
            }

            if (ok)
            {
                State = FileTransferState.WaitingForResponse;
            }
            else
            {
                State = FileTransferState.Error;
                EventErrorFileTransfer transfer =
                    new EventErrorFileTransfer("Error while negotiating file transfer conditions");
                Events.Instance.OnEvent(this, transfer);
            }
        }
Exemplo n.º 8
0
        private void SendSiIq()
        {
            SIIq iq = new SIIq();
            iq.To = Contact.FullJid;
            iq.Type = IqType.set;

            File afile;
            afile = new File(Path.GetFileName(FileName), _fileLength);

            afile.Description = FileDescription;
            afile.Range = new Range();

            FeatureNeg fNeg = new FeatureNeg();

            agsXMPP.protocol.x.data.Data data = new agsXMPP.protocol.x.data.Data(XDataFormType.form);
            Field f = new Field(FieldType.List_Single);
            f.Var = "stream-method";
            f.AddOption().SetValue(Uri.BYTESTREAMS);
            data.AddField(f);

            fNeg.Data = data;

            iq.SI.File = afile;
            iq.SI.FeatureNeg = fNeg;
            iq.SI.Profile = Uri.SI_FILE_TRANSFER;

            _sid = Guid.NewGuid().ToString();
            iq.SI.Id = _sid;

            _xmppConnection.IqGrabber.SendIq(iq, new IqCB(SiIqResult), null);

            State = FileTransferState.WaitingForResponse;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates the XData Response Element from the entered Data in the GUI Form
        /// </summary>
        /// <returns></returns>
        public Data CreateResponse()
        {
            Data data = new Data(XDataFormType.submit);
            foreach(XDataFieldControl ctl in panelFields.Controls)
            {
                Type type = ctl.GetType();

                if ( type == typeof(XDataTextBox) )
                {
                    Field f;
                    XDataTextBox txt = ctl as XDataTextBox;
                    if (txt.Multiline == true)
                    {
                        f = new Field(FieldType.Text_Multi);
                    }
                    else
                    {
                        if (txt.IsPrivate)
                            f = new Field(FieldType.Text_Private);
                        else
                            f = new Field(FieldType.Text_Single);

                    }
                    f.AddValues(txt.Values);
                    f.Var = txt.Var;
                    data.AddField(f);

                }
                else if ( type == typeof(XDataHidden) )
                {
                    Field f;
                    XDataHidden hidden = ctl as XDataHidden;

                    f = new Field(FieldType.Hidden);

                    f.AddValue(hidden.Value);
                    f.Var = hidden.Var;

                    data.AddField(f);
                }
                else if ( type == typeof(XDataJidSingle) )
                {
                    XDataJidSingle jids = ctl as XDataJidSingle;
                    Field f = new Field(FieldType.Jid_Single);
                    f.SetValue(jids.Value);
                    f.Var = jids.Var;
                    data.AddField(f);
                }
                else if ( type == typeof(XDataJidMulti) )
                {
                    XDataJidMulti jidm = ctl as XDataJidMulti;
                    Field f = new Field(FieldType.Jid_Multi);
                    f.AddValues(jidm.Values);
                    f.Var = jidm.Var;
                    data.AddField(f);

                }
                else if ( type == typeof(XDataCheckBox) )
                {
                    XDataCheckBox chk = ctl as XDataCheckBox;
                    Field f = new Field(FieldType.Boolean);
                    f.SetValueBool(chk.Value);
                    f.Var = chk.Var;
                    data.AddField(f);
                }
                else if ( type == typeof(XDataListMulti) )
                {
                    XDataListMulti listm = ctl as XDataListMulti;
                    Field f = new Field(FieldType.List_Multi);
                    f.AddValues(listm.Values);
                    f.Var = listm.Var;
                    data.AddField(f);
                }
                else if ( type == typeof(XDataListSingle) )
                {
                    XDataListSingle lists = ctl as XDataListSingle;
                    Field f = new Field(FieldType.List_Single);
                    f.SetValue(lists.Value);
                    f.Var = lists.Var;
                    data.AddField(f);
                }
            }

            return data;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates the Xdata from from the given XData Element
        /// </summary>
        /// <param name="xdata"></param>
        public void CreateForm(Data xdata)
        {
            this.SuspendLayout();

            this.panelFields.SuspendLayout();
            this.panelFields.Controls.Clear();

            lblTitle.Text			= xdata.Title;
            lblInstructions.Text	= xdata.Instructions;

            XDataControl_Resize(this, null);

            Field[] fields = xdata.GetFields();
            for (int i = fields.Length -1; i >= 0; i--)
            {
                CreateField(fields[i], i);
            }

            this.panelFields.ResumeLayout();

            this.ResumeLayout();
        }
Exemplo n.º 11
0
        private void SendSiIq()
        {
            /*
            Recv:
            <iq xmlns="jabber:client" from="[email protected]/Psi" to="[email protected]/SharpIM"
            type="set" id="aab4a"> <si xmlns="http://jabber.org/protocol/si"
            profile="http://jabber.org/protocol/si/profile/file-transfer" id="s5b_405645b6f2b7c681"> <file
            xmlns="http://jabber.org/protocol/si/profile/file-transfer" size="719" name="Kunden.dat"> <range />
            </file> <feature xmlns="http://jabber.org/protocol/feature-neg"> <x xmlns="jabber:x:data" type="form">
            <field type="list-single" var="stream-method"> <option>
            <value>http://jabber.org/protocol/bytestreams</value> </option> </field> </x> </feature> </si> </iq>

            Send: <iq xmlns="jabber:client" id="agsXMPP_5" to="[email protected]/Psi" type="set">
             <si xmlns="http://jabber.org/protocol/si" id="af5a2e8d-58d4-4038-8732-7fb348ff767f">
             <file xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="ALEX1.JPG" size="22177"><range /></file>
             <feature xmlns="http://jabber.org/protocol/feature-neg"><x xmlns="jabber:x:data" type="form">
            <field type="list-single" var="stream-method"><option>http://jabber.org/protocol/bytestreams</option></field></x></feature></si></iq>

            Send:
            <iq xmlns="jabber:client" id="aab4a" to="[email protected]/Psi" type="result"><si
            xmlns="http://jabber.org/protocol/si" id="s5b_405645b6f2b7c681"><feature
            xmlns="http://jabber.org/protocol/feature-neg"><x xmlns="jabber:x:data" type="submit"><field
            var="stream-
            method"><value>http://jabber.org/protocol/bytestreams</value></field></x></feature></si></iq>

            Recv:
            <iq xmlns="jabber:client" from="[email protected]/Psi" to="[email protected]/SharpIM"
            type="set" id="aab6a"> <query xmlns="http://jabber.org/protocol/bytestreams" sid="s5b_405645b6f2b7c681"
            mode="tcp"> <streamhost port="8010" jid="[email protected]/Psi" host="192.168.74.142" /> <streamhost
            port="7777" jid="proxy.ag-software.de" host="82.165.34.23"> <proxy
            xmlns="http://affinix.com/jabber/stream" /> </streamhost> <fast xmlns="http://affinix.com/jabber/stream"
            /> </query> </iq>

            Send:
            <iq xmlns="jabber:client" type="result" to="[email protected]/Psi" id="aab6a"><query
            xmlns="http://jabber.org/protocol/bytestreams"><streamhost-used jid="[email protected]/Psi"
            /></query></iq>
            */

            SIIq iq = new SIIq();
            iq.To = m_To;
            iq.Type = IqType.set;

            m_lFileLength = new FileInfo(m_FileName).Length;

            agsXMPP.protocol.extensions.filetransfer.File file;
            file =new agsXMPP.protocol.extensions.filetransfer.File(
                        Path.GetFileName(m_FileName), m_lFileLength);
            if (m_DescriptionChanged)
                file.Description = txtDescription.Text;
            file.Range = new Range();

            FeatureNeg fNeg = new FeatureNeg();

            Data data = new Data(XDataFormType.form);
            Field f = new Field(FieldType.List_Single);
            f.Var = "stream-method";
            f.AddOption().SetValue(agsXMPP.Uri.BYTESTREAMS);
            data.AddField(f);

            fNeg.Data = data;

            iq.SI.File = file;
            iq.SI.FeatureNeg = fNeg;
            iq.SI.Profile = agsXMPP.Uri.SI_FILE_TRANSFER;

            m_Sid = Guid.NewGuid().ToString();
            iq.SI.Id = m_Sid;

            m_XmppCon.IqGrabber.SendIq(iq, new IqCB(SiIqResult), null);
        }
Exemplo n.º 12
0
        private void cmdAccept_Click(object sender, EventArgs e)
        {
            cmdAccept.Enabled = false;
            cmdRefuse.Enabled = false;

            agsXMPP.protocol.extensions.featureneg.FeatureNeg fNeg = si.FeatureNeg;
            if (fNeg != null)
            {
                agsXMPP.protocol.x.data.Data data = fNeg.Data;
                if (data != null)
                {
                    agsXMPP.protocol.x.data.Field[] field = data.GetFields();
                    if (field.Length == 1)
                    {
                        Dictionary<string, string> methods = new Dictionary<string, string>();
                        foreach (agsXMPP.protocol.x.data.Option o in field[0].GetOptions())
                        {
                            string val = o.GetValue();
                            methods.Add(val, val);
                        }
                        if (methods.ContainsKey(agsXMPP.Uri.BYTESTREAMS))
                        {
                            // supports bytestream, so choose this option
                            agsXMPP.protocol.extensions.si.SIIq sIq = new agsXMPP.protocol.extensions.si.SIIq();
                            sIq.Id      = siIq.Id;
                            sIq.To      = siIq.From;
                            sIq.Type    = IqType.result;

                            sIq.SI.Id = si.Id;
                            sIq.SI.FeatureNeg = new agsXMPP.protocol.extensions.featureneg.FeatureNeg();

                            Data xdata = new Data();
                            xdata.Type = XDataFormType.submit;
                            Field f = new Field();
                            //f.Type = FieldType.List_Single;
                            f.Var = "stream-method";
                            f.AddValue(agsXMPP.Uri.BYTESTREAMS);
                            xdata.AddField(f);
                            sIq.SI.FeatureNeg.Data = xdata;

                            m_XmppCon.Send(sIq);
                        }
                    }
                }
            }
        }
Exemplo n.º 13
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);
            }
Exemplo n.º 14
0
        private void OnRequestConfiguration(object sender, IQ iq, object obj)
        {
            agsXMPP.protocol.x.muc.iq.owner.OwnerIq oIq = new agsXMPP.protocol.x.muc.iq.owner.OwnerIq();
            oIq.Type = IqType.set;
            oIq.To = iq.From;
            agsXMPP.protocol.x.data.Data data = new agsXMPP.protocol.x.data.Data(XDataFormType.submit);

            addFieldInDataIQ(data, "FORM_TYPE", "http://jabber.org/protocol/muc#roomconfig");
            addFieldInDataIQ(data, "muc#roomconfig_roomname", roomName);
            addFieldInDataIQ(data, "muc#roomconfig_roomdesc", roomDesc);
            addFieldInDataIQ(data, "muc#roomconfig_persistentroom", persistRoom);
            addFieldInDataIQ(data, "muc#roomconfig_publicroom", "1");
            addFieldInDataIQ(data, "public_list", "1");
            addFieldInDataIQ(data, "muc#roomconfig_passwordprotectedroom", (password == "") ? "0" : "1");
            addFieldInDataIQ(data, "muc#roomconfig_roomsecret", "");
            addFieldInDataIQ(data, "muc#roomconfig_maxusers", "1000");
            addFieldInDataIQ(data, "muc#roomconfig_whois", "moderators");
            addFieldInDataIQ(data, "muc#roomconfig_membersonly", "0");
            addFieldInDataIQ(data, "muc#roomconfig_moderatedroom", "1");
            addFieldInDataIQ(data, "members_by_default", "0");
            addFieldInDataIQ(data, "muc#roomconfig_membersonly", "0");
            addFieldInDataIQ(data, "muc#roomconfig_membersonly", "0");
            addFieldInDataIQ(data, "muc#roomconfig_changesubject", "1");
            addFieldInDataIQ(data, "allow_private_messages", "1");
            addFieldInDataIQ(data, "allow_private_messages_from_visitors", "anyone");
            addFieldInDataIQ(data, "allow_query_users", "1");
            addFieldInDataIQ(data, "muc#roomconfig_allowinvites", "0");
            addFieldInDataIQ(data, "muc#roomconfig_allowvisitorstatus", "1");
            addFieldInDataIQ(data, "muc#roomconfig_allowvisitornickchange", "0");
            addFieldInDataIQ(data, "muc#roomconfig_allowvoicerequests", "1");
            addFieldInDataIQ(data, "muc#roomconfig_voicerequestmininterval", "1800");
            addFieldInDataIQ(data, "muc#roomconfig_captcha_whitelist", "");
            addFieldInDataIQ(data, "muc#roomconfig_enablelogging", savingHistory);

            oIq.Query.AddChild(data);
            Settings.xmpp.IqGrabber.SendIq(oIq, new IqCB(OnGetFieldsResult), null);
        }