当前位置: 首页>>代码示例>>C++>>正文


C++ CContact类代码示例

本文整理汇总了C++中CContact的典型用法代码示例。如果您正苦于以下问题:C++ CContact类的具体用法?C++ CContact怎么用?C++ CContact使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CContact类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: throw

CContact *CRoutingBin::GetContact(uint32_t ip, uint16_t port, bool tcpPort) const throw()
{
	for (ContactList::const_iterator it = m_entries.begin(); it != m_entries.end(); ++it) {
		CContact *contact = *it;
		if ((contact->GetIPAddress() == ip)
		    && ((!tcpPort && port == contact->GetUDPPort()) || (tcpPort && port == contact->GetTCPPort()) || port == 0)) {
			return contact;
		}
	}
	return NULL;
}
开发者ID:0vermind,项目名称:hmule,代码行数:11,代码来源:RoutingBin.cpp

示例2: Compare

    TInt Compare(TInt aLeft, TInt aRight) const
        {
        CContact* left = arr[aLeft];
        CContact* right = arr[aRight];

        left->Name(name1, last_name_first);
        right->Name(name2, last_name_first);

        //TCollationMethod m = *Mem::CollationMethodByIndex(0); // get the standard method
        //m.iFlags |= TCollationMethod::EIgnoreNone; // dont ignore punctuation and spaces

        return name1->CompareC(*name2, 3 /* string level */, NULL);
        }
开发者ID:bohwaz,项目名称:s60voip,代码行数:13,代码来源:PhoneBkEngine.cpp

示例3: wxASSERT

void CRoutingBin::SetAlive(CContact *contact)
{
	wxASSERT(contact != NULL);
	// Check if we already have a contact with this ID in the list.
	CContact *test = GetContact(contact->GetClientID());
	wxASSERT(contact == test);
	if (test) {
		// Mark contact as being alive.
		test->UpdateType();
		// Move to the end of the list
		PushToBottom(test);
	}
}
开发者ID:0vermind,项目名称:hmule,代码行数:13,代码来源:RoutingBin.cpp

示例4: wxCHECK

bool CKademlia::FindNodeIDByIP(CKadClientSearcher& requester, uint32_t ip, uint16_t tcpPort, uint16_t udpPort)
{
	wxCHECK(IsRunning() && instance && GetUDPListener() && GetRoutingZone(), false);

	// first search our known contacts if we can deliver a result without asking, otherwise forward the request
	CContact* contact;
	if ((contact = GetRoutingZone()->GetContact(wxUINT32_SWAP_ALWAYS(ip), tcpPort, true)) != NULL) {
		uint8_t nodeID[16];
		contact->GetClientID().ToByteArray(nodeID);
		requester.KadSearchNodeIDByIPResult(KCSR_SUCCEEDED, nodeID);
		return true;
	} else {
		return GetUDPListener()->FindNodeIDByIP(&requester, wxUINT32_SWAP_ALWAYS(ip), tcpPort, udpPort);
	}
}
开发者ID:Artoria2e5,项目名称:amule-dlp,代码行数:15,代码来源:Kademlia.cpp

示例5: SetTCPPort

void CRoutingBin::SetTCPPort(uint32_t ip, uint16_t port, uint16_t tcpPort)
{
	// Find contact with IP/Port
	for (ContactList::iterator it = m_entries.begin(); it != m_entries.end(); ++it) {
		CContact *c = *it;
		if ((ip == c->GetIPAddress()) && (port == c->GetUDPPort())) {
			// Set TCPPort and mark as alive.
			c->SetTCPPort(tcpPort);
			c->UpdateType();
			// Move to the end of the list
			PushToBottom(c);
			break;
		}
	}
}
开发者ID:0vermind,项目名称:hmule,代码行数:15,代码来源:RoutingBin.cpp

示例6: Add

bool CRoutingZone::Add(CContact* pContact, bool bUpdate)
{
	// If we are not a leaf, call add on the correct branch.
	if (!IsLeaf())
		return m_pSubZones[pContact->GetDistance().GetBitNumber(m_uLevel)]->Add(pContact, bUpdate);
	else
	{
		// Do we already have a contact with this KadID?
		CContact* pContactUpdate = m_pBin->GetContact(pContact->GetClientID());
		if (pContactUpdate)
		{
			if(bUpdate)
			{
				pContactUpdate->SetIPAddress(pContact->GetIPAddress());
				pContactUpdate->SetUDPPort(pContact->GetUDPPort());
				pContactUpdate->SetTCPPort(pContact->GetTCPPort());
				pContactUpdate->SetVersion(pContact->GetVersion());
				m_pBin->SetAlive(pContactUpdate);
//------> xt	theApp.emuledlg->kademliawnd->ContactRef(pContactUpdate);
				CKademlia::GetListCtrl()->ContactRef(pContactUpdate);
			}
			return false;
		}
		else if (m_pBin->GetRemaining())
		{
			// This bin is not full, so add the new contact.
			if(m_pBin->AddContact(pContact))
			{
				// Add was successful, add to the GUI and let contact know it's listed in the gui.
//------> xt	if (theApp.emuledlg->kademliawnd->ContactAdd(pContact))
				if (CKademlia::GetListCtrl()->ContactAdd(pContact) && CKademlia::GetHistogramCtrl()->ContactAdd(pContact))
				{
					pContact->SetGuiRefs(true);
				}
				return true;
			}
			return false;
		}
		else if (CanSplit())
		{
			// This bin was full and split, call add on the correct branch.
			Split();
			return m_pSubZones[pContact->GetDistance().GetBitNumber(m_uLevel)]->Add(pContact, bUpdate);
		}
		else
			return false;
	}
}
开发者ID:tempbottle,项目名称:TestSet,代码行数:48,代码来源:RoutingZone.cpp

