hungdluit / flowlib

Automatically exported from code.google.com/p/flowlib
0 stars 0 forks source link

Unable to upload file while logged using Russian DisplayName (Nick) #20

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Join any nmdc hub using Cyryllic symbols DisplayName. for example = 
"Владислав"
2. Try to upload filelist to other client

- What is the expected output? What do you see instead?
- Expecting file upload. Nothing happens.

using FlowLib SVN 20090203 + Share file from Issue 19.

Windows Vista Sp1

No any exceptions triggered.

I'm trying to download filelist from flowlib based client using FlyLinkDC 
(active connection), all works normally while nick does not contain any 
cyryllic symbols.
By default flowlib cant connect to hub using such nick. to solve this I 
use following code:

hub.Connect();
if (hub.Protocol is HubNmdcProtocol)
{
    HubNmdcProtocol prot = (HubNmdcProtocol)hub.Protocol;
    prot.Encoding = Encoding.Default;
}

Hub_Protocol_Update event fires
Protocol_ChangeDownloadItem event dont fires, but should

Original issue reported on code.google.com by hackw...@gmail.com on 17 Feb 2009 at 5:11

GoogleCodeExporter commented 8 years ago
This happens because the encoding used between you and hub is different then 
encoding
between you and other users.

You need to set encoding on TransferNmdcProtocol to.
Changing on 2 places should probably do the trick.
For active connections:

        void trans_ProtocolChange(object sender, FmdcEventArgs e)
        {
            Transfer trans = sender as Transfer;
            if (trans == null)
                return;
            IProtocolTransfer prot = e as IProtocolTransfer;
            if (prot != null)
            {
                prot.ChangeDownloadItem -= Protocol_ChangeDownloadItem;
                prot.RequestTransfer -= Protocol_RequestTransfer;
            }
            // Set Encoding here
            trans.Protocol.ChangeDownloadItem += new
FmdcEventHandler(Protocol_ChangeDownloadItem);
            trans.Protocol.RequestTransfer += new
FmdcEventHandler(Protocol_RequestTransfer);
        }

For passive connections:

        void hubConnection_Update(object sender, FmdcEventArgs e)
        {
            switch (e.Action)
            {
                case Actions.TransferRequest:
                    if (e.Data is TransferRequest)
                    {
                        TransferRequest req = (TransferRequest)e.Data;
                        transferManager.AddTransferReq(req);
                    }
                    break;
                case Actions.TransferStarted:
                    Transfer trans = e.Data as Transfer;
                    if (trans != null)
                    {
                        // Set Encoding here
                        transferManager.StartTransfer(trans);
                    }
                    break;
            }
        }

(Remember that you should only do this if the protocol is of type 
TransferNmdcProtocol)

Please let me know how it goes.

Original comment by blomman84 on 19 Feb 2009 at 9:19

GoogleCodeExporter commented 8 years ago
Now it works fine. Thank you very much!

Original comment by hackw...@gmail.com on 24 Feb 2009 at 7:51

GoogleCodeExporter commented 8 years ago
Good. Issue closed :)

Original comment by blomman84 on 24 Feb 2009 at 11:24