Official eMule-Board: "not A Valid Link" Fix In Directdownloaddlg - Official eMule-Board

Jump to content


Page 1 of 1

"not A Valid Link" Fix In Directdownloaddlg

#1 User is offline   zoom 

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 28-December 02

Post icon  Posted 30 July 2006 - 01:37 AM

it might happen that a copied ed2k-link contain whitespaces at the end, especially after copying a link from a website.

add this line in DirectDownloadDlg.cpp to fix this (marked in red)

Quote

void CDirectDownloadDlg::OnOK()
{
CString strLinks;
GetDlgItem(IDC_ELINK)->GetWindowText(strLinks);

int curPos = 0;
CString strTok = strLinks.Tokenize(_T("\t\n\r"), curPos);
while (!strTok.IsEmpty())
{
  strTok.Trim();
  if (strTok.Right(1) != _T("/"))
   strTok += _T("/");
  try
  ...


cheers

zoom

This post has been edited by zoom: 30 July 2006 - 03:50 PM

0

#2 User is offline   netfinity 

  • Master of WARP
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1658
  • Joined: 23-April 04

Posted 30 July 2006 - 05:51 AM

You need to use a qoute to do that!
eMule v0.50a [NetF WARP v0.3a]
- Compiled for 32 and 64 bit Windows versions
- Optimized for fast (100Mbit/s) Internet connections
- Faster file completion via Dynamic Block Requests and dropping of stalling sources
- Faster searching via KAD with equal or reduced overhead
- Less GUI lockups through multi-threaded disk IO operations
- VIP "Payback" queue
- Fakealyzer (helps you chosing the right files)
- Quality Of Service to keep eMule from disturbing VoIP and other important applications (Vista/7/8 only!)
0

#3 User is offline   zoom 

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 28-December 02

Posted 30 July 2006 - 03:48 PM

thanks for your help :+1:
0

#4 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 30 July 2006 - 07:35 PM

If I may add it might be even better to do this:

Quote

CString strTok = strLinks.Tokenize(_T("\t\n\r"), curPos);
while (!strTok.IsEmpty())
{
  strTok.Trim();
  if(strTok.IsEmpty())
    break;

  if (strTok.Right(1) != _T("/"))
  strTok += _T("/");
  try
  ...

as a line might contain only spaces.
0

#5 User is offline   zoom 

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 28-December 02

Posted 31 July 2006 - 07:44 PM

good input :+1:

this way it might be even better:

Quote

CString strTok = strLinks.Tokenize(_T("\t\n\r"), curPos);
while (!strTok.IsEmpty())
{
  strTok.Trim();
  if(strTok.IsEmpty())
    continue;

  if (strTok.Right(1) != _T("/"))
  strTok += _T("/");
  try
  ...


just in cases that there is another link after the empty line...
0

#6 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 31 July 2006 - 08:07 PM

Considering that the official client "throws" on error I thought a break would be ok *g
One can change that part then, too ;)
0

#7 User is offline   Aenarion[ITA] 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 92
  • Joined: 03-April 05

Posted 07 August 2006 - 07:57 PM

zoom, on Jul 31 2006, 08:44 PM, said:

good input  :+1:

this way it might be even better:

Quote

CString strTok = strLinks.Tokenize(_T("\t\n\r"), curPos);
while (!strTok.IsEmpty())
{
  strTok.Trim();
  if(strTok.IsEmpty())
    continue;

  if (strTok.Right(1) != _T("/"))
  strTok += _T("/");
  try
  ...


just in cases that there is another link after the empty line...
View Post


Why this "if"??
the control to determine if strTok is empy comes made already from the "while".
EX Dev of Ackronic

The best italian mod!!
0

#8 User is offline   CiccioBastardo 

  • Doomsday Executor
  • PipPipPipPipPipPipPip
  • Group: Italian Moderators
  • Posts: 5541
  • Joined: 22-November 03

Posted 07 August 2006 - 08:06 PM

Because before the trim strTok can be not empty. After the trim it can be. If it is, the following code lines are useless.
I can't understand the continue, instead. Used that way the next line of the string will never be tokenized.
You need:

Quote

strTok = strLinks.Tokenize(_T("\t\n\r"), curPos);

before the continue.

Or I am missing something?

/edit: to complete the example:

Quote

CString strTok = strLinks.Tokenize(_T("\t\n\r"), curPos);
while (!strTok.IsEmpty())
{
  strTok.Trim();
  if(strTok.IsEmpty()) {
    strTok = strLinks.Tokenize(_T("\t\n\r"), curPos);
   
continue;
  }
  if (strTok.Right(1) != _T("/"))
  strTok += _T("/");
  try
  ...


Which can be optimized a lot putting the Tokenize into the while check statement, I think, but this is not really required.

This post has been edited by CiccioBastardo: 07 August 2006 - 08:10 PM

The problem is not the client, it's the user
0

#9 User is offline   BlueSonicBoy 

  • Magnificent Member
  • PipPipPipPipPipPip
  • Group: Members
  • Posts: 396
  • Joined: 26-September 04

Posted 12 August 2006 - 08:34 PM

View PostCiccioBastardo, on Aug 7 2006, 04:06 PM, said:

I can't understand the continue, instead. Used that way the next line of the string will never be tokenized.
You need:


That looks good to me... But can't we do away with this now? :flowers:

Quote

try
{
CED2KLink* pLink = CED2KLink::CreateLinkFromUrl(strTok.Trim());
if (pLink)


So we would have:

void CDirectDownloadDlg::OnOK() said:

CString strTok = strLinks.Tokenize(_T("\t\n\r"), curPos);
while (!strTok.IsEmpty())
{
strTok.Trim();
if(strTok.IsEmpty()) {
strTok = strLinks.Tokenize(_T("\t\n\r"), curPos);
continue;
}

if (strTok.Right(1) != _T("/"))
strTok += _T("/");
try{
CED2KLink* pLink = CED2KLink::CreateLinkFromUrl(strTok);
if (pLink)
...

0

  • Member Options

Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users