Пример #1
0
G2Packet* CQuery::ToG2Packet(CEndPoint* pAddr, quint32 nKey)
{
	G2Packet* pPacket = G2Packet::New("Q2", true);

	//bool bWantURL = true;
	bool bWantDN = (!m_sDescriptiveName.isEmpty());
	bool bWantMD = !m_sMetadata.isEmpty();
	//bool bWantPFS = true;

	if(pAddr)
	{
		G2Packet* pUDP = pPacket->WritePacket("UDP", 10);
		pUDP->WriteHostAddress(pAddr);
		pUDP->WriteIntLE(nKey);
	}

	if(bWantDN)
	{
		pPacket->WritePacket("DN", m_sDescriptiveName.toUtf8().size())->WriteString(m_sDescriptiveName, false);
	}
	if(bWantMD)
	{
		pPacket->WritePacket("MD", m_sMetadata.toUtf8().size())->WriteString(m_sMetadata, false);
	}

	foreach(CHash pHash, m_lHashes)
	{
		pPacket->WritePacket("URN", pHash.GetFamilyName().size() + CHash::ByteCount(pHash.getAlgorithm()) + 1);
		pPacket->WriteString(pHash.GetFamilyName() + "\0" + pHash.RawValue(), false);
	}
Пример #2
0
void CChatSessionG2::SendStartups()
{
	qDebug() << "sending startups";
	G2Packet* pPacket = G2Packet::New("UPROC", false);

	// A dirty workaround for Shareaza bug...
	if( m_bShareaza )
		pPacket->WriteString("dupa");

	SendPacket(pPacket);
}
Пример #3
0
void CChatSessionG2::SendMessage(QString sMessage, bool bAction)
{
	qDebug() << "Send message:" << sMessage << bAction;

	G2Packet* pPacket = G2Packet::New("CMSG", true);
	if( bAction )
		pPacket->WritePacket("ACT", 0);

	G2Packet* pBody = G2Packet::New("BODY");
	pBody->WriteString(sMessage);
	pPacket->WritePacket(pBody);
	pBody->Release();

	SendPacket(pPacket);
}
Пример #4
0
void CChatSessionG2::OnUPROC(G2Packet *pPacket)
{
	Q_UNUSED(pPacket);

	// Temporary code, needs to be moved to GProfile class

	QString sXML = "<?xml version=\"1.0\"?><gprofile xmlns=\"http://www.shareaza.com/schemas/GProfile.xsd\"><gnutella guid=\"%1\"/><identity><handle primary=\"%2\"/></identity></gprofile>";
	sXML = sXML.arg(quazaaSettings.Profile.GUID.toString().toUpper().replace("{", "").replace("}", "")).arg(quazaaSettings.Profile.GnutellaScreenName);

	G2Packet* pD = G2Packet::New("UPROD", true);
	pD->WritePacket("XML", sXML.toUtf8().size());
	pD->WriteString(sXML);

	SendPacket(pD);
}