Ejemplo n.º 1
0
// ---------------------------------------------------------------------------
// Update existing service provider settings entry
// ---------------------------------------------------------------------------
//
TInt CSPSettingsEngine::UpdateEntryL( const CSPEntry& aEntry )
    {
    XSPSLOGSTRING( "CSPSettingsEngine::UpdateEntry() - IN" );

    TServiceId serviceId( aEntry.GetServiceId() );

    // Leave if there is no service ID 
    if ( KSPNoId == serviceId || aEntry.GetServiceName().Length() == 0 )
        {
        User::Leave( KErrArgument );
        }

    // construct RIpAppPropArray
    RIpAppPropArray array;
    TCleanupItem cleanup( CSPSettingsEngine::CleanupPointerArray, &array );
    CleanupStack::PushL( cleanup );
    
    ConvertSpEntryToCenRepArrayL( aEntry, array );

    TInt err = iCenRepUtils->UpdateEntryL( (TInt) serviceId, array );
    
    CleanupStack::PopAndDestroy( &array );
    
    XSPSLOGSTRING( "CSPSettingsEngine::UpdateEntry() - OUT" );
    
    return err;
    }
Ejemplo n.º 2
0
void DimmableLight::handleDimming(QString actionName, void *serviceToken, const QHash<QString, QString> &arguments)
{
    if (actionName == "SetLoadLevelTarget") {
        QString raw = QString();
        if (arguments.contains("newLoadlevelTarget"))
            raw = arguments.value("newLoadlevelTarget");

        if (raw.isEmpty() == false) {
            bool parseResult;
            int parsed = raw.toInt(&parseResult);
            if (parseResult) {
                if(parseResult < 0 || parseResult > 100){
                    _outArgs["__errorCode"]    = QString::number(601);
                    _outArgs["__errorMessage"] = "Argument Value Out of range";
                }else{
                    _dimming->setDimmingLevel(parsed);

                    lightLoadLevelChanged(getLightLoadLevel());
                    lightLevelChanged(getLightLevel());

                    QString serviceId(DIMMING_SERV_ID);
                    if (_udaStack != NULL)
                        _udaStack->sendEvent(serviceId, serviceToken, "LoadLevelStatus", raw);
                    if (_ucaStack != NULL)
                        _ucaStack->sendEvent(serviceId, NULL, "LoadLevelStatus", raw);
                    }
            } else {
                _outArgs["__errorCode"]    = QString::number(402);
                _outArgs["__errorMessage"] = "Wrong value, expected number.";
            }
        }else{
            _outArgs["__errorCode"]    = QString::number(402);
            _outArgs["__errorMessage"] = "Missing argument newLoadlevelTarget";
        }
    } else if (actionName == "GetLoadLevelTarget") {
        _outArgs["retLoadlevelTarget"] = QString::number(getLightLoadLevel());
    } else if (actionName == "GetLoadLevelStatus") {
        _outArgs["retLoadlevelStatus"] = QString::number(getLightLoadLevel());
    } else{
        _outArgs["__errorCode"] = QString::number(401);
        _outArgs["__errorMessage"] = "Invalid action";
    }
}
Ejemplo n.º 3
0
void DimmableLight::handleSwitchPower(QString actionName, void *serviceToken, const QHash<QString, QString> &arguments)
{
    if (actionName == "SetTarget") {
        QString raw = QString();
        if (arguments.contains("NewTargetValue"))
            raw = arguments.value("NewTargetValue");

        if (raw.isEmpty() == false) {
            bool parseResult;
            int parsed = raw.toInt(&parseResult);
            if (parseResult) {
                _switch->setEnabled(parsed);

                lightEnabledChanged(_switch->getEnabled() > 0);
                lightLevelChanged(getLightLevel());

                QString serviceId(SWITCHPOWER_SERV_ID);
                if (_udaStack != NULL)
                    _udaStack->sendEvent(serviceId, serviceToken, "Status", raw);
                if (_ucaStack != NULL)
                    _ucaStack->sendEvent(serviceId, NULL, "Status", raw);
            } else {
                _outArgs["__errorCode"]    = QString::number(402);
                _outArgs["__errorMessage"] = "Wrong value, expected boolean.";
            }
        }else{
            _outArgs["__errorCode"]    = QString::number(402);
            _outArgs["__errorMessage"] = "Missing argument NewTargetValue";
        }
    } else if (actionName == "GetTarget") {
        _outArgs["RetTargetValue"] = QString::number(getLightEnabled());
    } else if (actionName == "GetStatus") {
        _outArgs["ResultStatus"] = QString::number(getLightEnabled());
    } else{
        _outArgs["__errorCode"] = QString::number(401);
        _outArgs["__errorMessage"] = "Invalid action";
    }
}
Ejemplo n.º 4
0
// -----------------------------------------------------------------------------
// ShowTypedQueryL
// Shows list query and returns the user selection.
// -----------------------------------------------------------------------------
//
TUid CSendUiImpl::ShowTypedQueryL(
    CSendUi::TSendUiMenuType    aMenuType,
    const CMessageData*         aMessageData,
    TSendingCapabilities        aRequiredCapabilities,
    CArrayFix<TUid>*            aServicesToDim,
    const TDesC&                aTitleText )
{
    // Implemented for CR # 401-1806 >>
    // This section to enable/disable features (supported by feature manager) at run time, is to be revised,
    // once an observer class is available from feature manager side to intimate about feature state

    CRepository* repository = CRepository::NewLC( KCRUidSendUi );
    TInt oldFeatures(0);
    TInt newFeatures(0);
    TBool updateNeeded( EFalse );

    if ( repository->Get( KKeySendUiFeatureManagerServices, oldFeatures ) != KErrNone )
    {
        updateNeeded = ETrue;
    }
    FeatureManager::InitializeLibL();
    FeatureStatus( KFeatureIdMmsPostcard, newFeatures, KSendUiPostcard );
    FeatureStatus( KFeatureIdAudioMessaging, newFeatures, KSendUiAudioMessage );
    FeatureStatus( KFeatureIdSenduiMmsUpload, newFeatures, KSendUiMmsUpload );
    FeatureManager::UnInitializeLib();
    if ( newFeatures != oldFeatures )
    {
        repository->Set( KKeySendUiFeatureManagerServices, newFeatures );
        updateNeeded = ETrue;
    }

    CleanupStack::PopAndDestroy( repository );

    RProperty propertyUpdateOperation;
    TRequestStatus status;
    if ( updateNeeded )
    {
        RProperty::Set(
            KPSUidSendUiProperty,
            KSendUiUpdateRequest,
            KSendUiUpdateRequested );
        User::LeaveIfError( propertyUpdateOperation.Attach( KPSUidSendUiProperty, KSendUiUpdateRequest ));
        propertyUpdateOperation.Subscribe( status );
        User::WaitForRequest(status);
        TInt value = KErrNone;
        if(propertyUpdateOperation.Get( value ) !=KErrNotFound && value == KSendUiUpdated )
        {
            TRAPD( err, GetServicesL() );
            if ( err )
            {
#ifdef _DEBUG
                TBuf<256> buf;
                buf.Format(_L("SendUi err"));
                User::InfoPrint(buf);
#endif
                TUid serviceId( KNullUid );
                return serviceId;
            }
        }
        propertyUpdateOperation.Close();
    }
    // Implemented for CR # 401-1806 <<
    // List items for list query.
    CDesCArrayFlat* listItems = new (ELeave) CDesCArrayFlat( KArrayGranularity );
    CleanupStack::PushL( listItems);

    // This array is used to map user selection to correct service.
    CArrayFix<TUid>* listItemUids =
        new ( ELeave ) CArrayFixFlat<TUid>( KArrayGranularity );
    CleanupStack::PushL( listItemUids );

    iServicesToDim->Reset();

    TInt i = 0;
    if ( aServicesToDim )
    {
        for ( i = 0; i < aServicesToDim->Count(); i++  )
        {
            iServicesToDim->AppendL( (*aServicesToDim)[i] );
        }
    }

    // Get and filter ECom based services.
    FilterServicesL(
        *listItems,
        *listItemUids,
        aRequiredCapabilities,
        aMessageData,
        aMenuType );

    TUid serviceId( KNullUid );
    if ( listItems->Count() > 0 )
    {
        // Show list query.
        SortListL( *listItems, *listItemUids );

        serviceId = ShowListQueryL(
                        listItems,
                        *listItemUids,
                        aTitleText,
                        aMenuType );
    }

    CleanupStack::PopAndDestroy( 2, listItems );  // listItemUids, listItems

    return serviceId;
}