示例7: ASSERT

bool CKademlia::FindIPByNodeID(CKadClientSearcher& rRequester, const uchar* pachNodeID){
	if (!IsRunning() || m_pInstance == NULL || GetUDPListener() == NULL){
		ASSERT( false );
		return false;
	}
	// first search our known contacts if we can deliver a result without asking, otherwise forward the request
	CContact* pContact;
	if ((pContact = GetRoutingZone()->GetContact(CUInt128(pachNodeID))) != NULL){
		// make sure that this entry is not too old, otherwise just do a search to be sure
		if (pContact->GetLastSeen() != 0 && time(NULL) - pContact->GetLastSeen() < 1800){
			rRequester.KadSearchIPByNodeIDResult(KCSR_SUCCEEDED, ntohl(pContact->GetIPAddress()), pContact->GetTCPPort());
			return true;
		}
	}
	return CSearchManager::FindNodeSpecial(CUInt128(pachNodeID), &rRequester);
}
开发者ID:HackLinux,项目名称:eMule-IS-Mod,代码行数:16,代码来源:Kademlia.cpp

示例8: GetContact

bool CRoutingZone::VerifyContact(const CUInt128& id, uint32_t ip)
{
    CContact* contact = GetContact(id);
    if (contact == NULL) {
        return false;
    } else if (ip != contact->GetIPAddress()) {
        return false;
    } else {
        if (contact->IsIPVerified()) {
            LogKadLine(LOG_DEBUG /*logKadRouting*/, L"Sender already verified (sender: %s)", IPToStr(ip).c_str());
        } else {
            contact->SetIPVerified(true);
        }
        return true;
    }
}
开发者ID:supertanglang,项目名称:NeoLoader,代码行数:16,代码来源:RoutingZone.cpp

示例9: compareName

TInt CPhoneBkEngine::compareName(const CContact& aFirst,
        const CContact& aSecond)
    {
    HBufC* name1 = HBufC::NewL(128);
    CleanupStack::PushL(name1);
    HBufC* name2 = HBufC::NewL(128);
    CleanupStack::PushL(name2);

    aFirst.Name(name1, false);
    aSecond.Name(name2, false);

    TInt comparison = name1->CompareC(*name2, 3 /* string level */, NULL);
    CleanupStack::PopAndDestroy(2);

    return comparison;
    }
开发者ID:bohwaz,项目名称:s60voip,代码行数:16,代码来源:PhoneBkEngine.cpp

示例10: DebugLogWarning

void CRoutingZone::DbgWriteBootstrapFile()
{
	DebugLogWarning(_T("Writing special bootstrap nodes.dat - not intended for normal use"));
	try
	{
		// Write a saved contact list.
		CUInt128 uID;
		CSafeBufferedFile file;
		CFileException fexp;
		if (file.Open(m_sFilename, CFile::modeWrite | CFile::modeCreate | CFile::typeBinary|CFile::shareDenyWrite, &fexp))
		{
			setvbuf(file.m_pStream, NULL, _IOFBF, 32768);

			// The bootstrap method gets a very nice sample of contacts to save.
			ContactMap mapContacts;
			CUInt128 uRandom(CUInt128((ULONG)0), 0);
			CUInt128 uDistance = uRandom;
			uDistance.Xor(uMe);
			GetClosestTo(2, uRandom, uDistance, 1200, &mapContacts, false, false);
			// filter out Kad1 nodes
			for (ContactMap::iterator itContactMap = mapContacts.begin(); itContactMap != mapContacts.end(); )
			{
				ContactMap::iterator itCurContactMap = itContactMap;
				++itContactMap;
				CContact* pContact = itCurContactMap->second;
				if (pContact->GetVersion() <= 1)
					mapContacts.erase(itCurContactMap);
			}
			// Start file with 0 to prevent older clients from reading it.
			file.WriteUInt32(0);
			// Now tag it with a version which happens to be 2 (1 till 0.48a).
			file.WriteUInt32(3);
			file.WriteUInt32(1); // if we would use version >=3, this would mean that this is not a normal nodes.dat
			file.WriteUInt32((uint32_t)mapContacts.size());
			for (ContactMap::const_iterator itContactMap = mapContacts.begin(); itContactMap != mapContacts.end(); ++itContactMap)
			{
				CContact* pContact = itContactMap->second;
				pContact->GetClientID(&uID);
				file.WriteUInt128(&uID);
				file.WriteUInt32(pContact->GetIPAddress());
				file.WriteUInt16(pContact->GetUDPPort());
				file.WriteUInt16(pContact->GetTCPPort());
				file.WriteUInt8(pContact->GetVersion());
			}
			file.Close();
			AddDebugLogLine( false, _T("Wrote %ld contact to bootstrap file."), mapContacts.size());
		}
		else
			DebugLogError(_T("Unable to store Kad file: %s"), m_sFilename);
	}
	catch (CFileException* e)
	{
		e->Delete();
		AddDebugLogLine(false, _T("CFileException in CRoutingZone::writeFile"));
	}

}
开发者ID:HackLinux,项目名称:eMule-IS-Mod,代码行数:57,代码来源:RoutingZone.cpp

