qutim_sdk_0_3::ChatSession *Chat::getSession(qutim_sdk_0_3::ChatUnit *unit, bool create) { // TODO: Think, is it good idea or we need smth more intellegent? if (ChatUnit *meta = unit->metaContact()) unit = meta; unit = getUnitForSession(unit); if (!unit) return nullptr; // We don't wont to have separate channels for contact and his resource unit = const_cast<ChatUnit*>(unit->getHistoryUnit()); foreach (ChatChannel *channel, m_channels) { if (channel->unit() == unit) return channel; } ChatChannel *channel = 0; if (create) { m_view.show(); channel = new ChatChannel(unit); QQmlEngine::setObjectOwnership(channel, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(unit, QQmlEngine::CppOwnership); connect(channel, SIGNAL(activated(bool)), SLOT(onSessionActivated(bool))); connect(channel, SIGNAL(destroyed(QObject*)), SLOT(onSessionDestroyed(QObject*))); m_channels << channel; emit channelsChanged(channels()); emit sessionCreated(channel); } return channel; }
JingleSession *JingleManager::createSession(const JID &responder, const QStringList &contents) { Q_D(JingleManager); if (JingleSession *session = d->sessionsByJid.value(responder)) return session; JingleSession *session = new JingleSession(responder, contents, d->client); emit sessionCreated(session); return session; }
void SessionServer::initSession(SessionState *session) { session->setHistoryLimit(_historyLimit); session->setPersistenceAllowed(allowPersistentSessions()); connect(session, &SessionState::userConnected, this, &SessionServer::moveFromLobby); connect(session, &SessionState::userDisconnected, this, &SessionServer::userDisconnectedEvent); connect(session, &SessionState::sessionAttributeChanged, [this](SessionState *ses) { emit sessionChanged(SessionDescription(*ses)); }); _sessions.append(session); emit sessionCreated(session); emit sessionChanged(SessionDescription(*session)); }
void SessionServer::initSession(Session *session) { session->setHistoryLimit(_historyLimit); session->setPersistenceAllowed(allowPersistentSessions()); session->setWelcomeMessage(welcomeMessage()); connect(session, &Session::userConnected, this, &SessionServer::moveFromLobby); connect(session, &Session::userDisconnected, this, &SessionServer::userDisconnectedEvent); connect(session, &Session::sessionAttributeChanged, [this](Session *ses) { emit sessionChanged(SessionDescription(*ses)); }); connect(session, &Session::requestAnnouncement, this, &SessionServer::announceSession); connect(session, &Session::requestUnlisting, this, &SessionServer::unlistSession); _sessions.append(session); emit sessionCreated(session); emit sessionChanged(SessionDescription(*session)); }