summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-06-14 14:23:32 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-06-14 14:23:32 (GMT)
commit83f6dbd0036f3f2e23f9015626ef42d4836fbeee (patch)
tree0fbb4ce455b3b22133138ffcd7dd714cc3f652d1 /Swiften
parent94259d74a5f21d7dbe4ef30bfe433e3950c135f6 (diff)
downloadswift-contrib-83f6dbd0036f3f2e23f9015626ef42d4836fbeee.zip
swift-contrib-83f6dbd0036f3f2e23f9015626ef42d4836fbeee.tar.bz2
Improved session initialization from UI side
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Whiteboard/WhiteboardSessionManager.cpp17
-rw-r--r--Swiften/Whiteboard/WhiteboardSessionManager.h7
2 files changed, 18 insertions, 6 deletions
diff --git a/Swiften/Whiteboard/WhiteboardSessionManager.cpp b/Swiften/Whiteboard/WhiteboardSessionManager.cpp
index eae9e5b..eff0aae 100644
--- a/Swiften/Whiteboard/WhiteboardSessionManager.cpp
+++ b/Swiften/Whiteboard/WhiteboardSessionManager.cpp
@@ -38,7 +38,8 @@ namespace Swift {
OutgoingWhiteboardSession::ref session = boost::make_shared<OutgoingWhiteboardSession>(fullJID, router_);
sessions_[to.toBare()] = session;
session->onSessionTerminateReceived.connect(boost::bind(&WhiteboardSessionManager::handleSessionTerminate, this, _1));
- session->onSessionCancelled.connect(boost::bind(&WhiteboardSessionManager::handleSessionCancelled, this, _1));
+ session->onSessionCancelled.connect(boost::bind(&WhiteboardSessionManager::handleSessionCancel, this, _1));
+ session->onRequestAccepted.connect(boost::bind(&WhiteboardSessionManager::handleSessionAccept, this, _1));
return session;
}
@@ -47,6 +48,7 @@ namespace Swift {
if (!session) {
OutgoingWhiteboardSession::ref outgoingSession = createOutgoingSession(to);
outgoingSession->startSession();
+ onSessionRequest(to, true);
return outgoingSession;
} else {
return session;
@@ -56,8 +58,9 @@ namespace Swift {
void WhiteboardSessionManager::handleIncomingSession(IncomingWhiteboardSession::ref session) {
sessions_[session->getTo().toBare()] = session;
session->onSessionTerminateReceived.connect(boost::bind(&WhiteboardSessionManager::handleSessionTerminate, this, _1));
- session->onSessionCancelled.connect(boost::bind(&WhiteboardSessionManager::handleSessionCancelled, this, _1));
- onRequestReceived(session->getTo());
+ session->onSessionCancelled.connect(boost::bind(&WhiteboardSessionManager::handleSessionCancel, this, _1));
+ session->onRequestAccepted.connect(boost::bind(&WhiteboardSessionManager::handleSessionAccept, this, _1));
+ onSessionRequest(session->getTo(), false);
}
JID WhiteboardSessionManager::getFullJID(const JID& bareJID) {
@@ -67,9 +70,15 @@ namespace Swift {
void WhiteboardSessionManager::handleSessionTerminate(const JID& contact) {
sessions_.erase(contact.toBare());
+ onSessionTerminate(contact);
}
- void WhiteboardSessionManager::handleSessionCancelled(const JID& contact) {
+ void WhiteboardSessionManager::handleSessionCancel(const JID& contact) {
sessions_.erase(contact.toBare());
+ onSessionTerminate(contact);
+ }
+
+ void WhiteboardSessionManager::handleSessionAccept(const JID& contact) {
+ onRequestAccepted(contact);
}
}
diff --git a/Swiften/Whiteboard/WhiteboardSessionManager.h b/Swiften/Whiteboard/WhiteboardSessionManager.h
index d2a59e0..10f27d5 100644
--- a/Swiften/Whiteboard/WhiteboardSessionManager.h
+++ b/Swiften/Whiteboard/WhiteboardSessionManager.h
@@ -29,14 +29,17 @@ namespace Swift {
WhiteboardSession::ref requestSession(const JID& to);
public:
- boost::signal< void (const JID&)> onRequestReceived;
+ boost::signal< void (const JID&, bool senderIsSelf)> onSessionRequest;
+ boost::signal< void (const JID&)> onSessionTerminate;
+ boost::signal< void (const JID&)> onRequestAccepted;
private:
JID getFullJID(const JID& bareJID);
OutgoingWhiteboardSession::ref createOutgoingSession(const JID& to);
void handleIncomingSession(IncomingWhiteboardSession::ref session);
void handleSessionTerminate(const JID& contact);
- void handleSessionCancelled(const JID& contact);
+ void handleSessionCancel(const JID& contact);
+ void handleSessionAccept(const JID& contact);
private:
std::map<JID, boost::shared_ptr<WhiteboardSession> > sessions_;