Example #1
0
/***********************************************************
remove people online
***********************************************************/
void CommunityBox::RemoveOnline(const std::string & listname, const std::string &_offline)
{
	if(listname == "online")
	{
		CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
			CEGUI::WindowManager::getSingleton().getWindow("Community/onlinelist"));


		std::map<std::string, CEGUI::ListboxItem *>::iterator itmap = _onlines.find(_offline);
		if(itmap != _onlines.end())
		{
			lb->removeItem(itmap->second);
			_onlines.erase(itmap);
		}

		if(IsFriend(_offline))
			UpdateFriend(_offline);
	}

	if(listname == "IRC")
	{
		CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
			CEGUI::WindowManager::getSingleton().getWindow("Community/IRClist"));

		CEGUI::ListboxItem *it = lb->findItemWithText(_offline, NULL);
		if(it != NULL)
			lb->removeItem(it);
	}
}
Example #2
0
/***********************************************************
used to process text to add
***********************************************************/
void CommunityBox::Process()
{
	std::vector<ThreadSafeWorkpile::JoinEvent> data;
	ThreadSafeWorkpile::getInstance()->GetJoinEventData(data);

	std::vector<ThreadSafeWorkpile::JoinEvent>::const_iterator it = data.begin();
	std::vector<ThreadSafeWorkpile::JoinEvent>::const_iterator end = data.end();
	for(; it != end; ++it)
	{
		if(it->Clear)
		{
			ClearList(it->ListName);
		}
		else
		{
			if(it->Joined)
				AddOnline(it->ListName, it->Nickname, it->Status, it->Color);
			else
				RemoveOnline(it->ListName, it->Nickname);
		}
	}


	LbaNet::FriendsSeq friends;
	if(ThreadSafeWorkpile::getInstance()->GetFriends(friends))
	{
		ClearFriends();
		for(size_t i=0; i<friends.size(); ++i)
			UpdateFriend(friends[i]);
	}
}
Example #3
0
/***********************************************************
update friend online status
***********************************************************/
void CommunityBox::UpdateFriendOnlineStatus(const std::string & name)
{
	T_friendmap::iterator it = _friends.begin();
	T_friendmap::iterator end = _friends.end();
	for(; it != end; ++it)
	{
		if(it->second.first.Name == name)
		{
			UpdateFriend(it->second.first);
			break;
		}
	}
}
void CFriendListCtrl::RefreshFriend(const CFriend* pFriend)
{
	//Xman CodeFix
	if (!theApp.emuledlg->IsRunning())
		return;
	//Xman end

	LVFINDINFO find;
	find.flags = LVFI_PARAM;
	find.lParam = (LPARAM)pFriend;
	int iItem = FindItem(&find);
	if (iItem != -1)
		UpdateFriend(iItem, pFriend);
}
void CFriendListCtrl::Localize()
{
	CHeaderCtrl* pHeaderCtrl = GetHeaderCtrl();
	HDITEM hdi;
	hdi.mask = HDI_TEXT;
	CString strRes;

	strRes = GetResString(IDS_QL_USERNAME);
	hdi.pszText = const_cast<LPTSTR>((LPCTSTR)strRes);
	pHeaderCtrl->SetItem(0, &hdi);

	int iItems = GetItemCount();
	for (int i = 0; i < iItems; i++)
		UpdateFriend(i, (CFriend*)GetItemData(i));
}
void CFriendListCtrl::AddFriend(const CFriend* pFriend)
{
	// ==> Run eMule as NT Service [leuk_he/Stulle] - Stulle
	if (theApp.IsRunningAsService(SVC_LIST_OPT))
		return;
	// <== Run eMule as NT Service [leuk_he/Stulle] - Stulle

	//Xman CodeFix
	if (!theApp.emuledlg->IsRunning())
		return;
	//Xman end

	int iItem = InsertItem(LVIF_TEXT | LVIF_PARAM, GetItemCount(), pFriend->m_strName, 0, 0, 0, (LPARAM)pFriend);
	if (iItem >= 0)
		UpdateFriend(iItem, pFriend);
	theApp.emuledlg->chatwnd->UpdateFriendlistCount(theApp.friendlist->GetCount());
}
Example #7
0
/***********************************************************
add people online
***********************************************************/
void CommunityBox::AddOnline(const std::string & listname, const std::string &_online,
							 const std::string &_status, const std::string &color)
{
	if(listname == "online")
	{
		CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
			CEGUI::WindowManager::getSingleton().getWindow("Community/onlinelist"));

		std::string dis = "[colour='" + color + "']" + _online;
		if(_status != "")
			dis += " (" + _status + ")";

		std::map<std::string, CEGUI::ListboxItem *>::iterator itmap = _onlines.find(_online);
		if(itmap != _onlines.end())
		{
			itmap->second->setText(dis);
			lb->invalidate();
		}
		else
		{
			CEGUI::ListboxItem *it = new MyComListItem(dis);
			lb->addItem(it);
			_onlines[_online] = it;
		}


		if(IsFriend(_online))
			UpdateFriend(_online);
	}

	if(listname == "IRC")
	{
		CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
			CEGUI::WindowManager::getSingleton().getWindow("Community/IRClist"));

		CEGUI::ListboxItem *it = lb->findItemWithText(_online, NULL);
		if(it == NULL)
			lb->addItem(new MyComListItem(_online));
	}
}
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;
}