Exemplo n.º 1
0
void SessionServer::setSessionStore(SessionStore *store)
{
	Q_ASSERT(store);
	_store = store;
	store->setParent(this);

	connect(store, SIGNAL(sessionAvailable(SessionDescription)), this, SIGNAL(sessionChanged(SessionDescription)));
}
Exemplo n.º 2
0
bool Hibernation::storeSession(const SessionState *session)
{
	if(!session->mainstream().hasSnapshot()) {
		logger::warning() << session << "Unable to hibernate due to lack of snapshot point!";
		return false;
	}

	QString filename = QDir(_path).filePath(QString("session-%1.dphib").arg(session->id()));

	recording::Writer writer(filename);
	writer.setFilterMeta(false);
	writer.setMinimumInterval(0);

	if(!writer.open()) {
		logger::error() << "Couldn't open" << filename << "for writing:" << writer.errorString();
		return false;
	}

	// Write header
	recording::HibernationHeader header;
	header.minorVersion = session->minorProtocolVersion();
	header.title = session->title();
	header.founder = session->founder();
	header.password = session->passwordHash();

	if(session->isPersistent())
		header.flags |= recording::HibernationHeader::PERSISTENT;

	writer.writeHibernationHeader(header);

	// Write session
	const protocol::MessageStream &msgs = session->mainstream();
	const protocol::SnapshotPoint &sp = msgs.snapshotPoint().cast<protocol::SnapshotPoint>();
	for(const protocol::MessagePtr &msg : sp.substream())
		writer.recordMessage(msg);

	int idx = msgs.snapshotPointIndex()+1;
	while(msgs.isValidIndex(idx)) {
		writer.recordMessage(msgs.at(idx));
		++idx;
	}

	writer.close();

	SessionDescription desc(*session);
	_sessions.append(desc);
	emit sessionAvailable(desc);

	return true;
}