当前位置: 首页>>代码示例>>C++>>正文


C++ AbiCollabSessionManager::setDocumentHandles方法代码示例

本文整理汇总了C++中AbiCollabSessionManager::setDocumentHandles方法的典型用法代码示例。如果您正苦于以下问题:C++ AbiCollabSessionManager::setDocumentHandles方法的具体用法?C++ AbiCollabSessionManager::setDocumentHandles怎么用?C++ AbiCollabSessionManager::setDocumentHandles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AbiCollabSessionManager的用法示例。


在下文中一共展示了AbiCollabSessionManager::setDocumentHandles方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _handlePacket


//.........这里部分代码省略.........
            // serialize entire document into string
            JoinSessionRequestResponseEvent jsre(jse->getSessionId(), iAuthorId);
            if (AbiCollabSessionManager::serializeDocument(pDoc, jsre.m_sZABW, false /* no base64 */) == UT_OK)
            {
                // set more document properties
                jsre.m_iRev = pDoc->getCRNumber();
                jsre.m_sDocumentId = pDoc->getDocUUIDString();
                if (pDoc->getFilename())
                    jsre.m_sDocumentName = UT_go_basename_from_uri(pDoc->getFilename());
                
                // send to buddy!
                send(&jsre, buddy);
                
                // add this buddy to the collaboration session
                pSession->addCollaborator(buddy);
            }
            break;
        }
        
        case PCT_JoinSessionRequestResponseEvent:
        {
            JoinSessionRequestResponseEvent* jsre = static_cast<JoinSessionRequestResponseEvent*>( packet );
            PD_Document* pDoc = 0;
            if (AbiCollabSessionManager::deserializeDocument(&pDoc, jsre->m_sZABW, false) == UT_OK)
            {
                if (pDoc)
                {
                    // NOTE: we could adopt the same document name here, but i'd
                    // rather not at the moment - MARCM
                    pDoc->forceDirty();
                    if (jsre->m_sDocumentName.size() > 0)
                    {
                        gchar* fname = g_strdup(jsre->m_sDocumentName.utf8_str());
                        pDoc->setFilename(fname);
                    }
                    // The default ownership when joining is FALSE, as that seems 
                    // to make sense for the generic case. The person sharing the 
                    // document by default owns the document (and is thus allowed
                    // to modify the ACL).
                    pManager->joinSession(jsre->getSessionId(), pDoc, jsre->m_sDocumentId, jsre->m_iRev, jsre->getAuthorId(), buddy, this, false, NULL);
                }
                else 
                {
                    UT_DEBUGMSG(("AccountHandler::_handlePacket() - deserializing document failed!\n"));
                }
            }
            break;
        }
        
        case PCT_GetSessionsEvent:
        {
            GetSessionsResponseEvent gsre;
            const UT_GenericVector<AbiCollab *> sessions = pManager->getSessions();
            for (UT_sint32 i = 0; i < sessions.getItemCount(); i++)
            {
                AbiCollab* pSession = sessions.getNthItem(i);
                if (pSession && pSession->isLocallyControlled())
                {
                    // check if the buddy has access to this session
                    if (!hasAccess(pSession->getAcl(), buddy))
                    {
                        UT_DEBUGMSG(("Buddy %s denied access to session %s by ALC\n", buddy->getDescriptor(true).utf8_str(), pSession->getSessionId().utf8_str()));
                        continue;
                    }

                    const PD_Document * pDoc = pSession->getDocument();
                    UT_continue_if_fail(pDoc);

                    // determine name
                    UT_UTF8String documentBaseName;
                    if (pDoc->getFilename())
                        documentBaseName = UT_go_basename_from_uri(pDoc->getFilename());
                    // set session info
                    gsre.m_Sessions[ pSession->getSessionId() ] = documentBaseName;
                }
            }
            send(&gsre, buddy);
            break;
        }
        
        case PCT_GetSessionsResponseEvent:
        {
            GetSessionsResponseEvent* gsre = static_cast<GetSessionsResponseEvent*>( packet );
            UT_GenericVector<DocHandle*> vDocHandles;
            for (std::map<UT_UTF8String,UT_UTF8String>::iterator it=gsre->m_Sessions.begin(); it!=gsre->m_Sessions.end(); ++it) {
                DocHandle* pDocHandle = new DocHandle((*it).first, (*it).second);
                vDocHandles.addItem(pDocHandle);
            }
            pManager->setDocumentHandles(buddy, vDocHandles);
            break;
        }
        
        default:
        {
            UT_DEBUGMSG(("Unhandled packet class: 0x%x\n", packet->getClassType()));
            UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
            break;
        }
    }
}
开发者ID:tchx84,项目名称:debian-abiword-packages,代码行数:101,代码来源:AccountHandler.cpp


注:本文中的AbiCollabSessionManager::setDocumentHandles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。