Search for Alternates problem

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

Locked
redlight
Posts: 5
Joined: 2003-05-27 01:24

Search for Alternates problem

Post by redlight » 2003-12-26 07:09

The search for alternates used to only download files with the same filename as the one in the queue. Now there is some kind of per token search through the search results.

For example:
I am downloading a rar set bh-xvid.r??. Suppose I search for alternates on bh-xvid.r05. DC++ will search for "bh xvid r05". The search results include dmt-xvid-bh.r05, and that file is improperly added to the queue as an alternate for bh-xvid.r05.

I found the following code in QueueFrame.cpp, but I am not sure how to modify it or even if it is the right place to modify.

Code: Select all

LRESULT QueueFrame::onSearchAlternates(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	if(ctrlQueue.GetSelectedCount() == 1) {
		string tmp;

		int i = ctrlQueue.GetNextItem(-1, LVNI_SELECTED);
		QueueItemInfo* ii = ctrlQueue.getItemData(i);
		
		string searchString = SearchManager::clean(ii->getSearchString());
		if (searchString.size() < 1)
			string searchString = SearchManager::clean(ii->getTargetFileName());
		StringList tok = StringTokenizer(searchString, ' ').getTokens();
		
		for(StringIter si = tok.begin(); si != tok.end(); ++si) {
			bool found = false;
			
			for(StringIter j = searchFilter.begin(); j != searchFilter.end(); ++j) {
				if(Util::stricmp(si->c_str(), j->c_str()) == 0) {
					found = true;
				}
			}
			
			if(!found && !si->empty()) {
				tmp += *si + ' ';
			}
		}
		if(!tmp.empty()) {
			bool bigFile = (ii->getSize() > 10*1024*1024);
			if(bigFile) {
				SearchFrame::openWindow(tmp, ii->getSize()-1, SearchManager::SIZE_ATLEAST, ShareManager::getInstance()->getType(ii->getTargetFileName()));
			} else {
				SearchFrame::openWindow(tmp, ii->getSize()+1, SearchManager::SIZE_ATMOST, ShareManager::getInstance()->getType(ii->getTargetFileName()));
			}
		}
	} 
	
	return 0;
}

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Re: Search for Alternates problem

Post by GargoyleMT » 2003-12-26 08:51

