Пример #1
0
static AJ_Status SetPasscode(const char* daemonRealm, const uint8_t* newPasscode, uint8_t newPasscodeLen)
{
    AJ_Status status = AJ_OK;
    char newStringPasscode[PASSWORD_VALUE_LENGTH + 1];

    status = AJ_RawToHex(newPasscode, newPasscodeLen, newStringPasscode, sizeof(newStringPasscode), FALSE);
    if (status != AJ_OK) {
        return status;
    }
    if (AJSVC_PropertyStore_SetValue(AJSVC_PROPERTY_STORE_REALM_NAME, daemonRealm) && AJSVC_PropertyStore_SetValue(AJSVC_PROPERTY_STORE_PASSCODE, newStringPasscode)) {

        status = AJSVC_PropertyStore_SaveAll();
        if (status != AJ_OK) {
            return status;
        }
        AJ_ClearCredentials();
        status = AJ_ERR_READ;     //Force disconnect of AJ and services to refresh current sessions
    } else {

        status = AJSVC_PropertyStore_LoadAll();
        if (status != AJ_OK) {
            return status;
        }
    }

    return status;
}
Пример #2
0
AJ_Status PropertyStore_Init()
{
    AJ_Status status = AJ_OK;
#ifdef CONFIG_SERVICE
    status = AJSVC_PropertyStore_LoadAll();
#endif
    InitMandatoryPropertiesInRAM();
    return status;
}
Пример #3
0
AJ_Status PropertyStore_Init()
{
    AJ_Status status = AJ_OK;
#ifdef CONFIG_SERVICE
    status = AJSVC_PropertyStore_LoadAll();
#endif
    InitMandatoryPropertiesInRAM();
    /*
     * About needs to get values from the property store
     */
    AJ_AboutRegisterPropStoreGetter(AboutPropGetter);
    return status;
}
Пример #4
0
AJ_Status PropertyStore_Init()
{
    AJ_Status status = AJ_OK;
    const char* const* supportedLanguage = propertyStoreDefaultLanguages;
    numberOfLanguages = 0;
    while (*(supportedLanguage++) != NULL) {
        numberOfLanguages++;
    }
#ifdef CONFIG_SERVICE
    status = AJSVC_PropertyStore_LoadAll();
#endif
    InitMandatoryPropertiesInRAM();
    /*
     * About needs to get values from the property store
     */
    AJ_AboutRegisterPropStoreGetter(AboutPropGetter);
    return status;
}
Пример #5
0
AJ_Status AJCFG_ResetConfigurationsHandler(AJ_Message* msg)
{
    AJ_Status status = AJ_OK;
    AJ_Arg array;
    AJ_Message reply;
    char* key;
    char* language;
    int8_t langIndex = AJSVC_PROPERTY_STORE_ERROR_LANGUAGE_INDEX;
    uint8_t numOfDeletedItems = 0;
    uint8_t errorReply = FALSE;

    AJ_InfoPrintf(("Handling ResetConfigurations request\n"));

    status = AJ_UnmarshalArgs(msg, "s", &language);
    if (status != AJ_OK) {
        goto Exit;
    }
    AJ_InfoPrintf(("Lang=%s\n", language));
    errorReply = !AJSVC_IsLanguageSupported(msg, &reply, language, &langIndex);
    if (!errorReply) {
        status = AJ_UnmarshalContainer(msg, &array, AJ_ARG_ARRAY);
        if (status != AJ_OK) {
            goto Exit;
        }
        while (1) {
            status = AJ_UnmarshalArgs(msg, "s", &key);
            if (status != AJ_OK) {
                break;
            }
            AJ_InfoPrintf(("Key=%s\n", key));
            status = AJSVC_PropertyStore_Reset(key, langIndex);
            if (status == AJ_OK) {
                numOfDeletedItems++;
            } else if (status == AJ_ERR_INVALID) {
                if (!errorReply) {
                    AJ_MarshalErrorMsg(msg, &reply, AJSVC_ERROR_INVALID_VALUE);
                    errorReply = TRUE;
                }
            } else if (status == AJ_ERR_FAILURE) {
                if (!errorReply) {
                    AJ_MarshalErrorMsg(msg, &reply, AJSVC_ERROR_UPDATE_NOT_ALLOWED);
                    errorReply = TRUE;
                }
            }
        }
        if (status != AJ_OK && status != AJ_ERR_NO_MORE) {
            goto Exit;
        }
        status = AJ_UnmarshalCloseContainer(msg, &array);
        if (status != AJ_OK) {
            goto Exit;
        }
    }
    if (!errorReply) {
        status = AJ_MarshalReplyMsg(msg, &reply);
        if (status != AJ_OK) {
            goto Exit;
        }
    }
    status = AJ_DeliverMsg(&reply);
    if (status != AJ_OK) {
        goto Exit;
    }

Exit:

    if (numOfDeletedItems) {
        if (errorReply) {
            AJSVC_PropertyStore_LoadAll(); // Discard partial successful deletions
        } else {
            AJSVC_PropertyStore_SaveAll();
            AJ_AboutSetShouldAnnounce();
        }
    }

    return status;
}