bool ConnectionBOSH::send( const std::string& data ) { if( m_state == StateDisconnected ) return false; if( data.substr( 0, 2 ) == "<?" ) { // if( m_initialStreamSent ) { m_streamRestart = true; sendXML(); return true; } // else // { // m_initialStreamSent = true; // m_logInstance.dbg( LogAreaClassConnectionBOSH, "initial <stream:stream> dropped" ); // return true; // } } else if( data == "</stream:stream>" ) return true; m_sendBuffer += data; sendXML(); return true; }
bool ServerInterface::commit(QStringList docs, QList<QByteArray> data) { if(m_reply == NULL) { m_getDoc = docs; m_getData = data; login(SLOT(sendXML())); return true; } else { return false; } }
ConnectionError ConnectionBOSH::recv( int timeout ) { if( m_state == StateDisconnected ) return ConnNotConnected; if( !m_connectionPool.empty() ) m_connectionPool.front()->recv( 0 ); if( !m_activeConnections.empty() ) m_activeConnections.front()->recv( timeout ); // If there are no open requests then the spec allows us to send an empty request... // (Some CMs do not obey this, it seems) if( ( m_openRequests == 0 || m_sendBuffer.size() > 0 ) && m_state == StateConnected ) { m_logInstance.dbg( LogAreaClassConnectionBOSH, "Sending empty request (or there is data in the send buffer)" ); sendXML(); } return ConnNoError; // FIXME? }
void ServerInterface::sentXMLDone() { disconnect(m_reply, SIGNAL(finished()), this, SLOT(sentXMLDone())); m_reply->deleteLater(); if(checkError()) { QString doctype = m_getDoc.first(); m_getDoc.removeFirst(); m_getData.removeFirst(); QByteArray response = m_reply->readAll(); QDomDocument doc; if(doc.setContent(response)) { QDomNodeList list = doc.elementsByTagName("TransactionTicket"); if(list.count() == 1 && list.at(0).isElement() && list.at(0).hasChildNodes()) { QDomElement element = list.at(0).toElement(); QString text = element.childNodes().at(0).toText().nodeValue(); emit commitFile(doctype, text.toInt()); } } if(m_getDoc.isEmpty()) { m_reply = NULL; emit commitDone(); } else { sendXML(); } } }