// ismod
void CCollectionViewDialog::OnEnChangeModEditcatalogname()
{
	CString temp;
	m_CatalogName.GetWindowText(temp);
	m_pCollection->m_sCollectionName = StripInvalidFilenameChars(temp);
	if (temp != m_pCollection->m_sCollectionName)
	{
		m_CatalogName.SetSel(0,-1);
		m_CatalogName.ReplaceSel(m_pCollection->m_sCollectionName);
		m_CatalogName.SetModify(false);
	}
	SetWindowText(m_pCollection->m_sCollectionName);
	if (m_pCollection->m_sCollectionFolder == _T(""))
	{
		SetDlgItemText(IDC_MOD_SAVEPATH, _T("Укажите место сохранения каталога ----->>>"));
	}
	if (m_pCollection->m_sCollectionName == _T(""))
	{
		GetDlgItem(IDC_MOD_SELECTOUTPUTDIR)->EnableWindow(false);
	}
	else
	{
		GetDlgItem(IDC_MOD_SELECTOUTPUTDIR)->EnableWindow(true);
	}
	if (m_pCollection->m_sCollectionName == _T("") || m_pCollection->m_sCollectionFolder == _T(""))
	{
		GetDlgItem(IDC_VIEWCOLLECTIONDL)->EnableWindow(false);
	}
	else
	{
		GetDlgItem(IDC_VIEWCOLLECTIONDL)->EnableWindow(true);
	}
}
Exemplo n.º 2
0
CString	CDetailInfo::GetLink(CKnownFile* pFile)
{
	//ADDED by fengwen on 2007/07/12 <begin>	:	如果是url下载,则返回源url。
	if (NULL == pFile)
		return _T("");

	if (pFile->IsPartFile())
	{
		CPartFile	*pPartFile = (CPartFile	*) pFile;
		if ( pPartFile->HasNullHash() )
			return pPartFile->GetPartFileURL();
	}
	//ADDED by fengwen on 2007/07/12 <end>	:	如果是url下载,则返回源url。

	CString strLinks;
	CString strBuffer;

	bool bHashset = false;
	bool bHTML = false;
//	bool bSource = true;
//	bool bHostname  = true;
	bool bEMHash = true;

	if (!strLinks.IsEmpty())
		strLinks += _T("\r\n\r\n");

	if (bHTML)
		strLinks += _T("<a href=\"");

	//const CKnownFile* file = STATIC_DOWNCAST(CKnownFile, (*pFile)[i]);
	const CKnownFile* file = pFile;
	strLinks += CreateED2kLink(file, false);

	if (bHashset && file->GetHashCount() > 0 && file->GetHashCount() == file->GetED2KPartHashCount())
	{
		strLinks += _T("p=");
		for (UINT j = 0; j < file->GetHashCount(); j++)
		{
			if (j > 0)
				strLinks += _T(':');
			strLinks += EncodeBase16(file->GetPartHash(j), 16);
		}
		strLinks += _T('|');
	}

	if (bEMHash && file->GetAICHHashset()->HasValidMasterHash() && 
		(file->GetAICHHashset()->GetStatus() == AICH_VERIFIED || file->GetAICHHashset()->GetStatus() == AICH_HASHSETCOMPLETE))
	{
		strBuffer.Format(_T("h=%s|"), file->GetAICHHashset()->GetMasterHash().GetString() );
		strLinks += strBuffer;			
	}
    if(!strLinks.IsEmpty())
	    strLinks += _T('/');
	//if (bHostname)
	//{
	//	strBuffer.Format(_T("|sources,%s:%i|/"), thePrefs.GetYourHostname(), thePrefs.GetPort() );
	//	strLinks += strBuffer;
	//}
	//else if(bSource)
	//{
	//	uint32 dwID = CGlobalVariable::GetID();
	//	strBuffer.Format(_T("|sources,%i.%i.%i.%i:%i|/"),(uint8)dwID,(uint8)(dwID>>8),(uint8)(dwID>>16),(uint8)(dwID>>24), thePrefs.GetPort() );
	//	strLinks += strBuffer;
	//}

	if (bHTML)
		strLinks += _T("\">") + StripInvalidFilenameChars(file->GetFileName(), true) + _T("</a>");

	return strLinks;
}
BOOL CFriendListCtrl::OnCommand(WPARAM wParam, LPARAM /*lParam*/)
{
	wParam = LOWORD(wParam);

	CFriend* cur_friend = NULL;
	int iSel = GetNextItem(-1, LVIS_SELECTED | LVIS_FOCUSED);
	if (iSel != -1) 
		cur_friend = (CFriend*)GetItemData(iSel);
	
	switch (wParam)
	{
		case MP_MESSAGE:
			if (cur_friend)
			{
				theApp.emuledlg->chatwnd->StartSession(cur_friend->GetClientForChatSession());
			}
			break;
		case MP_REMOVEFRIEND:
			if (cur_friend)
			{
				theApp.friendlist->RemoveFriend(cur_friend);
				// auto select next item after deleted one.
				if (iSel < GetItemCount()) {
					SetSelectionMark(iSel);
					SetItemState(iSel, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
				}
				theApp.emuledlg->chatwnd->UpdateSelectedFriendMsgDetails();
			}
			break;
		case MP_ADDFRIEND:{
			CAddFriend dialog2; 
			dialog2.DoModal();
			break;
		}
		case MP_DETAIL:
		case MPG_ALTENTER:
		case IDA_ENTER:
			if (cur_friend)
				ShowFriendDetails(cur_friend);
			break;
		case MP_SHOWLIST:
			if (cur_friend)
			{
				if (cur_friend->GetLinkedClient(true))
					cur_friend->GetLinkedClient()->RequestSharedFileList();
				else
				{
					CUpDownClient* newclient = new CUpDownClient(0, cur_friend->m_nLastUsedPort, cur_friend->m_dwLastUsedIP, 0, 0, true);
					newclient->SetUserName(cur_friend->m_strName);
					//Xman Code Improvement don't search new generated clients in lists
					/*
					theApp.clientlist->AddClient(newclient);
					*/
					theApp.clientlist->AddClient(newclient,true);
					//Xman end
					newclient->RequestSharedFileList();
				}
			}
			break;
		case MP_FRIENDSLOT:
			if (cur_friend)
			{
				bool bIsAlready = cur_friend->GetFriendSlot();
				theApp.friendlist->RemoveAllFriendSlots();
				if (!bIsAlready)
				{ //Xman
					cur_friend->SetFriendSlot(true);
					//Xman friend visualization
					UpdateFriend(iSel,cur_friend);
					//Xman end
				} //Xman
			}
			break;
		// - show requested files (sivka/Xman)
		case MP_LIST_REQUESTED_FILES:
			{ 
				if (cur_friend && cur_friend->GetLinkedClient())
				{
					cur_friend->GetLinkedClient()->ShowRequestedFiles(); 
				}
				break;
			}
		//Xman end
		// MORPH START - Added by Commander, Friendlinks [emulEspaa] - added by zz_fly
		case MP_PASTE:
		{
			CString link = theApp.CopyTextFromClipboard();
			link.Trim();
			if ( link.IsEmpty() )
				break;
			try{
				CED2KLink* pLink = CED2KLink::CreateLinkFromUrl(link);
		
				if (pLink && pLink->GetKind() == CED2KLink::kFriend )
				{
					// Better with dynamic_cast, but no RTTI enabled in the project
					CED2KFriendLink* pFriendLink = static_cast<CED2KFriendLink*>(pLink);
					uchar userHash[16];
					pFriendLink->GetUserHash(userHash);

					if ( ! theApp.friendlist->IsAlreadyFriend(userHash) )
						theApp.friendlist->AddFriend(userHash, 0U, 0U, 0U, 0U, pFriendLink->GetUserName(), 1U);
					else
					{
						CString msg;
						msg.Format(GetResString(IDS_USER_ALREADY_FRIEND), pFriendLink->GetUserName());
						AddLogLine(true, msg);
					}
				}
				if(pLink) delete pLink; //zz_fly :: memleak :: thanks DolphinX
			}
			catch(CString strError){
				AfxMessageBox(strError);
			}
		}
			break;
        case MP_GETFRIENDED2KLINK:
		{
			CString sCompleteLink;
			if ( cur_friend && cur_friend->HasUserhash() )
			{
				CString sLink;
				CED2KFriendLink friendLink(cur_friend->m_strName, cur_friend->m_abyUserhash);
				friendLink.GetLink(sLink);
				if ( !sCompleteLink.IsEmpty() )
					sCompleteLink.Append(_T("\r\n"));
				sCompleteLink.Append(sLink);
			}

			if ( !sCompleteLink.IsEmpty() )
				theApp.CopyTextToClipboard(sCompleteLink);
		}
			break;
		case MP_GETHTMLFRIENDED2KLINK:
		{
			CString sCompleteLink;
			
			if ( cur_friend && cur_friend->HasUserhash() )
			{
				CString sLink;
				CED2KFriendLink friendLink(cur_friend->m_strName, cur_friend->m_abyUserhash);
				friendLink.GetLink(sLink);
				sLink = _T("<a href=\"") + sLink + _T("\">") + StripInvalidFilenameChars(cur_friend->m_strName) + _T("</a>");
				if ( !sCompleteLink.IsEmpty() )
					sCompleteLink.Append(_T("\r\n"));
				sCompleteLink.Append(sLink);
			}
			
			if ( !sCompleteLink.IsEmpty() )
				theApp.CopyTextToClipboard(sCompleteLink);
		}
			break;
		// MORPH END - Added by Commander, Friendlinks [emulEspaa]

		case MP_FIND:
			OnFindStart();
			break;
	}
	return true;
}