示例11: CContact

// Returns true if a contact was added or updated, false if the routing table was not touched.
bool CRoutingZone::AddUnfiltered(const CUInt128& id, uint32_t ip, uint16_t port, uint16_t tport, uint8_t version, const CKadUDPKey& key, bool& ipVerified, bool update, bool fromHello)
{
    if (id != me) {
        CContact *contact = new CContact(id, ip, port, tport, version, key, ipVerified);
        if (fromHello) {
            contact->SetReceivedHelloPacket();
        }
        if (Add(contact, update, ipVerified)) {
            ASSERT(!update);
            return true;
        } else {
            delete contact;
            return update;
        }
    }
    return false;
}
开发者ID:supertanglang,项目名称:NeoLoader,代码行数:18,代码来源:RoutingZone.cpp

示例12: GetContact

bool CRoutingZone::VerifyContact(const CUInt128 &uID, uint32_t uIP){
	CContact* pContact = GetContact(uID);
	if (pContact == NULL){
		return false;
	}
	else if (uIP != pContact->GetIPAddress())
		return false;
	else {
		if (pContact->IsIpVerified())
			DebugLogWarning(_T("Kad: VerifyContact: Sender already verified (sender: %s)"), ipstr(ntohl(uIP)));
		else{
			pContact->SetIpVerified(true);
			theApp.emuledlg->kademliawnd->ContactRef(pContact);
		}
		return true;
	}
}
开发者ID:HackLinux,项目名称:eMule-IS-Mod,代码行数:17,代码来源:RoutingZone.cpp

示例13: setAlive

void CRoutingBin::setAlive(uint32 ip, uint16 port)
{
	if (m_entries.empty())
		return;

	CContact *c;
	ContactList::iterator it;
	for (it = m_entries.begin(); it != m_entries.end(); it++)
	{
		c = *it;
		if ((ip == c->getIPAddress()) && (port == c->getUDPPort()))
		{
			c->updateType();
			break;
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:resurrection,代码行数:17,代码来源:RoutingBin.cpp

示例14: setTCPPort

void CRoutingBin::setTCPPort(uint32 ip, uint16 port, uint16 tcpPort)
{
	if (m_entries.empty())
		return;

	CContact *c;
	ContactList::iterator it;
	for (it = m_entries.begin(); it != m_entries.end(); it++)
	{
		c = *it;
		if ((ip == c->getIPAddress()) && (port == c->getUDPPort()))
		{
			c->setTCPPort(tcpPort);
			c->updateType();
			// Move to the end of the list
			remove(c);
			m_entries.push_back(c);
			break;
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:resurrection,代码行数:21,代码来源:RoutingBin.cpp

示例15: OnResolverResponse

void CMainApp::OnResolverResponse(wxThreadEvent& event)
{
  unsigned key = event.GetInt();
  unsigned data = event.GetExtraLong();
  CContact c = event.GetPayload<CContact>();
  CJournalEntry *pE = findActiveEntry(key);
  if (pE != NULL) {
    if (data == RESOLVE_CALLER) {
      pE->setCallerName(c.getSN());
      if (pE->getType() == CJournalEntry::J_INCOMING) {
        pE->setImage(c.getImage());
      }
    } else if (data == RESOLVE_CALLED) {
      pE->setCalledName(c.getSN());
      if (pE->getType() == CJournalEntry::J_OUTGOING) {
        pE->setImage(c.getImage());
      }
    }
    m_pJournalModel->insertUpdateEntry(*pE);
  }
  else {
    CJournalEntry e;
    if (findJournalEntry(key, e)) {
      if (data == RESOLVE_CALLER) e.setCallerName(c.getSN());
      if (data == RESOLVE_CALLED) e.setCalledName(c.getSN());
      m_pJournalModel->insertUpdateEntry(e);
    }
  }
}
开发者ID:Sonderstorch,项目名称:c-mon,代码行数:29,代码来源:mainapp.cpp


注:本文中的CContact类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。