Ejemplo n.º 1
0
void MainPageModelItem::setGuid(const QString &guid)
{
    if(p->guid == guid)
        return;

    p->guid = guid;
    emit guidChanged();
}
Ejemplo n.º 2
0
void CChatSession::SetupWidget(CWidgetPrivateMessage *pWg)
{
	m_pWidget = pWg;

	connect(this, SIGNAL(guidChanged(QUuid)), m_pWidget, SLOT(OnGUIDChanged(QUuid)));
	connect(this, SIGNAL(nickChanged(QString)), m_pWidget, SLOT(OnNickChanged(QString)));
	connect(this, SIGNAL(incomingMessage(QString,bool)), m_pWidget, SLOT(OnIncomingMessage(QString,bool)));
	connect(this, SIGNAL(systemMessage(QString)), m_pWidget, SLOT(OnSystemMessage(QString)));
	connect(m_pWidget, SIGNAL(SendMessageS(QString,bool)), this, SLOT(SendMessage(QString,bool)));
	connect(m_pWidget, SIGNAL(SendMessageS(QTextDocument*,bool)), this, SLOT(SendMessage(QTextDocument*,bool)));
	connect(m_pWidget, SIGNAL(destroyed()), this, SLOT(deleteLater()));
}
Ejemplo n.º 3
0
void CChatSessionG2::OnCHATANS(G2Packet *pPacket)
{
	char szType[9];
	quint32 nLength = 0, nNext = 0;

	bool bAccepted = false;

	while(pPacket->ReadPacket(&szType[0], nLength))
	{
		nNext = pPacket->m_nPosition + nLength;

		if(strcmp("USERGUID", szType) == 0 && nLength >= 16)
		{
			QUuid oGUID;
			oGUID = pPacket->ReadGUID();
			if( !oGUID.isNull() )
			{
				m_oGUID = oGUID;
				emit guidChanged(oGUID);
			}
		}
		else if (strcmp("ACCEPT", szType) == 0 )
		{
			emit systemMessage("Private conversation accepted, you're now chatting with " + m_sNick);
			qDebug() << "chat accepted";
			bAccepted = true;
		}
		else if( strcmp("DENY", szType) == 0 )
		{
			emit systemMessage("Private conversation denied by remote host, sorry.");
			qDebug() << "chat denied";
			CNetworkConnection::Close();
			return;
		}
		else if( strcmp("AWAY", szType) == 0 )
		{
			emit systemMessage(m_sNick + " is away.");
			qDebug() << "he is away";
			bAccepted = true;
		}

		pPacket->m_nPosition = nNext;
	}

	if( bAccepted )
		m_nState = csActive;
}
Ejemplo n.º 4
0
void CChatSessionG2::OnUPROD(G2Packet *pPacket)
{
	qDebug() << "OnUPROD";

	if( !pPacket->m_bCompound )
		return;

	QUuid oGUID;
	bool hasXML = false;

	char szType[9];
	quint32 nLength = 0, nNext = 0;

	while(pPacket->ReadPacket(&szType[0], nLength))
	{
		nNext = pPacket->m_nPosition + nLength;

		if(strcmp("XML", szType) == 0)
		{
			// Temporary code, needs to be moved to GProfile class
			QXmlStreamReader oXML;
			bool hasGprofile = false;
			bool hasGUID = false;
			bool hasIdentity = false;
			bool hasNick = false;
			oXML.addData(pPacket->ReadString(nLength));

			while(!oXML.atEnd() && !oXML.hasError())
			{
				QXmlStreamReader::TokenType token = oXML.readNext();

				if( token == QXmlStreamReader::StartDocument)
				{
					continue;
				}
				else if( token == QXmlStreamReader::StartElement )
				{
					if( oXML.name() == "gprofile" )
					{
						/*
						if( oXML.attributes().value("xmlns") != "http://www.shareaza.com/schemas/GProfile.xsd" )
							return;*/
						hasGprofile = true;
						continue;
					}
					else if( hasGprofile && oXML.name() == "gnutella" )
					{
						if( oXML.attributes().hasAttribute("guid") )
						{
							QString sTemp = oXML.attributes().value("guid").toString();
							QUuid oTemp(sTemp);
							oGUID = oTemp;
							hasGUID = true;
							continue;
						}
					}
					else if( hasGprofile && oXML.name() == "identity" )
					{
						hasIdentity = true;
						continue;
					}
					else if( hasGprofile && hasIdentity && oXML.name() == "handle" )
					{
						if( oXML.attributes().hasAttribute("primary") )
						{
							m_sNick = oXML.attributes().value("primary").toString();
							hasNick = true;
							continue;
						}
					}
				}
			}

			if( !hasNick || !hasGUID )
				return;

			hasXML = true;
		}

		pPacket->m_nPosition = nNext;
	}

	if( !hasXML )
		return;

	m_oGUID = oGUID;
	emit guidChanged(oGUID);
	emit nickChanged(m_sNick);

	if( m_bInitiated ) // TODO PUSH handling
	{
		G2Packet* pReq = G2Packet::New("CHATREQ", true);
		pReq->WritePacket("USERGUID", 16);
		pReq->WriteGUID(m_oGUID);

		SendPacket(pReq);
	}
}