void AP_Dialog_CollaborationShare::share(AccountHandler* pAccount, const std::vector<std::string>& vAcl) { UT_DEBUGMSG(("AP_Dialog_CollaborationShare::_share()\n")); AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager(); UT_return_if_fail(pManager); // determine which document to share XAP_Frame* pFrame = XAP_App::getApp()->getLastFocussedFrame(); UT_return_if_fail(pFrame); PD_Document* pDoc = static_cast<PD_Document *>(pFrame->getCurrentDoc()); UT_return_if_fail(pDoc); AbiCollab* pSession = NULL; if (!pManager->isInSession(pDoc)) { UT_DEBUGMSG(("Sharing document...\n")); // FIXME: this can cause a race condition: the other side can already be // offered the session before we actually started it! // Tell the account handler that we start a new session, so // it set up things if needed. This call may just setup some stuff // for a new session, or it might actually start a new session. bool b = pAccount->startSession(pDoc, m_vAcl, &pSession); if (!b) { XAP_App::getApp()->getLastFocussedFrame()->showMessageBox( "There was an error sharing this document!", XAP_Dialog_MessageBox::b_O, XAP_Dialog_MessageBox::a_OK); return; } // start the session ourselves when the account handler did not... if (!pSession) { // ... and start the session! UT_UTF8String sSessionId(""); // TODO: we could use/generate a proper descriptor when there is only // 1 account where we share this document over pSession = pManager->startSession(pDoc, sSessionId, pAccount, true, NULL, ""); } } else { pSession = pManager->getSession(pDoc); } UT_return_if_fail(pSession); pManager->updateAcl(pSession, pAccount, vAcl); }
AbiCollab* AP_Dialog_CollaborationShare::_getActiveSession() { AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager(); UT_return_val_if_fail(pManager, NULL); XAP_Frame* pFrame = XAP_App::getApp()->getLastFocussedFrame(); UT_return_val_if_fail(pFrame, NULL); PD_Document* pDoc = static_cast<PD_Document *>(pFrame->getCurrentDoc()); UT_return_val_if_fail(pDoc, NULL); if (!pManager->isInSession(pDoc)) return NULL; return pManager->getSession(pDoc); }
bool AP_Dialog_CollaborationShare::_populateShareState(BuddyPtr pBuddy) { AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager(); UT_return_val_if_fail(pManager, false); PD_Document *pDoc = static_cast<PD_Document*>(XAP_App::getApp()->getLastFocussedFrame()->getCurrentDoc()); UT_return_val_if_fail(pDoc, false); if (!pManager->isInSession(pDoc)) { AccountHandler* pHandler = pBuddy->getHandler(); UT_return_val_if_fail(pHandler, false); return pHandler->defaultShareState(pBuddy); } return _inAcl(m_vAcl, pBuddy); }