Exemplo n.º 1
0
        void hubConnection_Update(object sender, FmdcEventArgs e)
        {
            Hub hub = (Hub)sender;

            switch (e.Action)
            {
            case Actions.TransferRequest:
                if (e.Data is TransferRequest)
                {
                    TransferRequest req = (TransferRequest)e.Data;
                    if (transferManager.GetTransferReq(req.Key) == null)
                    {
                        transferManager.AddTransferReq(req);
                    }
                }
                break;

            case Actions.TransferStarted:
                Transfer trans = e.Data as Transfer;
                if (trans != null)
                {
                    transferManager.StartTransfer(trans);
                    trans.Protocol.ChangeDownloadItem += new FmdcEventHandler(Protocol_ChangeDownloadItem);
                    trans.Protocol.RequestTransfer    += new FmdcEventHandler(Protocol_RequestTransfer);
                }
                break;

            case Actions.UserOnline:
                last = System.DateTime.Now.Ticks;
                break;
            }
        }
Exemplo n.º 2
0
        void Protocol_RequestTransfer(object sender, FmdcEventArgs e)
        {
            TransferRequest req = e.Data as TransferRequest;

            req = transferManager.GetTransferReq(req.Key);
            if (req != null)
            {
                e.Handled = true;
                e.Data    = req;
                transferManager.RemoveTransferReq(req.Key);
            }
        }
        void hubConnection_Update(object sender, FmdcEventArgs e)
        {
            Hub hub = (Hub)sender;

            switch (e.Action)
            {
            case Actions.TransferRequest:
                if (e.Data is TransferRequest)
                {
                    TransferRequest req = (TransferRequest)e.Data;
                    if (transferManager.GetTransferReq(req.Key) == null)
                    {
                        transferManager.AddTransferReq(req);
                    }
                }
                break;

            case Actions.TransferStarted:
                Transfer trans = e.Data as Transfer;
                if (trans != null)
                {
#if !COMPACT_FRAMEWORK
                    // Security, Windows Mobile doesnt support SSLStream so we disable this feature for it.
                    trans.SecureUpdate += new FmdcEventHandler(trans_SecureUpdate);
#endif
                    transferManager.StartTransfer(trans);
                    trans.Protocol.ChangeDownloadItem += new FmdcEventHandler(Protocol_ChangeDownloadItem);
                    trans.Protocol.RequestTransfer    += new FmdcEventHandler(Protocol_RequestTransfer);
                }
                break;

            case Actions.UserOnline:
                bool hasMe = (hub.GetUserById(hub.Me.ID) != null);
                if (!sentRequest && hasMe)
                {
                    User usr = null;
                    if ((usr = hub.GetUserByNick("FlowLibActiveTLS")) != null)
                    {
                        // Adding filelist of unknown type to download manager.
                        // to the user FlowLibActiveTLS
                        ContentInfo info = new ContentInfo(ContentInfo.FILELIST, BaseFilelist.UNKNOWN);
                        info.Set(ContentInfo.STORAGEPATH, currentDir + "Filelists\\" + usr.StoreID + ".filelist");
                        downloadManager.AddDownload(new DownloadItem(info), new Source(hub.RemoteAddress.ToString(), usr.StoreID));
                        // Start transfer to user
                        UpdateBase(this, new FmdcEventArgs(Actions.StartTransfer, usr));
                        sentRequest = true;
                    }
                }
                break;
            }
        }