redlight wrote:The search for alternates used to only download files with the same filename as the one in the queue. Now there is some kind of per token search through the search results.
DC++ did (and still does, if you haven't set a specific alternate string) add a file as a source if the filename is the same, and the search result contains all of the tokens in the original filename. If it contains additional tokens, the filename still matches.

How is your example different from:
bh-xvid_[sharereactor].r05

Or similar?

redlight
Posts: 5
Joined: 2003-05-27 01:24

Post by redlight » 2003-12-26 10:13

DC++ did (and still does, if you haven't set a specific alternate string) add a file as a source if the filename is the same, and the search result contains all of the tokens in the original filename. If it contains additional tokens, the filename still matches.
I'm not sure what you mean by "specific alternate string." But I just checked out 0.251, and it will only add alternates automatically if the filenames are an exact match. By exact match I mean, if the file in my queue was bh-xvid.r05 then the search result would have to have the filename bh-xvid.r05 to be considered an alternate. Further, bh-xvid_[sharereactor].r05 or dmt-xvid-bh.r05 (which is the wrong file altogether) would not download automatically in version 0.251.
How is your example different from:
bh-xvid_[sharereactor].r05

Or similar?
Well the difference is bh-xvid_[sharereactor].r05 is most likely the same file as bh-xvid.r05; whereas dmt-xvid-bh.r05 is from a different rar set.


I'd just like to know where the code is that performs the comparison between the filenames in the queue and the filenames in the search results.

redlight
Posts: 5
Joined: 2003-05-27 01:24

Post by redlight » 2003-12-27 05:07

I fixed it.

I replaced the code in QueueManager::onAction(SearchManagerListener::Types, SearchResult*) with the code from 0.251, and I modified it slightly to be compatible with 0.305.

Code: Select all

// SearchManagerListener
void QueueManager::onAction(SearchManagerListener::Types type, SearchResult* sr) throw() {
	if(type == SearchManagerListener::SEARCH_RESULT && BOOLSETTING(AUTO_SEARCH)) {
		StringList l;
	    getTargetsBySize(l, sr->getSize(), Util::getFileExt(sr->getFile()));
		
		StringTokenizer t(SearchManager::clean(sr->getFileName()), ' ');
		StringList& tok = t.getTokens();

		for(StringIter i = l.begin(); i != l.end(); ++i) {
			bool found = true;

			for(StringIter j = tok.begin(); j != tok.end(); ++j) {
				if(Util::findSubString(*i, *j) == string::npos) {
					found = false;
					break;
				}
			}

			if(found) {
				// Wow! found a new source that seems to match...add it...
				try {
					add(sr->getFile(), sr->getSize(), sr->getUser(), *i, Util::emptyString, QueueItem::FLAG_RESUME, 
						QueueItem::DEFAULT, Util::emptyString, false);
					dcdebug("QueueManager::onAction New source %s for target %s found\n", sr->getUser()->getNick().c_str(), i->c_str());
					if(BOOLSETTING(AUTO_SEARCH_AUTO_MATCH))
						addList(sr->getUser(), QueueItem::FLAG_MATCH_QUEUE);
				} catch(const Exception&) {
					// ...
				}
				// Ok, so let's match the file listing at once...
			}
		}
	}
}

Dooble
Posts: 12
Joined: 2003-12-30 20:35

Post by Dooble » 2003-12-30 20:39

This is exactly what I have been looking for ! I am getting this kind of problem quite often and it drives me mad !

Could you please tell me if the change you made works properly ? If so, could you tell me how I could implement this in my client ?

That would be great indeed...

redlight
Posts: 5
Joined: 2003-05-27 01:24

Post by redlight » 2004-01-06 10:12

It works. Replace the current QueueManager::onAction(SearchManagerListener::Types, SearchResult*) with the one in my last post.

deepdown
Posts: 10
Joined: 2003-02-05 15:58

Post by deepdown » 2004-01-11 19:31

Me to, have this problem!

I don't have any "QueueFrame.cpp" file...

Which file should I alter ?
(so I need the source code ?..)

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-01-11 20:36

deepdown wrote:Me to, have this problem!

I don't have any "QueueFrame.cpp" file...

Which file should I alter ?
(so I need the source code ?..)
QueueFrame.cpp is in the windows/ directory.

However, his code goes into client/QueueManager.cpp.

Twink
Posts: 436
Joined: 2003-03-31 23:31
Location: New Zealand

Post by Twink » 2004-01-11 23:42

deepdown wrote: Which file should I alter ?
(so I need the source code ?..)
yes you need to download the source, and have a compiler (microsoft visual c++ .net 2003) + the stl and wtl libraries. (or you could ask the patchs author politely if he can release a modded version)

deepdown
Posts: 10
Joined: 2003-02-05 15:58

Post by deepdown » 2004-01-12 05:16

I'm running win2000.
Don't have any file with the name; QueueFrame.cpp

A release which solves this problem would be reallyappreciated.
But who should I talk to ?

I don't have any .net compilers on my computer :?

joakim_tosteberg
Forum Moderator
Posts: 587
Joined: 2003-05-07 02:38
Location: Sweden, Linkoping

Post by joakim_tosteberg » 2004-01-12 10:08

My guess is that you have no idea about what you are doing, am I right?

Dooble
Posts: 12
Joined: 2003-12-30 20:35

Post by Dooble » 2004-01-14 09:11

I'm running PhantomDC++0.305 1.18c at the moment. I really like that client and I saw Twink's post in here... As I know that you are working on PhantomDC++, Twink, I would really appreciate if you could put that piece of code into the next release of PhantomDC.

I think it would make good sense, because I consider that Search Problem a serious bug. I'm afraid I don't have the time to work on this myself. I will think of donating instead.

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-01-14 12:16

Dooble wrote:I think it would make good sense, because I consider that Search Problem a serious bug. I'm afraid I don't have the time to work on this myself. I will think of donating instead.
Donating to who? :) 90% of phantom DC is arne. 7% is cologic, and 3% is twink.

Twink
Posts: 436
Joined: 2003-03-31 23:31
Location: New Zealand

Post by Twink » 2004-01-15 00:19

the donations were phantoms idea as PhantomDC did start off as a private client made for a certain hub, it wasn't really meant to become known in others, which also meant the donations went towards running the hub itself. But actually i dont think we've had any in ages, I know I haven't accepted any.

I do know that Phantom did give a good proportion of the donated stuff to arnie as he deserved it, specially as there is alot of arne and coloic's work in it. Personally I would rather people gave the donations to arnie.

This isn't really the forum to suggest things for my client either, I tend to not mention it here and suggest people use BCDC if the subject comes up. oh and gargoyle, dont forget opera's percentage :P (although I did have to change large portions of his things to work without his extra library functions).

I guess I'll look at what this patch actually does and see if its worth including anyway.
Last edited by Twink on 2004-03-13 23:55, edited 1 time in total.

arnetheduck
The Creator Himself
Posts: 296
Joined: 2003-01-02 17:15

Post by arnetheduck » 2004-01-15 08:39

Twink wrote:I do know that Phantom did give a good proportion of the donated stuff to arnie as he deserved it, specially as there is alot of arnie and coloic's work in it. Personally I would rather people gave the donations to arnie.
he did?

GargoyleMT
DC++ Contributor
Posts: 3212
Joined: 2003-01-07 21:46
Location: .pa.us

Post by GargoyleMT » 2004-01-15 13:01

Twink wrote:gargoyle, dont forget opera's percentage :P
Ooops, yeah. He probably would appreciate some positive feedback, instead of just complaints about features, requests for new features, and support questions. (That probably goes for...most of us actually.)

Dooble
Posts: 12
Joined: 2003-12-30 20:35

Post by Dooble » 2004-01-15 16:21

It's worth including the patch if we are talking about RAR Sharing. As long as File Hashing is not included in DC++ it will be needed to stop the search confusing the filenames....

I also have to say I appreciate Opera's work. There are some very nice features in his client. I do not use it at the moment, because it crashes quite often with a VisualC++ Unhandled Exception. :(

Well, I posted this thread in my favourite's Hub Forum and found somebody who is taking care of the problem and trying to implement the code. I'm looking forward to testing it....

Twink
Posts: 436
Joined: 2003-03-31 23:31
Location: New Zealand

Post by Twink » 2004-01-15 23:50

arnetheduck wrote:
Twink wrote:I do know that Phantom did give a good proportion of the donated stuff to arnie as he deserved it, specially as there is alot of arnie and coloic's work in it. Personally I would rather people gave the donations to arnie.
he did?
well I seem to remember him telling me so, however that was months ago (maybe 5-6?) and since the NZ currency wasn't that great back then it probably didn't end up being that much.

Locked