示例#1
0
void AssetRatingsJob::Private::parseRatings(const QVariantMap &result)
{
    QVariantList ratingsList = result[QLatin1String("ratings")].toList();
    QVariantList::const_iterator itr;
    for (itr = ratingsList.constBegin(); itr != ratingsList.constEnd(); ++itr) {
        AssetRatings info;
        QVariantMap attribute = itr->toMap();
        info.attributeId = attribute[QLatin1String("attribute")].toString();
        info.attributeName = attribute[QLatin1String("attributename")].toString();
        info.personId = attribute[QLatin1String("person")].toString();
        info.personName = attribute[QLatin1String("name")].toString();
        info.rated = QDateTime::fromTime_t(attribute[QLatin1String("rated")].toLongLong());
        QVariantList l = attribute[QLatin1String("ratings")].toList();
        QVariantList::const_iterator it;
        for (it = l.constBegin(); it != l.constEnd(); ++it) {
            Rating r;
            QVariantMap data = it->toMap();
            r.attributeId = data[QLatin1String("attribute")].toString();
            r.attributeName = data[QLatin1String("name")].toString();
            r.rating = data[QLatin1String("rating")].toString();
            info.ratings.append(r);
        }
        ratings.append(info);
    }
}
示例#2
0
void SimpleClient::load(const QVariant& settings)
{
    const QVariantMap map = settings.toMap();

    if (map.contains("dialogs"))
    {
        const QVariantList list = map.value("dialogs").toList();

        for (QVariantList::const_iterator it = list.begin();
                it != list.end(); ++it)
        {
            const QVariantMap map = it->toMap();
            const QString operation = map["operation"].toString();

            if (!operation.isEmpty() && map.contains("value"))
            {
                // find the index
                unsigned int i = 0;
                const unsigned int count =
                    m_objref->interface()->operation_count();

                for (; i < count; i++)
                {
                    const char * current =
                            m_objref->interface()->get_reflective_by_index(
                                    i)->get_name();

                    if (operation == current) break;
                }

                // load its saved value
                if (i < count)
                {
                    getRequestDialog(i)->load(map.value("value"));
                }
            }
        }
    }

    if (map.contains("filtered_log"))
    {
        m_filteredLog->load(map["filtered_log"]);
    }

    if (map.contains("operations"))
    {
        // ensure created
        showOperationSequenceTool();

        m_seqTool->load(map["operations"]);
    }
}
示例#3
0
void FilterModel::load(const QVariant& settings)
{
    const QVariantList list = settings.toList();

    for (QVariantList::const_iterator it = list.begin(); 
            it != list.end(); ++it) 
    {
        const QVariantMap map = it->toMap();

        if (!map.contains("instance") || !map.contains("operations"))
            continue;

        // Name to ID conversion
        const QString instance = map["instance"].toString();

        if (instance.isEmpty()) continue;

        Objref_ptr objref = m_instances.find(instance);

        if (!objref) continue;

        FirstLevelItems_t::iterator fit =  m_items.find(objref->id());

        if (fit == m_items.end()) continue;

        // End Name to ID conversion
        
        const QVariantMap operations = map["operations"].toMap();

        for (unsigned int j = 0; 
                j < objref->interface()->operation_count(); j++) 
        {
            OperationDescriptor_ptr op = 
                objref->interface()->get_reflective_by_index(j);
            tag_t tag = op->get_tag();

            OperationsMap_t::iterator opit = 
                fit.value().operations.find(tag);

            if(operations.contains(op->get_name()) && 
                    opit != fit.value().operations.end())
            {
                bool state = operations[op->get_name()].toBool();

                opit.value()->setCheckState((state)?
                        Qt::Checked: Qt::Unchecked);
            }
        }
    }
}
示例#4
0
QList<Notification> parseNotificationJson(const QVariantList &json)
{
    QList<Notification> item_list;

    for(QVariantList::const_iterator it = json.begin(); it != json.end(); ++it)
    {
        QVariantMap notification = it->toMap();
        Notification notif;
        notif.contentID = notification["contentId"].toString();
        notif.status = notification["status"].toString();
        item_list.append(notif);
    }

    return item_list;
}
示例#5
0
void ChannelsJob::Private::parseChannels(const QVariantMap &result)
{
    QVariantList channelsLst = result[QLatin1String("channels")].toList();
    QVariantList::const_iterator itr;
    for (itr = channelsLst.constBegin(); itr != channelsLst.constEnd(); ++itr) {
        ChannelInfo info;
        QVariantMap channel = itr->toMap();
        info.id = channel[QLatin1String("id")].toString();
        info.name = channel[QLatin1String("name")].toString();
        info.description = channel[QLatin1String("description")].toString();
        info.images = q->session()->urlsForImage(
                          channel[QLatin1String("image")].toString());
        info.assetCount = channel[QLatin1String("assetcount")].toInt();
        channels.append(info);
    }
}
void collectionListAssetsJob::Private::parseAssets(const QVariantMap &result)
{
    QVariantList assetsLst = result[QLatin1String("assets")].toList();
    QVariantList::const_iterator itr;
    for (itr = assetsLst.constBegin(); itr != assetsLst.constEnd(); ++itr) {
        AssetInfo info;
        QVariantMap asset = itr->toMap();
        info.id = asset[QLatin1String("id")].toString();
        info.license = asset[QLatin1String("license")].toString();
        info.partnerId = asset[QLatin1String("partnerid")].toString();
        info.partnerName = asset[QLatin1String("partnername")].toString();
        info.name = asset[QLatin1String("name")].toString();
        info.version = asset[QLatin1String("version")].toString();
        info.images = q->session()->urlsForImage(
            asset[QLatin1String("image")].toString());
        info.description = asset[QLatin1String("description")].toString();
        info.points = asset[QLatin1String("points")].toInt();
        assets.append(info);
    }
}
示例#7
0
QList<TitleInfo> parsePsnJson(const QVariantMap &json)
{
    QList<TitleInfo> item_list;

    bool ok = false;
    int total_results = json["total_results"].toInt(&ok);
    if(!ok) {
        return item_list;
    }

    qDebug() << "Total entitlements: " << total_results;
    QVariantList entitlements = json["entitlements"].toList();

    for(QVariantList::const_iterator it = entitlements.begin(); it != entitlements.end(); ++it)
    {
        QVariantMap entitlement = it->toMap();

        QString contentId;
        QString game_name;
        qlonglong package_size;
        QString package_url;
        ConsoleType console;
        int plus;

        if(entitlement["entitlement_type"].toInt() == 2) // PSP/PS3/VITA
        {
            contentId = entitlement["product_id"].toString();

            if(!entitlement.contains("drm_def"))
                continue;

            QMap<QString,QVariant> drm_def = entitlement["drm_def"].toMap();
            QVariantList drmContents = drm_def["drmContents"].toList();
            QMap<QString,QVariant> drmContent = drmContents[0].toMap();

            if(drm_def.contains("contentName"))
                game_name = drm_def["contentName"].toString();
            else
                game_name = drmContent["titleName"].toString();

            package_size = drmContent["contentSize"].toLongLong();
            package_url = drmContent["contentUrl"].toString();
            qlonglong platformIds = drmContent["platformIds"].toLongLong();
            plus = drmContent["gracePeriod"].toInt() > 0;

            switch(platformIds)
            {
            case 0x80000000: // ps3 game
            case 0x80800000: // ps3 addon
                console = PS3;
                break;
            case 0x08000000: // psm assistant and soul sacrifice demo
            case 0x88000000: // ps vita game
            case 0xFE100000:
                console = PSVITA;
                break;
            case 0xF8100000: // psp game
            case 0xF0100000: // demo
                console = PSP;
                break;
            default:
                console = UNKNOWN;
                break;
            }
        }
        else if(entitlement["entitlement_type"].toInt() == 5) // PS4
        {
            QMap<QString,QVariant> game_meta = entitlement["game_meta"].toMap();
            contentId = entitlement["product_id"].toString();
            game_name = game_meta["name"].toString();
            plus = entitlement.contains("inactive_date");
            QVariantList entitlement_attributes = entitlement["entitlement_attributes"].toList();
            QMap<QString,QVariant> entitlement_attribute = entitlement_attributes[0].toMap();
            package_size = entitlement_attribute["package_file_size"].toLongLong();
            package_url = entitlement_attribute["reference_package_url"].toString();
            console = PS4;
        }
        else // 1 or 3
        {
            continue;
        }

        TitleInfo item(contentId, game_name, package_size, package_url, console, plus);
        item_list << item;
    }

    qSort(item_list.begin(), item_list.end(), TitleInfo::lessThan);

    return item_list;
}