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


C++ DataStore::notificationCollector方法代码示例

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


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

示例1: parseStream

bool Link::parseStream()
{
    Protocol::LinkItemsCommand cmd(m_command);

    const Collection collection = HandlerHelper::collectionFromScope(cmd.destination(), connection());
    if (!collection.isVirtual()) {
        return failureResponse("Can't link items to non-virtual collections");
    }

    /* FIXME BIN
    Resource originalContext;
    Scope::SelectionScope itemSelectionScope = Scope::selectionScopeFromByteArray(m_streamParser->peekString());
    if (itemSelectionScope != Scope::None) {
        m_streamParser->readString();
        // Unset Resource context if destination collection is specified using HRID/RID,
        // because otherwise the Resource context is relative to the destination collection
        // instead of the source collection (collection context)
        if ((mDestinationScope.scope() == Scope::HierarchicalRid || mDestinationScope.scope() == Scope::Rid) && itemSelectionScope == Scope::Rid) {
            originalContext = connection()->context()->resource();
            connection()->context()->setResource(Resource());
        }
    }
    Scope itemScope(itemSelectionScope);
    itemScope.parseScope(m_streamParser);
    */

    SelectQueryBuilder<PimItem> qb;
    ItemQueryHelper::scopeToQuery(cmd.items(), connection()->context(), qb);

    /*
    if (originalContext.isValid()) {
        connection()->context()->setResource(originalContext);
    }
    */

    if (!qb.exec()) {
        return failureResponse("Unable to execute item query");
    }

    const PimItem::List items = qb.result();

    DataStore *store = connection()->storageBackend();
    Transaction transaction(store);

    PimItem::List toLink, toUnlink;
    const bool createLinks = (cmd.action() == Protocol::LinkItemsCommand::Link);
    for (const PimItem &item : items) {
        const bool alreadyLinked = collection.relatesToPimItem(item);
        bool result = true;
        if (createLinks && !alreadyLinked) {
            result = collection.addPimItem(item);
            toLink << item;
        } else if (!createLinks && alreadyLinked) {
            result = collection.removePimItem(item);
            toUnlink << item;
        }
        if (!result) {
            return failureResponse("Failed to modify item reference");
        }
    }

    if (!toLink.isEmpty()) {
        store->notificationCollector()->itemsLinked(toLink, collection);
    } else if (!toUnlink.isEmpty()) {
        store->notificationCollector()->itemsUnlinked(toUnlink, collection);
    }

    if (!transaction.commit()) {
        return failureResponse("Cannot commit transaction.");
    }

    return successResponse<Protocol::LinkItemsResponse>();
}
开发者ID:KDE,项目名称:akonadi,代码行数:73,代码来源:link.cpp


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