SOLVED: Force attempt

Technical discussion about the NMDC and <a href="http://dcpp.net/ADC.html">ADC</A> protocol. The NMDC protocol is documented in the <a href="http://dcpp.net/wiki/">Wiki</a>, so feel free to refer to it.

Moderator: Moderators

Locked
OWNBuilder
Posts: 2
Joined: 2003-04-01 13:22

SOLVED: Force attempt

Post by OWNBuilder » 2003-04-01 13:40

THIS IS SCRATCHY, but it works:
LRESULT MainFrame::onForce(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
int i = -1;
CString somes;
LVITEM lvi;
int nRes;
memset(&lvi, 0, sizeof(LVITEM));
lvi.iSubItem = COLUMN_STATUS;
while( (i = ctrlTransfers.GetNextItem(i, LVNI_SELECTED)) != -1) {
int nLen = 128;
do
{
nLen *= 2;
lvi.cchTextMax = nLen;
lvi.pszText = somes.GetBufferSetLength(nLen);
nRes = (int)::SendMessage(ctrlTransfers.m_hWnd, LVM_GETITEMTEXT, (WPARAM)i,
(LPARAM)&lvi);
} while (nRes == nLen - 1);
if(!strncmp(somes.GetString(), CSTRING(DOWNLOADED_LEFT), somes.FindOneOf(" "))||
!somes.Compare(CSTRING(DISCONNECTED))||!somes.Compare(CSTRING(CONNECTION_TIMEOUT))||
!somes.Compare(CSTRING(ALL_DOWNLOAD_SLOTS_TAKEN))||!somes.Compare(CSTRING(NO_SLOTS_AVAILABLE))) {
ItemInfo *validItemData = (ItemInfo*) ctrlTransfers.GetItemData(i);
if(validItemData){ //Try NULL? :)
ctrlTransfers.SetItemText(i, COLUMN_STATUS, CSTRING(CONNECTING_FORCED));
validItemData->user->connect();
} else break;
}
}
somes.ReleaseBuffer();

return 0;
}
OKeeee?

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

Post by GargoyleMT » 2003-04-01 22:54

I think I'm having a dense night (sorry). I can see that you're getting the text in the dialog and checking it against some of the strings before you try to force a connection, but I don't recall a previous mention of what behavior/side effects you're fixing by this patch.

Would it be possible to just read the state from the ConnectionQueueItem directly?

OWNBuilder
Posts: 2
Joined: 2003-04-01 13:22

Post by OWNBuilder » 2003-04-03 05:32

maybe, but it hasn't got too many stages.. I think there are only 2/3. (upload/download.. ?connecting?)
For now it is nice solve :o)

It's about a window with handleing transfers (that down). When you select all of that transfers, this will force only downloads.. Sometime it is good..


Srry 4 my EN :o)
OKeeee?

Locked