#include "com_funambol_omadmclient_android_testclientadapter_TestClientAdapter.h"
#include "ClientAdapter/TestClientAdapter.h"
#include <jni.h>

static NS_DM_Client::TestClientAdapter S_testClientAdapter;

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_GetManagementObject
(JNIEnv *env, jclass, jstring objectName)
{
    const char* str = env->GetStringUTFChars(objectName, 0);
    bool res = S_testClientAdapter.GetManagementObject(str);

    env->ReleaseStringUTFChars(objectName, str);
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_GetManagementTree
(JNIEnv * env, jclass, jstring uri)
{
    const char* str = env->GetStringUTFChars(uri, 0);
    bool res = S_testClientAdapter.GetManagementTree(str);

    env->ReleaseStringUTFChars(uri, str);
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_GetClientProfiles
(JNIEnv *, jclass)
{
    bool res = S_testClientAdapter.GetClientProfiles();
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_SetManagementObject
(JNIEnv * env, jclass, jstring objectName)
{
    const char* str = env->GetStringUTFChars(objectName, 0);
    bool res = S_testClientAdapter.SetManagementObject(str);

    env->ReleaseStringUTFChars(objectName, str);
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_Set
(JNIEnv * env, jclass, jstring filename)
{
    const char* str = env->GetStringUTFChars(filename, 0);
    bool res = S_testClientAdapter.Set(str);

    env->ReleaseStringUTFChars(filename, str);
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_SetEMSK
(JNIEnv * env, jclass, jstring emsk)
{
    const char* str = env->GetStringUTFChars(emsk, 0);
    bool res = S_testClientAdapter.SetEMSK(str);

    env->ReleaseStringUTFChars(emsk, str);
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_SetManufacturer
(JNIEnv * env, jclass, jstring manufacturer)
{
    const char* str = env->GetStringUTFChars(manufacturer, 0);
    bool res = S_testClientAdapter.SetManufacturer(str);

    env->ReleaseStringUTFChars(manufacturer, str);
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_SetModel
(JNIEnv * env, jclass, jstring model)
{
    const char* str = env->GetStringUTFChars(model, 0);
    bool res = S_testClientAdapter.SetModel(str);

    env->ReleaseStringUTFChars(model, str);
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_SetDeviceID
(JNIEnv * env, jclass, jstring deviceID)
{
    const char* str = env->GetStringUTFChars(deviceID, 0);
    bool res = S_testClientAdapter.SetDeviceID(str);

    env->ReleaseStringUTFChars(deviceID, str);
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_SetWiMAXDiagnostics
(JNIEnv *, jclass)
{
    bool res = S_testClientAdapter.SetWiMAXDiagnostics();
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_CheckFirmware
(JNIEnv *, jclass)
{
    bool res = S_testClientAdapter.CheckFirmware();
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_StartDMSession
(JNIEnv *, jclass)
{
    bool res = S_testClientAdapter.StartDMSession();
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_HandleProvision
(JNIEnv *, jclass)
{
    bool res = S_testClientAdapter.HandleProvision();
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_HandleConfirmation
(JNIEnv *, jclass)
{
    S_testClientAdapter.HandleConfirmation();
    return 1;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_Subscribe
(JNIEnv *, jclass)
{
    bool res = S_testClientAdapter.Subscribe();
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_DRMDReadyRequest
(JNIEnv *, jclass)
{
    S_testClientAdapter.DRMDReadyRequest();
    return 1;
}
//-------------------------------------------------------------------------------------------

JNIEXPORT jlong JNICALL Java_com_funambol_omadmclient_android_testclientadapter_TestClientAdapter_HandleNetworkEntry
(JNIEnv * env, jclass, jint hnspID, jstring operatorName)
{
    const char* str = env->GetStringUTFChars(operatorName, 0);
    bool res = S_testClientAdapter.HandleNetworkEntry(hnspID, str);

    env->ReleaseStringUTFChars(operatorName, str);
    return res? 1: 0;
}
//-------------------------------------------------------------------------------------------

jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
    JNIEnv* env;
    if(vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK){
        return -1;
    }

    return JNI_VERSION_1_6;
}
