public static StreamInitIQ BuildDefaultStreamInitOffer(XMPPClient client, FileTransfer trans)
        {
            StreamInitIQ q = new StreamInitIQ(StreamInitIQType.Offer);
            q.mimetype = trans.MimeType;
            q.filename = trans.FileName;
            q.sid = trans.sid;
            q.filesize = trans.BytesTotal;
            q.FileTransferObject = trans;

            q.StreamOptions = XMPP.StreamOptions.ibb;

            /// Don't offer byte streams if the server doesn't support a SOCKS 5 proxy, since windows phone can't listen for connections
            item filetransfer = client.ServerServiceDiscoveryFeatureList.GetItemByType(ItemType.SOCKS5ByteStream);

            if ((FileTransferManager.SOCKS5Proxy != null) && (FileTransferManager.SOCKS5Proxy.Length > 0))
                filetransfer = new item(); /// User has supplied a socks5 proxy, so we don't need our xmpp server to supply one to use bytestreams

            if ((filetransfer != null) && (FileTransferManager.UseIBBOnly == false))
            {
                q.StreamOptions |= StreamOptions.bytestreams;
            }

            return q;
        }
Ejemplo n.º 2
0
        void QueryItemType(item item)
        {
            if (item.ItemType == ItemType.NotQueried)
            {
                ServiceDiscoveryIQ iqqueryproxy = new ServiceDiscoveryIQ();
                iqqueryproxy.From = XMPPClient.JID;
                iqqueryproxy.To = item.JID;
                iqqueryproxy.ServiceDiscoveryInfoQuery = new ServiceDiscoveryInfoQuery();
                iqqueryproxy.Type = IQType.get.ToString();

                IQ iqret = XMPPClient.SendRecieveIQ(iqqueryproxy, 15000, SerializationMethod.XMLSerializeObject);
                if ((iqret != null) && (iqret is ServiceDiscoveryIQ))
                {
                    ServiceDiscoveryIQ response = iqret as ServiceDiscoveryIQ;
                    if ((response.ServiceDiscoveryInfoQuery != null) && (response.ServiceDiscoveryInfoQuery.Identities != null) && (response.ServiceDiscoveryInfoQuery.Identities.Length > 0))
                    {
                        if ((response.ServiceDiscoveryInfoQuery.Identities[0].Category == "proxy") &&
                            (response.ServiceDiscoveryInfoQuery.Identities[0].Type == "bytestreams"))
                        {
                            item.ItemType = ItemType.SOCKS5ByteStream;
                            return;
                        }
                        if (response.ServiceDiscoveryInfoQuery.Identities[0].Category == "pubsub")
                        {
                            item.ItemType = ItemType.PubSub;
                            return;
                        }
                        if (response.ServiceDiscoveryInfoQuery.Identities[0].Category == "directory")
                        {
                            item.ItemType = ItemType.Directory;
                            return;
                        }
                        if (response.ServiceDiscoveryInfoQuery.Identities[0].Category == "conference")
                        {
                            item.ItemType = ItemType.Conference;
                            return;
                        }
                    }
                }

                item.ItemType = ItemType.Unknown;
            }
        }