Beispiel #1
0
        public frmFileTransfer(XmppClientConnection XmppCon, IQ iq)
        {
            InitializeComponent();
            cmdSend.Enabled = false;
            this.Text       = "Receive 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;

            if (file != null)
            {
                m_lFileLength = file.Size;

                this.lblDescription.Text    = file.Description;
                this.lblFileName.Text       = file.Name;
                this.lblFileSize.Text       = HRSize(m_lFileLength);
                this.txtDescription.Visible = false;
            }

            m_XmppCon = XmppCon;


            this.progress.Maximum = 100;
            //this.Text += iq.From.ToString();

            //this.tbFileSize.Text = FileTransferUtils.ConvertToByteString(m_lFileLength);

            XmppCon.OnIq += new IqHandler(XmppCon_OnIq);
        }
        public FileTransfer(XmppClientConnection xmppCon, IQ iq, IContact from)
            : base(from)
        {
            _siIq = iq;
            _si = iq.SelectSingleElement(typeof (SI)) as SI;

            if (_si != null)
            {
                // get SID for file transfer
                _sid = _si.Id;
                _file = _si.File;

                Contact = from;

                if (_file != null)
                {
                    _fileLength = _file.Size;

                    FileDescription = _file.Description;
                    FileName = _file.Name;
                }

                _xmppConnection = xmppCon;
            }
        }
Beispiel #3
0
        public frmFileTransfer(XmppClientConnection XmppCon, IQ iq)
        {
            InitializeComponent();
            cmdSend.Enabled = false;
            this.Text = "Receive 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;

            if (file != null)
            {
                m_lFileLength = file.Size;

                this.lblDescription.Text    = file.Description;
                this.lblFileName.Text       = file.Name;
                this.lblFileSize.Text       = HRSize(m_lFileLength);
                this.txtDescription.Visible = false;
            }

            m_XmppCon = XmppCon;

            this.progress.Maximum = 100;
            //this.Text += iq.From.ToString();

            //this.tbFileSize.Text = FileTransferUtils.ConvertToByteString(m_lFileLength);

            XmppCon.OnIq += new IqHandler(XmppCon_OnIq);
        }
Beispiel #4
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);
                        }
                    }
                }
            }
        }
        public EventInfoFileTransfer(IQ iq)
            : base(string.Empty, EventSeverity.Info)
        {
            _iq = iq;

            agsXMPP.protocol.extensions.si.SI si = iq.SelectSingleElement(typeof(agsXMPP.protocol.extensions.si.SI)) as agsXMPP.protocol.extensions.si.SI;

            if (si != null)
            {
                _file = si.File;

                _contact = Roster.Instance.FindContactOrGetNew(iq.From);
            }

            _message = string.Format("Incoming file '{0}' from {1}", FileName, Contact.DisplayName);
        }
Beispiel #6
0
        public FileTransfer(XmppClientConnection XmppCon, Jid m_To)
        {
            m_XmppCon = XmppCon;
            SIIq iq = new SIIq();

            iq.To   = m_To;
            iq.Type = IqType.set;

            m_lFileLength = new FileInfo(@"c:\\ping.txt").Length;

            agsXMPP.protocol.extensions.filetransfer.File file;
            file = new agsXMPP.protocol.extensions.filetransfer.File(Path.GetFileName(@"c:\\ping.txt"), 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);
        }
        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;
        }
Beispiel #8
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);
        }
Beispiel #9
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);
        }