void Session::queryOnResult(InboundPkt &inboundPkt, qint64 msgId) { qCDebug(TG_CORE_SESSION) << "result for query" << QString::number(msgId, 16); qint32 op = inboundPkt.prefetchInt(); qint32 *inPtr = 0; qint32 *inEnd = 0; if (op == (qint32)TL_GZipPacked) { inboundPkt.fetchInt(); qint32 l = inboundPkt.prefetchStrlen(); char *s = inboundPkt.fetchStr(l); static qint32 packedBuffer[MAX_PACKED_SIZE / 4]; qint32 totalOut = Utils::tinflate (s, l, packedBuffer, MAX_PACKED_SIZE); inPtr = inboundPkt.inPtr(); inEnd = inboundPkt.inEnd(); inboundPkt.setInPtr(packedBuffer); inboundPkt.setInEnd(inboundPkt.inPtr() + totalOut / 4); qCDebug(TG_CORE_SESSION) << "unzipped data"; } Query *q = m_pendingQueries.take(msgId); if (!q) { qCWarning(TG_CORE_SESSION) << "No such query"; inboundPkt.setInPtr(inboundPkt.inEnd()); } else { qCDebug(TG_CORE_SESSION) << "acked query with msgId" << QString::number(msgId, 16) << ",pendingQueries:" << m_pendingQueries.size(); q->setAcked(true); Q_EMIT resultReceived(q, inboundPkt); } if (inPtr) { inboundPkt.setInPtr(inPtr); inboundPkt.setInEnd(inEnd); } }
void Session::rpcExecuteAnswer(InboundPkt &inboundPkt, qint64 msgId) { qint32 op = inboundPkt.prefetchInt(); qCDebug(TG_CORE_SESSION) << "rpcExecuteAnswer(), op =" << QString::number(op, 16); switch (op) { case TL_MsgContainer: workContainer(inboundPkt, msgId); return; case TL_NewSessionCreated: workNewSessionCreated(inboundPkt, msgId); return; case TL_MsgsAck: workMsgsAck(inboundPkt, msgId); return; case TL_RpcResult: workRpcResult(inboundPkt, msgId); return; case TL_UpdateShort: workUpdateShort(inboundPkt, msgId); return; case TL_UpdatesCombined: workUpdatesCombined(inboundPkt, msgId); case TL_Updates: workUpdates(inboundPkt, msgId); return; case TL_UpdateShortMessage: workUpdateShortMessage(inboundPkt, msgId); return; case TL_UpdateShortChatMessage: workUpdateShortChatMessage(inboundPkt, msgId); return; case TL_GZipPacked: workPacked(inboundPkt, msgId); return; case TL_BadServerSalt: workBadServerSalt(inboundPkt, msgId); return; case TL_Pong: workPong(inboundPkt, msgId); return; case TL_MsgDetailedInfo: workDetailedInfo(inboundPkt, msgId); return; case TL_MsgNewDetailedInfo: workNewDetailedInfo(inboundPkt, msgId); return; case TL_UpdatesTooLong: workUpdatesTooLong(inboundPkt, msgId); return; case TL_BadMsgNotification: workBadMsgNotification(inboundPkt, msgId); return; } qCWarning(TG_CORE_SESSION) << "Unknown rpc response message"; inboundPkt.setInPtr(inboundPkt.inEnd()); }
void Session::workRpcResult(InboundPkt &inboundPkt, qint64 msgId) { qCDebug(TG_CORE_SESSION) << "workRpcResult: msgId =" << QString::number(msgId, 16); mAsserter.check(inboundPkt.fetchInt() == (qint32)TL_RpcResult); qint64 id = inboundPkt.fetchLong(); qint32 op = inboundPkt.prefetchInt(); if (op == (qint32)TL_RpcError) { queryOnError(inboundPkt, id); } else { queryOnResult(inboundPkt, id); } }