From 306bd468a8842220ccee2375a20fddc85519888f Mon Sep 17 00:00:00 2001 From: Lukas Karas Date: Sat, 26 Nov 2011 20:39:11 +0100 Subject: [PATCH] fix session id generator --- src/backend/session.cpp | 14 ++++++++++++-- src/backend/telepathy-client.cpp | 24 ++---------------------- src/ui-kde/roster-widget.cpp | 2 +- src/ui-kde/sessionview.cpp | 8 ++++---- src/ui-kde/wbscene.cpp | 2 +- src/ui-mobile/declarative/ContactDetailPopup.qml | 5 ++--- 6 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/backend/session.cpp b/src/backend/session.cpp index 070c4fd..dd49b88 100644 --- a/src/backend/session.cpp +++ b/src/backend/session.cpp @@ -69,7 +69,7 @@ Session::Session(const Tp::ChannelPtr &channel, SesstionTypes chatType, QObject } } if (!m_contact) { - qWarning() << "start session with unauthorized contact?!"; + qWarning() << "Session: start session with NULL contact?!"; } m_sessionName = m_contact ? m_contact->alias() : "undefined"; @@ -246,6 +246,11 @@ void Session::sendMessage(const QString& message) { if (message == QString()) return; + if (m_textChannel.isNull()){ + qWarning() << "Sesssion: m_textChannel shared pointer is NULL !!!"; + return; + } + //qDebug() << "Session: Sending message: " << message; connect(m_textChannel->send(message), SIGNAL(finished(Tp::PendingOperation *)), this, SLOT(onMessageSent(Tp::PendingOperation *))); @@ -334,7 +339,12 @@ bool Session::isMUC() { ///----------------------------------------------------------------------------------------------------------------------- void Session::startMediaCall(bool video) { - qDebug() << "Session: start media call"; + qDebug() << "Session: start media call (" << m_uniqueSessionName << ")"; + + if (m_contact.isNull()){ + qWarning() << "Session: m_contact shared pointer is NULL !!!"; + return; + } QVariantMap request; request.insert(TELEPATHY_INTERFACE_CHANNEL ".ChannelType", diff --git a/src/backend/telepathy-client.cpp b/src/backend/telepathy-client.cpp index b7ea4d3..6794b52 100644 --- a/src/backend/telepathy-client.cpp +++ b/src/backend/telepathy-client.cpp @@ -121,14 +121,14 @@ namespace MaknetoBackend { targetHandle = channel->targetHandle(); contact = account->connection()->contactManager()->lookupContactByHandle(targetHandle); - sessionName = Session::sessionNameForChannel(account, channel); + sessionName = Session::sessionName(account, contact); Q_ASSERT(sessionName != QString()); } else if (channel->targetHandleType() == Tp::HandleTypeRoom) { qDebug() << "TelepathyClient: Incoming channel is an MUC."; targetHandle = channel->targetHandle(); isMUC = true; - sessionName = Session::sessionNameForChannel(account, channel); + sessionName = Session::sessionName(account, contact); } qDebug() << "TelepathyClient: Channel to: " << channel->targetId(); @@ -307,26 +307,6 @@ namespace MaknetoBackend { return Session::sessionName(account, contact); } - /* - QString TelepathyClient::sessionNameForChannel(const Tp::ChannelPtr &channel) { - Tp::Contacts allContacts = channel->groupContacts(); - if (allContacts.size() == 2) { //one-to-one chat - - foreach(Tp::ContactPtr contact, allContacts) { - if (contact != channel->groupSelfContact()) - return contact->id(); - } - } else if (allContacts.size() == 1) { - Tp::Contacts pendingContacts = channel->groupRemotePendingContacts(); - if (pendingContacts.size() == 1) { - pendingContacts.begin()->constData()->id(); - } - } - //groupChat - return QString(); - } - */ - Tp::AccountPtr TelepathyClient::getAccountforChannel(const Tp::ChannelPtr &channel) { Tp::ConnectionPtr connection = channel->connection(); Tp::AccountPtr account; diff --git a/src/ui-kde/roster-widget.cpp b/src/ui-kde/roster-widget.cpp index b82fd05..1b64c8d 100644 --- a/src/ui-kde/roster-widget.cpp +++ b/src/ui-kde/roster-widget.cpp @@ -96,7 +96,7 @@ void RosterWidget::onInitializationFinished(MaknetoBackend::TelepathyClient *cli } void RosterWidget::onStartTextChat() { - qDebug() << "on start text chat"; + qDebug() << "RosterWidget: on start text chat"; emit textChatRequested(m_view->currentIndex()); } diff --git a/src/ui-kde/sessionview.cpp b/src/ui-kde/sessionview.cpp index 6d86157..736c9dd 100644 --- a/src/ui-kde/sessionview.cpp +++ b/src/ui-kde/sessionview.cpp @@ -328,7 +328,7 @@ void SessionView::sendWhiteboard(const QDomElement &wb) { QTextStream ts(&message); wb.save(ts, 0); - qDebug() << "wb:" << endl << message << endl << endl; + //qDebug() << "wb:" << endl << message << endl << endl; //TODO check the resource m_session->sendMessage(ts.readAll()); } @@ -356,19 +356,19 @@ void SessionView::onCallReady() { } void SessionView::onCallRequested() { - qDebug() << "Call requested"; + qDebug() << "SessionView: Call requested"; m_session->startMediaCall(false); } void SessionView::onVideoCallRequested() { - qDebug() << "Video Call requested"; + qDebug() << "SessionView: Video Call requested"; m_session->startMediaCall(true); } bool SessionView::acceptCallQuery() { // FIXME: SessionType flags is not setup yet! QString type = (m_session->getChatType().testFlag(MaknetoBackend::Session::SessionTypeVideo) ? "Video" : "Audio"); - qDebug() << "query for " + type + " call"; + qDebug() << "SessionView: query for " + type + " call"; if (QMessageBox::question(this, "Makneto", QString("Incoming " + type + " Call from " + m_session->getName() + ".\nAccept?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { diff --git a/src/ui-kde/wbscene.cpp b/src/ui-kde/wbscene.cpp index 17aa6e0..2fd3898 100644 --- a/src/ui-kde/wbscene.cpp +++ b/src/ui-kde/wbscene.cpp @@ -376,7 +376,7 @@ void WbScene::sendWb() { } void WbScene::queueNew(const QString &id, const qreal &index, const QDomElement &svg) { - qDebug() << "queueNew: " << svg.text(); + //qDebug() << "queueNew: " << svg.text(); QDomDocument d; QDomElement n = d.createElement("new"); n.setAttribute("id", id); diff --git a/src/ui-mobile/declarative/ContactDetailPopup.qml b/src/ui-mobile/declarative/ContactDetailPopup.qml index ba7436b..8367d54 100644 --- a/src/ui-mobile/declarative/ContactDetailPopup.qml +++ b/src/ui-mobile/declarative/ContactDetailPopup.qml @@ -80,7 +80,6 @@ AbstractPopup{ minimumWidth: maxButtonWidth onClicked: { - //log("request "+contactLine.accountId+" / "+contactLine.contactId +" ("+Makneto.Session.SessionTypeText+")"); main.getSessionController().requestSession(contactLine.accountId, contactLine.contactId, Makneto.Session.SessionTypeText); hidePopup(); } @@ -93,7 +92,7 @@ AbstractPopup{ minimumWidth: maxButtonWidth onClicked: { - // TODO + main.getSessionController().requestSession(contactLine.accountId, contactLine.contactId, Makneto.Session.SessionTypeAudio); hidePopup(); } } @@ -105,7 +104,7 @@ AbstractPopup{ minimumWidth: maxButtonWidth onClicked: { - // TODO + main.getSessionController().requestSession(contactLine.accountId, contactLine.contactId, Makneto.Session.SessionTypeVideo); hidePopup(); } } -- 2.11.4.GIT