Exemplo n.º 4
0
        void hubConnection_Update(object sender, FmdcEventArgs e)
        {
            Hub hub = (Hub)sender;

            switch (e.Action)
            {
            case Actions.TransferRequest:
                if (e.Data is TransferRequest)
                {
                    TransferRequest req = (TransferRequest)e.Data;
                    if (transferManager.GetTransferReq(req.Key) == null)
                    {
                        transferManager.AddTransferReq(req);
                    }
                }
                break;

            case Actions.TransferStarted:
                Transfer trans = e.Data as Transfer;
                if (trans != null)
                {
                    // Here we bind transfer to our data collector
                    stats = new GeneralProtocolDataCollector(trans);
                    transferManager.StartTransfer(trans);
                    trans.Protocol.ChangeDownloadItem += new FmdcEventHandler(Protocol_ChangeDownloadItem);
                    trans.Protocol.RequestTransfer    += new FmdcEventHandler(Protocol_RequestTransfer);
                }
                break;

            case Actions.UserOnline:
                bool hasMe = (hub.GetUserById(hub.Me.ID) != null);
                if (!sentRequest && hasMe)
                {
                    User usr = null;
                    if ((usr = hub.GetUserByNick("DCpp706")) != null)
                    {
                        // Adding filelist of unknown type to download manager.
                        // to the user DCpp706
                        ContentInfo info = new ContentInfo(ContentInfo.FILELIST, BaseFilelist.UNKNOWN);
                        info.Set(ContentInfo.STORAGEPATH, currentDir + "Filelists\\" + usr.StoreID + ".filelist");
                        downloadManager.AddDownload(new DownloadItem(info), new Source(hub.RemoteAddress.ToString(), usr.StoreID));
                        // Start transfer to user
                        UpdateBase(this, new FmdcEventArgs(Actions.StartTransfer, usr));
                        sentRequest = true;
                    }
                }
                break;
            }
        }
Exemplo n.º 5
0
        protected virtual void DoUPnPExternalRecieveAccess_RequestTransfer(object sender, FmdcEventArgs e)
        {
            TransferRequest req = e.Data as TransferRequest;

            req = transferManager.GetTransferReq(req.Key);
            if (req != null)
            {
                switch (req.Key)
                {
                case "upnp":
                    Success |= Functions.UPnPExternalRecieveAccess;
                    break;
                }
                transferManager.RemoveTransferReq(req.Key);
            }
        }
Exemplo n.º 6
0
        void prot_Update(object sender, FmdcEventArgs e)
        {
            Hub hubConnection = sender as Hub;

            if (hubConnection != null)
            {
                switch (e.Action)
                {
                case Actions.IsReady:
                    bool isReady = (bool)e.Data;
                    if (isReady)
                    {
                        // TODO: Start testing
                        var  usrlst = hubConnection.Userlist;
                        User usr    = null;
                        // Find usable user.
                        foreach (KeyValuePair <string, User> item in usrlst)
                        {
                            UserInfo me = hubConnection.Me;
                            usr = item.Value;

                            // Check so we are not trying to download from our self.
                            if (me.ID == usr.ID)
                            {
                                continue;
                            }

                            if (me.TagInfo.Mode == FlowLib.Enums.ConnectionTypes.Passive)
                            {
                                if (usr.Tag.Mode == ConnectionTypes.Direct)
                                {
                                    _hasFoundUser = true;
                                    break;
                                }
                            }
                            else
                            {
                                if (usr.Tag.Mode == ConnectionTypes.Passive)
                                {
                                    _hasFoundUser = true;
                                    break;
                                }
                            }
                        }

                        if (_hasFoundUser)
                        {
                            // Add filelist for a user
                            ContentInfo info = new ContentInfo(ContentInfo.FILELIST, BaseFilelist.UNKNOWN);

                            _filelistPath = currentDir + "Filelists" + System.IO.Path.DirectorySeparatorChar + "downloading" + ".filelist";
                            info.Set(ContentInfo.STORAGEPATH, _filelistPath);
                            info.Set("HubStoreId", hubConnection.StoreId);
                            info.Set(UserInfo.STOREID, usr.StoreID);

                            downloadManager.AddDownload(new DownloadItem(info), new Source(hubConnection.StoreId, usr.StoreID));

                            _testTimeoutLength += 10;
                        }
                    }
                    break;

                case Actions.TransferRequest:
                    if (e.Data is TransferRequest)
                    {
                        _hasTransferRequest = true;
                        TransferRequest req = (TransferRequest)e.Data;
                        if (transferManager.GetTransferReq(req.Key) == null)
                        {
                            transferManager.AddTransferReq(req);
                        }
                    }
                    break;

                case Actions.TransferStarted:
                    Transfer trans = e.Data as Transfer;
                    _hasTransferStarted = true;
                    if (trans != null)
                    {
                        // We could add a TransferRequest here if we wanted.
                        transferManager.StartTransfer(trans);
                        trans.Protocol.ChangeDownloadItem += new FmdcEventHandler(Protocol_ChangeDownloadItem);
                        trans.Protocol.RequestTransfer    += new FmdcEventHandler(Protocol_RequestTransfer);
                    }
                    break;
                }
            }
        }