int register_com_wunding_mlplayer_business_TUnDoneItem(JNIEnv* env) {
    static JNINativeMethod TUnDoneItemMethods[] = {
        { "nativeConstructor", "()V", (void*)TUnDoneItem_nativeConstructor},
        { "nativeDestructor", "()V", (void*)TUnDoneItem_nativeDestructor },
        { "GetType", "()Ljava/lang/String;", (void*)TUnDoneItem_GetType },
        { "SetType", "(Ljava/lang/String;)Z", (void*)TUnDoneItem_SetType },
        { "GetItemCount", "()I", (void*)TUnDoneItem_GetItemCount },
        { "SetItemCount", "(I)Z", (void*)TUnDoneItem_SetItemCount }
    };


    jclass clazz = env->FindClass("com/wunding/mlplayer/business/TUnDoneItem");
    if (clazz == 0) {
        CM_ERR("class TUnDoneItem no found");
        return -1;
    }

    gTUnDoneItemFieldID.nativeJavaObj = env->GetFieldID(clazz, "mNativeObj", "I");
    if (gTUnDoneItemFieldID.nativeJavaObj == 0) {
        CM_ERR("TUnDoneItem no found mNativeObj");
        return -1;
    }

    return env->RegisterNatives(clazz,
            TUnDoneItemMethods,
            sizeof(TUnDoneItemMethods) / sizeof(TUnDoneItemMethods[0]));
}
int register_com_wunding_mlplayer_business_TQAItem(JNIEnv* env) {
    static JNINativeMethod TQAItemMethods[] = {
        { "nativeConstructor", "()V", (void*)TQAItem_nativeConstructor},
        { "nativeDestructor", "()V", (void*)TQAItem_nativeDestructor },
        { "GetID", "()Ljava/lang/String;", (void*)TQAItem_GetID },
        { "SetID", "(Ljava/lang/String;)Z", (void*)TQAItem_SetID },
        { "GetQuestion", "()Ljava/lang/String;", (void*)TQAItem_GetQuestion },
        { "SetQuestion", "(Ljava/lang/String;)Z", (void*)TQAItem_SetQuestion },
        { "GetQuestioner_username", "()Ljava/lang/String;", (void*)TQAItem_GetQuestioner_username },
        { "SetQuestioner_username", "(Ljava/lang/String;)Z", (void*)TQAItem_SetQuestioner_username },
        { "GetQuestioner_fullname", "()Ljava/lang/String;", (void*)TQAItem_GetQuestioner_fullname },
        { "SetQuestioner_fullname", "(Ljava/lang/String;)Z", (void*)TQAItem_SetQuestioner_fullname },
        { "GetQuestioner_icon", "()Ljava/lang/String;", (void*)TQAItem_GetQuestioner_icon },
        { "SetQuestioner_icon", "(Ljava/lang/String;)Z", (void*)TQAItem_SetQuestioner_icon },
        { "GetPubdate", "()Ljava/lang/String;", (void*)TQAItem_GetPubdate },
        { "SetPubdate", "(Ljava/lang/String;)Z", (void*)TQAItem_SetPubdate },
        { "GetQcategorytitle", "()Ljava/lang/String;", (void*)TQAItem_GetQcategorytitle },
        { "SetQcategorytitle", "(Ljava/lang/String;)Z", (void*)TQAItem_SetQcategorytitle },
        { "GetQcategoryid", "()Ljava/lang/String;", (void*)TQAItem_GetQcategoryid },
        { "SetQcategoryid", "(Ljava/lang/String;)Z", (void*)TQAItem_SetQcategoryid },
        { "GetIsanonymity", "()Z", (void*)TQAItem_GetIsanonymity },
        { "SetIsanonymity", "(Z)Z", (void*)TQAItem_SetIsanonymity },
        { "GetVC", "()I", (void*)TQAItem_GetVC },
        { "SetVC", "(I)Z", (void*)TQAItem_SetVC },
        { "GetPV", "()I", (void*)TQAItem_GetPV },
        { "SetPV", "(I)Z", (void*)TQAItem_SetPV },
        { "GetAnswercount", "()I", (void*)TQAItem_GetAnswercount },
        { "SetAnswercount", "(I)Z", (void*)TQAItem_SetAnswercount },
        { "GetValue", "()I", (void*)TQAItem_GetValue },
        { "SetValue", "(I)Z", (void*)TQAItem_SetValue },
        { "GetAttention", "()I", (void*)TQAItem_GetAttention },
        { "SetAttention", "(I)Z", (void*)TQAItem_SetAttention },
        { "GetIsresolved", "()Z", (void*)TQAItem_GetIsresolved },
        { "SetIsresolved", "(Z)Z", (void*)TQAItem_SetIsresolved },
        { "GetPic_url", "()Ljava/lang/String;", (void*)TQAItem_GetPic_url },
        { "SetPic_url", "(Ljava/lang/String;)Z", (void*)TQAItem_SetPic_url },
        { "GetThumburl", "()Ljava/lang/String;", (void*)TQAItem_GetThumburl },
        { "SetThumburl", "(Ljava/lang/String;)Z", (void*)TQAItem_SetThumburl }
    };


    jclass clazz = env->FindClass("com/wunding/mlplayer/business/TQAItem");
    if (clazz == 0) {
        CM_ERR("class TQAItem no found");
        return -1;
    }

    gTQAItemFieldID.nativeJavaObj = env->GetFieldID(clazz, "mNativeObj", "I");
    if (gTQAItemFieldID.nativeJavaObj == 0) {
        CM_ERR("TQAItem no found mNativeObj");
        return -1;
    }

    return env->RegisterNatives(clazz,
            TQAItemMethods,
            sizeof(TQAItemMethods) / sizeof(TQAItemMethods[0]));
}
int register_com_wunding_mlplayer_business_CMCategory(JNIEnv* env) {
    static JNINativeMethod CMCategoryMethods[] = {
        { "nativeConstructor", "(Ljava/lang/Object;)V", (void*)CMCategory_nativeConstructor},
        { "nativeDestructor", "()V", (void*)CMCategory_nativeDestructor },
        { "GetItemCount", "()I", (void*)CMCategory_GetItemCount },
        { "GetItem", "(ILcom/wunding/mlplayer/business/CMCategoryItem;)Z", (void*)CMCategory_GetItem },
        { "Refresh", "(Lcom/wunding/mlplayer/business/CMCategoryItem;)Z", (void*)CMCategory_Refresh },
        { "Update", "(Lcom/wunding/mlplayer/business/CMCategoryItem;)Z", (void*)CMCategory_Update },
        { "IsEnd", "()Z", (void*)CMCategory_IsEnd },
        { "RequestMore", "()Z", (void*)CMCategory_RequestMore },
        { "IsRunning", "()Z", (void*)CMCategory_IsRunning },
        { "IsRefresh", "()Z", (void*)CMCategory_IsRefresh },
        { "Cancel", "()V", (void*)CMCategory_Cancel },
        { "SetRequestType", "(I)V", (void*)CMCategory_SetRequestType },
        { "nativeSetListener", "(Ljava/lang/Object;)V", (void*)CMCategory_SetListener },
        { "UpdateData", "()Z", (void*)CMCategory_UpdateData },
        { "UpdateCategoryList", "()Z", (void*)CMCategory_UpdateCategoryList },
        { "TopItemCount", "()I", (void*)CMCategory_TopItemCount },
        { "GetTopItem", "(I)Lcom/wunding/mlplayer/business/CMCategoryItem;", (void*)CMCategory_GetTopItem },
        { "SetExamSurveyCount", "(ILjava/lang/String;)V", (void*)CMCategory_SetExamSurveyCount },
        { "GetCacheData", "()Z", (void*)CMCategory_GetCacheData }
    };


    jclass clazz = env->FindClass("com/wunding/mlplayer/business/CMCategory");
    if (clazz == 0) {
        CM_ERR("class CMCategory no found");
        return -1;
    }

    gCMCategoryFieldID.nativeJavaObj = env->GetFieldID(clazz, "mNativeObj", "I");
    if (gCMCategoryFieldID.nativeJavaObj == 0) {
        CM_ERR("CMCategory no found mNativeObj");
        return -1;
    }

    gCMCategoryFieldID.jniData = env->GetFieldID(clazz, "mJniData", "I");
    if (gCMCategoryFieldID.jniData == 0) {
        CM_ERR("CMCategory no found mJniData");
        return -1;
    }

    // Get the postEvent method
    gCMCategoryFieldID.callback = env->GetStaticMethodID(
            clazz, "callback", "(Ljava/lang/Object;III)V");
    if (gCMCategoryFieldID.callback == NULL) {
        CM_ERR("CMCategory no found callback");
        return -1;
    }

    return env->RegisterNatives(clazz,
            CMCategoryMethods,
            sizeof(CMCategoryMethods) / sizeof(CMCategoryMethods[0]));
}
void CMSocketC::OnTimer(CMTimer &cTimer)
{
    if (m_status == NOTCONNECTED)
    {
        CMNetConnMgr& mgr = CMNetConnMgr::Instance();
        //未连接时OnTimer是因为接入还未成功,
        if (mgr.CurrentType() == CMNetConnMgr::NONE)
        {
            if (mgr.CurrentState() == 1)
            {
                //正在连接中,继续等待
                m_cTimer.Set(3000);   
                m_cTimer.Start();
            }
            else
            {
                m_pNotify->OnConnect(MERN_INITIALIZE); 
            }
            return;
        }
        else
        {
            //接入成功,开始连接
            Connect(m_sHost, m_nPort);
        }
    }
    else if (m_status == RECVING)
    {
        CM_ERR("Recving timeout");
        Cancel();
        m_pNotify->OnRecv(MERN_TIMEOUT, 0);
    }
    else if (m_status == SENDING)
    {
        CM_ERR("Sending timeout");
        Cancel();
        m_pNotify->OnSend(MERN_TIMEOUT, 0);
    }
    else if (m_status == CONNECTING)
    {
        CM_ERR("Connecting timeout");
        Cancel();
        m_pNotify->OnConnect(MERN_TIMEOUT);
    }
    else
    {
        CM_ERRP("status %d timeout", m_status);
        Cancel();        
        m_pNotify->OnConnect(MERN_TIMEOUT);
    }
}
void CMSocketC::Recv(INT8* pBuf, INT32 nLen)
{
    if (m_status == NOTCONNECTED)
    {
        CM_ERR("CMSocketC::Recv status notconnected");
        m_pNotify->OnRecv(MERN_NOT_CONNECTED, 0);
        return;
    }
    else if (m_status == SENDING)
    {
        CM_ERR("CMSocketC::Recv status sending");
        m_pNotify->OnRecv(MERN_SENDING, 0);
        return;
    }
    else if (m_status == RECVING)
    {
        CM_ERR("CMSocketC::Recv status recving");
        m_pNotify->OnRecv(MERN_RECVING, 0);
        return;
    }

    //理论上要求不会出现Active情况
    ASSERT(!IsActive());
    
    if (pBuf == NULL || nLen <= 0)
    {
        m_pNotify->OnRecv(MERN_WRONG_PARAM, 0);
        return;
    }
    
    m_nBufLen = nLen;
    if (m_pRecvBuf)
    {
        delete m_pRecvBuf;
        m_pRecvBuf = NULL;
    }
    //memset(pBuf, 0, nLen);  //无必要,屏蔽掉
    m_pRecvBuf = new TPtr8((UINT8*)pBuf, nLen);
    m_cLen = (TInt)0;
    m_sk.RecvOneOrMore(*m_pRecvBuf, 0, iStatus, m_cLen);
    m_status = RECVING;
    m_cTimer.Stop();
    m_cTimer.Start();
    CM_LOGP(CM_LOGL_DEBUG, "CMSocketC::Recv start. len %d", nLen);
    SetActive();

    return;
}
Esempio n. 6
0
static void _cota_fetch(void* user_data, int is_fetch, char* configId, uint32_t configSize,
                        char *sign, char *signMethod, char* url, char* getType)
{
    iotx_cm_conntext_t* cm_ctx = (iotx_cm_conntext_t*)user_data;

    if (NULL == cm_ctx) {
        CM_ERR(cm_log_error_parameter);
        return;
    }

    /* start */
    if (0 == is_fetch) {
        iotx_cm_cota_parameter_t ota_parameter = {0};

        ota_parameter.configId = configId;
        ota_parameter.configSize = configSize;
        ota_parameter.sign = sign;
        ota_parameter.signMethod = signMethod;
        ota_parameter.url = url;
        ota_parameter.getType = getType;

        if (cm_ctx->cota_func) cm_ctx->cota_func(cm_ctx, &ota_parameter, cm_ctx->cota_user_context);
    } else {
        g_cm_ota_status = 1;
    }
}
Esempio n. 7
0
uint32_t iot_context_manager_table_alloc(const iot_interface_t * p_interface)
{
    VERIFY_MODULE_IS_INITIALIZED();
    NULL_PARAM_CHECK(p_interface);

    uint32_t err_code = NRF_SUCCESS;

    CM_ENTRY();

    CM_MUTEX_LOCK();

    const uint32_t table_id = context_table_find(NULL);

    if (table_id != IOT_CONTEXT_MANAGER_MAX_TABLES)
    {
        // Found a free context table and assign to it.
        CM_TRC("Assigned new context table.");
        m_context_table[table_id].p_interface = (iot_interface_t *)p_interface;
    }
    else
    {
        // No free context table found.
        CM_ERR("No context table found.");
        err_code = (NRF_ERROR_NO_MEM | IOT_CONTEXT_MANAGER_ERR_BASE);
    }

    CM_MUTEX_UNLOCK();

    CM_EXIT();

    return err_code;
}
Esempio n. 8
0
uint32_t iot_context_manager_table_free(const iot_interface_t * p_interface)
{
    VERIFY_MODULE_IS_INITIALIZED();
    NULL_PARAM_CHECK(p_interface);

    uint32_t err_code = NRF_SUCCESS;

    CM_ENTRY();

    SDK_MUTEX_INIT(m_iot_context_manager_mutex);

    CM_MUTEX_LOCK();

    const uint32_t table_id = context_table_find(p_interface);

    if (table_id != IOT_CONTEXT_MANAGER_MAX_TABLES)
    {
        // Clear context table.
        CM_TRC("Found context table assigned to interface.");
        context_table_init(table_id);
    }
    else
    {
        // No free context table found.
        CM_ERR("No context table found.");
        err_code = (NRF_ERROR_NOT_FOUND | IOT_CONTEXT_MANAGER_ERR_BASE);
    }

    CM_MUTEX_UNLOCK();

    CM_EXIT();

    return err_code;
}
Esempio n. 9
0
int iotx_cm_cloud_conn_register_handler(iotx_cm_conntext_t* cm_ctx, char* URI, int result, int is_register)
{
    iotx_cm_event_msg_t event;
    iotx_cm_event_result_t event_result = {0};

    if (NULL == cm_ctx || NULL == URI) {
        CM_ERR(cm_log_error_parameter);
        return FAIL_RETURN;
    }

    event_result.result = result;
    event_result.URI = CM_malloc(CM_TOPIC_LEN_MAX);
    if (event_result.URI) {
        strncpy(event_result.URI, URI, CM_TOPIC_LEN_MAX);
    } else {
        return FAIL_RETURN;
    }

    if (is_register)
        event.event_id = IOTX_CM_EVENT_REGISTER_RESULT;
    else
        event.event_id = IOTX_CM_EVENT_UNREGISTER_RESULT;

    event.msg = (void*)&event_result;

    iotx_cm_trigger_event_callback(cm_ctx, &event);

    LITE_free(event_result.URI);

    return SUCCESS_RETURN;
}
Esempio n. 10
0
uint32_t iot_context_manager_get_by_addr(const iot_interface_t * p_interface,
                                         const ipv6_addr_t     * p_addr,
                                         iot_context_t        ** pp_context)
{
    VERIFY_MODULE_IS_INITIALIZED();
    NULL_PARAM_CHECK(p_interface);
    NULL_PARAM_CHECK(p_addr);
    NULL_PARAM_CHECK(pp_context);

    uint32_t err_code;

    CM_ENTRY();

    CM_MUTEX_LOCK();

    const uint32_t table_id = context_table_find(p_interface);

    if (table_id != IOT_CONTEXT_MANAGER_MAX_TABLES)
    {
        err_code = context_find_by_prefix(table_id, p_addr, pp_context);
    }
    else
    {
        // No free context table found.
        CM_ERR("No context table found.");
        err_code = (NRF_ERROR_NOT_FOUND | IOT_CONTEXT_MANAGER_ERR_BASE);
    }

    CM_MUTEX_UNLOCK();

    CM_EXIT();

    return err_code;
}
Esempio n. 11
0
/*  alcs */
void* iotx_local_conn_alcs_init(void* handle)
{
    iotx_alcs_param_t alcs_param;
    iotx_alcs_event_handle_t event_handle;
    void *pclient;

    memset(&alcs_param, 0x0, sizeof(iotx_alcs_param_t));
    memset(&event_handle, 0x0, sizeof(iotx_alcs_event_handle_t));

    alcs_param.group = (char*)string_group;
    alcs_param.port = _alcs_port;
    alcs_param.send_maxcount = _alcs_send_maxcount;
    alcs_param.waittime = _alcs_waittime;
    alcs_param.obs_maxcount = _alcs_obs_maxcount;
    alcs_param.role = IOTX_ALCS_ROLE_CLIENT | IOTX_ALCS_ROLE_SERVER;
    event_handle.h_fp = _alcs_event_handler;
    event_handle.pcontext = handle;

    alcs_param.handle_event = &event_handle;

    if (NULL == (pclient = IOT_ALCS_Construct(&alcs_param))) {
        CM_ERR(cm_log_error_fail);
        return NULL;
    }

    return pclient;
}
Esempio n. 12
0
int iotx_cm_ota_get_config(iotx_cm_conntext_t* cm_ctx, const char* configScope, const char* getType, const char* attributeKeys)
{
    if (NULL == cm_ctx || NULL == cm_ctx->ota_handler) {
        CM_ERR(cm_log_error_parameter);
        return FAIL_RETURN;
    }

    return IOT_OTA_GetConfig(cm_ctx->ota_handler, configScope, getType, attributeKeys);
}
Esempio n. 13
0
int iotx_cm_ota_request_image(iotx_cm_conntext_t* cm_ctx, const char* version)
{
    if (NULL == cm_ctx || NULL == cm_ctx->ota_handler) {
        CM_ERR(cm_log_error_parameter);
        return FAIL_RETURN;
    }

    return IOT_OTA_RequestImage(cm_ctx->ota_handler, version);
}
Esempio n. 14
0
int iotx_cm_ota_deinit(iotx_cm_conntext_t* cm_ctx)
{
    if (NULL == cm_ctx || NULL == cm_ctx->ota_handler) {
        CM_ERR(cm_log_error_parameter);
        return FAIL_RETURN;
    }

    return IOT_OTA_Deinit(cm_ctx->ota_handler);
}
Esempio n. 15
0
int register_com_wunding_mlplayer_business_CMCategoryItem(JNIEnv* env) {
    static JNINativeMethod CMCategoryItemMethods[] = {
        { "nativeConstructor", "()V", (void*)CMCategoryItem_nativeConstructor},
        { "nativeDestructor", "()V", (void*)CMCategoryItem_nativeDestructor },
        { "FrontChildItemCount", "()I", (void*)CMCategoryItem_FrontChildItemCount },
        { "ChildItemCount", "()I", (void*)CMCategoryItem_ChildItemCount },
        { "GetChildItem", "(I)Lcom/wunding/mlplayer/business/CMCategoryItem;", (void*)CMCategoryItem_GetChildItem },
        { "GetPositionCourseItem", "()I", (void*)CMCategoryItem_GetPositionCourseItem },
        { "EnablesubscriptionChildItemCount", "()I", (void*)CMCategoryItem_EnablesubscriptionChildItemCount },
        { "RemoveChildItem", "(I)V", (void*)CMCategoryItem_RemoveChildItem },
        { "GetEnablesubscriptionChildItem", "(I)Lcom/wunding/mlplayer/business/CMCategoryItem;", (void*)CMCategoryItem_GetEnablesubscriptionChildItem },
        { "GetSubscription", "()Z", (void*)CMCategoryItem_GetSubscription },
        { "SetSubscription", "(Z)V", (void*)CMCategoryItem_SetSubscription },
        { "GetID", "()Ljava/lang/String;", (void*)CMCategoryItem_GetID },
        { "SetID", "(Ljava/lang/String;)Z", (void*)CMCategoryItem_SetID },
        { "GetType", "()Ljava/lang/String;", (void*)CMCategoryItem_GetType },
        { "SetType", "(Ljava/lang/String;)Z", (void*)CMCategoryItem_SetType },
        { "GetTitle", "()Ljava/lang/String;", (void*)CMCategoryItem_GetTitle },
        { "SetTitle", "(Ljava/lang/String;)Z", (void*)CMCategoryItem_SetTitle },
        { "GetImage", "()Ljava/lang/String;", (void*)CMCategoryItem_GetImage },
        { "SetImage", "(Ljava/lang/String;)Z", (void*)CMCategoryItem_SetImage },
        { "GetEnablesubscription", "()Z", (void*)CMCategoryItem_GetEnablesubscription },
        { "SetEnablesubscription", "(Z)Z", (void*)CMCategoryItem_SetEnablesubscription },
        { "GetItemcount", "()I", (void*)CMCategoryItem_GetItemcount },
        { "SetItemcount", "(I)Z", (void*)CMCategoryItem_SetItemcount }
    };


    jclass clazz = env->FindClass("com/wunding/mlplayer/business/CMCategoryItem");
    if (clazz == 0) {
        CM_ERR("class CMCategoryItem no found");
        return -1;
    }

    gCMCategoryItemFieldID.nativeJavaObj = env->GetFieldID(clazz, "mNativeObj", "I");
    if (gCMCategoryItemFieldID.nativeJavaObj == 0) {
        CM_ERR("CMCategoryItem no found mNativeObj");
        return -1;
    }

    return env->RegisterNatives(clazz,
            CMCategoryItemMethods,
            sizeof(CMCategoryItemMethods) / sizeof(CMCategoryItemMethods[0]));
}
Esempio n. 16
0
int register_com_wunding_mlplayer_business_CMBrowser(JNIEnv* env) {
    static JNINativeMethod CMBrowserMethods[] = {
        { "nativeConstructor", "(Ljava/lang/Object;)V", (void*)CMBrowser_nativeConstructor},
        { "nativeDestructor", "()V", (void*)CMBrowser_nativeDestructor },
        { "Request", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*)CMBrowser_Request },
        { "RequestPisitionCourse", "()Z", (void*)CMBrowser_RequestPisitionCourse },
        { "RequestMarkClass", "(Ljava/lang/String;)Z", (void*)CMBrowser_RequestMarkClass },
        { "RequestCoursewareById", "(Ljava/lang/String;)Z", (void*)CMBrowser_RequestCoursewareById },
        { "RequestNewsById", "(Ljava/lang/String;)Z", (void*)CMBrowser_RequestNewsById },
        { "RequestTrain", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*)CMBrowser_RequestTrain },
        { "RequestTop", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*)CMBrowser_RequestTop }
    };


    jclass clazz = env->FindClass("com/wunding/mlplayer/business/CMBrowser");
    if (clazz == 0) {
        CM_ERR("class CMBrowser no found");
        return -1;
    }

    gCMBrowserFieldID.nativeJavaObj = env->GetFieldID(clazz, "mNativeObj", "I");
    if (gCMBrowserFieldID.nativeJavaObj == 0) {
        CM_ERR("CMBrowser no found mNativeObj");
        return -1;
    }

    gCMBrowserFieldID.jniData = env->GetFieldID(clazz, "mJniData", "I");
    if (gCMBrowserFieldID.jniData == 0) {
        CM_ERR("CMBrowser no found mJniData");
        return -1;
    }

    // Get the postEvent method
    gCMBrowserFieldID.callback = env->GetStaticMethodID(
            clazz, "callback", "(Ljava/lang/Object;III)V");
    if (gCMBrowserFieldID.callback == NULL) {
        CM_ERR("CMBrowser no found callback");
        return -1;
    }

    return env->RegisterNatives(clazz,
            CMBrowserMethods,
            sizeof(CMBrowserMethods) / sizeof(CMBrowserMethods[0]));
}
int register_com_wunding_mlplayer_business_CMRepalycomment(JNIEnv* env) {
    static JNINativeMethod CMRepalycommentMethods[] = {
        { "nativeConstructor", "(Ljava/lang/Object;)V", (void*)CMRepalycomment_nativeConstructor},
        { "nativeDestructor", "()V", (void*)CMRepalycomment_nativeDestructor },
        { "ReplyComment", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z", (void*)CMRepalycomment_ReplyComment },
        { "RequestRepalyCommentList", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*)CMRepalycomment_RequestRepalyCommentList },
        { "RequestMore", "()Z", (void*)CMRepalycomment_RequestMore },
        { "GetItemCount", "()I", (void*)CMRepalycomment_GetItemCount },
        { "GetItem", "(ILcom/wunding/mlplayer/business/TRepalymentItem;)Z", (void*)CMRepalycomment_GetItem },
        { "Cancel", "()V", (void*)CMRepalycomment_Cancel },
        { "IsEnd", "()Z", (void*)CMRepalycomment_IsEnd }
    };


    jclass clazz = env->FindClass("com/wunding/mlplayer/business/CMRepalycomment");
    if (clazz == 0) {
        CM_ERR("class CMRepalycomment no found");
        return -1;
    }

    gCMRepalycommentFieldID.nativeJavaObj = env->GetFieldID(clazz, "mNativeObj", "I");
    if (gCMRepalycommentFieldID.nativeJavaObj == 0) {
        CM_ERR("CMRepalycomment no found mNativeObj");
        return -1;
    }

    gCMRepalycommentFieldID.jniData = env->GetFieldID(clazz, "mJniData", "I");
    if (gCMRepalycommentFieldID.jniData == 0) {
        CM_ERR("CMRepalycomment no found mJniData");
        return -1;
    }

    // Get the postEvent method
    gCMRepalycommentFieldID.callback = env->GetStaticMethodID(
            clazz, "callback", "(Ljava/lang/Object;III)V");
    if (gCMRepalycommentFieldID.callback == NULL) {
        CM_ERR("CMRepalycomment no found callback");
        return -1;
    }

    return env->RegisterNatives(clazz,
            CMRepalycommentMethods,
            sizeof(CMRepalycommentMethods) / sizeof(CMRepalycommentMethods[0]));
}
Esempio n. 18
0
void* iotx_cm_ota_init(iotx_cm_conntext_t* cm_ctx, const char* version)
{
    linked_list_t* list;
    void* h_ota = NULL;
    iotx_device_info_t* device_info = iotx_device_info_get();
    iotx_connection_t* connection = NULL;

    connection = (iotx_connection_t*)cm_ctx->target_connectivity->context;

    if (NULL == cm_ctx || NULL == version) {
        CM_ERR(cm_log_error_parameter);
        return NULL;
    }

    list = cm_ctx->list_connectivity;

    cm_ctx->target_connectivity = NULL;
    linked_list_iterator(list, cm_find_ota_connectivity_handler, cm_ctx, IOTX_CM_CONNECTIVITY_TYPE_CLOUD);

    if (cm_ctx->target_connectivity) {
        h_ota = IOT_OTA_Init(device_info->product_key, device_info->device_name, connection->context);
        if (NULL == h_ota) {
            CM_ERR(cm_log_error_fail);
            return NULL;
        }
    } else {
        CM_WARNING(cm_log_warning_cloud_disconnected);
        return NULL;
    }

    cm_ctx->ota_handler = h_ota;

    if (0 != IOT_OTA_ReportVersion(h_ota, version)) {
        CM_ERR(cm_log_error_fail);
        IOT_OTA_Deinit(h_ota);
        return NULL;
    }

    iotx_ota_set_fetch_callback(h_ota, _fota_fetch, cm_ctx);
    iotx_ota_set_cota_fetch_callback(h_ota, _cota_fetch, cm_ctx);

    return h_ota;
}
Esempio n. 19
0
void CMHttpS::SetRemote(const CMUrl& rUrl)
{
    m_remote = rUrl;
    CMString& sUrl =m_remote.Url();
    //只保留主机和端口
    sUrl.Format(L"http://%s:%d", (const WCHAR*)rUrl.Host(), rUrl.Port());
    if (!m_remote.Parse())
    {
        CM_ERR("CMHttpS::SetRemote failed");
    }
}
int register_com_wunding_mlplayer_business_CMQuestionUpload(JNIEnv* env) {
    static JNINativeMethod CMQuestionUploadMethods[] = {
        { "nativeConstructor", "(Ljava/lang/Object;)V", (void*)CMQuestionUpload_nativeConstructor},
        { "nativeDestructor", "()V", (void*)CMQuestionUpload_nativeDestructor },
        { "nativeSetListener", "(Ljava/lang/Object;)V", (void*)CMQuestionUpload_SetListener },
        { "AskQuestion", "(Ljava/lang/String;IILjava/lang/String;Ljava/lang/String;)Z", (void*)CMQuestionUpload_AskQuestion },
        { "AnswerQuestion", "(Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)Z", (void*)CMQuestionUpload_AnswerQuestion },
        { "UpheadPhtho", "(Ljava/lang/String;)Z", (void*)CMQuestionUpload_UpheadPhtho }
    };


    jclass clazz = env->FindClass("com/wunding/mlplayer/business/CMQuestionUpload");
    if (clazz == 0) {
        CM_ERR("class CMQuestionUpload no found");
        return -1;
    }

    gCMQuestionUploadFieldID.nativeJavaObj = env->GetFieldID(clazz, "mNativeObj", "I");
    if (gCMQuestionUploadFieldID.nativeJavaObj == 0) {
        CM_ERR("CMQuestionUpload no found mNativeObj");
        return -1;
    }

    gCMQuestionUploadFieldID.jniData = env->GetFieldID(clazz, "mJniData", "I");
    if (gCMQuestionUploadFieldID.jniData == 0) {
        CM_ERR("CMQuestionUpload no found mJniData");
        return -1;
    }

    // Get the postEvent method
    gCMQuestionUploadFieldID.callback = env->GetStaticMethodID(
            clazz, "callback", "(Ljava/lang/Object;III)V");
    if (gCMQuestionUploadFieldID.callback == NULL) {
        CM_ERR("CMQuestionUpload no found callback");
        return -1;
    }

    return env->RegisterNatives(clazz,
            CMQuestionUploadMethods,
            sizeof(CMQuestionUploadMethods) / sizeof(CMQuestionUploadMethods[0]));
}
int register_com_wunding_mlplayer_business_CMSpecialTopic(JNIEnv* env) {
    static JNINativeMethod CMSpecialTopicMethods[] = {
        { "nativeConstructor", "(Ljava/lang/Object;)V", (void*)CMSpecialTopic_nativeConstructor},
        { "nativeDestructor", "()V", (void*)CMSpecialTopic_nativeDestructor },
        { "GetSpecialTopic", "(Ljava/lang/String;)V", (void*)CMSpecialTopic_GetSpecialTopic },
        { "GetTitle", "()Ljava/lang/String;", (void*)CMSpecialTopic_GetTitle },
        { "GetImage", "()Ljava/lang/String;", (void*)CMSpecialTopic_GetImage }
    };


    jclass clazz = env->FindClass("com/wunding/mlplayer/business/CMSpecialTopic");
    if (clazz == 0) {
        CM_ERR("class CMSpecialTopic no found");
        return -1;
    }

    gCMSpecialTopicFieldID.nativeJavaObj = env->GetFieldID(clazz, "mNativeObj", "I");
    if (gCMSpecialTopicFieldID.nativeJavaObj == 0) {
        CM_ERR("CMSpecialTopic no found mNativeObj");
        return -1;
    }

    gCMSpecialTopicFieldID.jniData = env->GetFieldID(clazz, "mJniData", "I");
    if (gCMSpecialTopicFieldID.jniData == 0) {
        CM_ERR("CMSpecialTopic no found mJniData");
        return -1;
    }

    // Get the postEvent method
    gCMSpecialTopicFieldID.callback = env->GetStaticMethodID(
            clazz, "callback", "(Ljava/lang/Object;III)V");
    if (gCMSpecialTopicFieldID.callback == NULL) {
        CM_ERR("CMSpecialTopic no found callback");
        return -1;
    }

    return env->RegisterNatives(clazz,
            CMSpecialTopicMethods,
            sizeof(CMSpecialTopicMethods) / sizeof(CMSpecialTopicMethods[0]));
}
int register_com_wunding_mlplayer_business_TRepalymentItem(JNIEnv* env) {
    static JNINativeMethod TRepalymentItemMethods[] = {
        { "nativeConstructor", "()V", (void*)TRepalymentItem_nativeConstructor},
        { "nativeDestructor", "()V", (void*)TRepalymentItem_nativeDestructor },
        { "GetUsername", "()Ljava/lang/String;", (void*)TRepalymentItem_GetUsername },
        { "SetUsername", "(Ljava/lang/String;)Z", (void*)TRepalymentItem_SetUsername },
        { "GetFullName", "()Ljava/lang/String;", (void*)TRepalymentItem_GetFullName },
        { "SetFullName", "(Ljava/lang/String;)Z", (void*)TRepalymentItem_SetFullName },
        { "GetHeadImage", "()Ljava/lang/String;", (void*)TRepalymentItem_GetHeadImage },
        { "SetHeadImage", "(Ljava/lang/String;)Z", (void*)TRepalymentItem_SetHeadImage },
        { "GetDepartment", "()Ljava/lang/String;", (void*)TRepalymentItem_GetDepartment },
        { "SetDepartment", "(Ljava/lang/String;)Z", (void*)TRepalymentItem_SetDepartment },
        { "GetDatetime", "()Ljava/lang/String;", (void*)TRepalymentItem_GetDatetime },
        { "SetDatetime", "(Ljava/lang/String;)Z", (void*)TRepalymentItem_SetDatetime },
        { "GetComment", "()Ljava/lang/String;", (void*)TRepalymentItem_GetComment },
        { "SetComment", "(Ljava/lang/String;)Z", (void*)TRepalymentItem_SetComment },
        { "GetID", "()Ljava/lang/String;", (void*)TRepalymentItem_GetID },
        { "SetID", "(Ljava/lang/String;)Z", (void*)TRepalymentItem_SetID },
        { "Getreply", "()I", (void*)TRepalymentItem_Getreply },
        { "Setreply", "(I)Z", (void*)TRepalymentItem_Setreply }
    };


    jclass clazz = env->FindClass("com/wunding/mlplayer/business/TRepalymentItem");
    if (clazz == 0) {
        CM_ERR("class TRepalymentItem no found");
        return -1;
    }

    gTRepalymentItemFieldID.nativeJavaObj = env->GetFieldID(clazz, "mNativeObj", "I");
    if (gTRepalymentItemFieldID.nativeJavaObj == 0) {
        CM_ERR("TRepalymentItem no found mNativeObj");
        return -1;
    }

    return env->RegisterNatives(clazz,
            TRepalymentItemMethods,
            sizeof(TRepalymentItemMethods) / sizeof(TRepalymentItemMethods[0]));
}
Esempio n. 23
0
static jobject CMCategoryItem_GetEnablesubscriptionChildItem(JNIEnv* env, jobject thiz, jint nIndex)
{
    CMCategoryItem* pObj = (CMCategoryItem*)env->GetIntField(thiz, gCMCategoryItemFieldID.nativeJavaObj);

    CMCategoryItem* pRet = pObj->GetEnablesubscriptionChildItem(nIndex);
    if (pRet == NULL) return NULL;

    jclass retClazz = env->FindClass("com/wunding/mlplayer/business/CMCategoryItem");
    if (retClazz == NULL) {
        CM_ERR("Can't find class CMCategoryItem");
        return NULL;
    }

    jmethodID retConstructor = env->GetMethodID(retClazz, "<init>", "(I)V");
    if (retConstructor == NULL) {
        CM_ERR("Can't find class CMCategoryItem native constructor");
        return NULL;
    }

    return env->NewObject(retClazz,
            retConstructor, (int)pRet);
}
Esempio n. 24
0
File: cmnv.c Progetto: bgtwoigu/1110
/*===========================================================================

FUNCTION cmnv_q_write_done_cb

DESCRIPTION
  Callback function for completion of NV write operations

DEPENDENCIES
  CM NV queue must have already been initialized with
  cmnv_q_init().

RETURN VALUE
  none

SIDE EFFECTS
  Dequeue item from the CM NV queue.

===========================================================================*/
void cmnv_q_write_done_cb( void )
{

  cmnv_item_s_type  nv_item;
      /* Container to hold dequeued NV item */

  /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /* Queue should NOT be empty!.
  */
  //CM_ASSERT( cmnv_q_cnt() > 0 );

  /* Dequeue item from head of CM NV queue into the
  ** nv_item buffer. If queue is empty log an error and return.
  */
  if( ! cmnv_q_get(&nv_item) ) {
    CM_ERR( "cmnv_q is empty!",0,0,0 );
    return;
  }

  /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /* If status is other than NV_DONE_S,
  ** NV write failed!
  */
  if( cmnv_cmd_async.status != NV_DONE_S )
  {
    CM_ERR( "NV write failed, item=%d, stat=%d",
            nv_item.item, cmnv_cmd_async.status, 0 );
  }

  /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /* Service the next item (if any).
  */
  cmnv_q_srv();

}
Esempio n. 25
0
int iotx_cm_cloud_conn_response_handler(iotx_cm_conntext_t* cm_ctx, iotx_cm_message_info_t* message_info)
{
    if (NULL == cm_ctx || NULL == message_info) {
        CM_ERR(cm_log_error_parameter);
        return FAIL_RETURN;
    }

    CM_INFO(cm_log_info_URI, (char*)message_info->URI);

    if (cm_ctx->response_func)
        cm_ctx->response_func(cm_ctx, message_info);

    return SUCCESS_RETURN;
}
Esempio n. 26
0
File: cmnv.c Progetto: bgtwoigu/1110
/*===========================================================================

FUNCTION cmnv_write

DESCRIPTION
  Write an item to NV memory.

  Note that NV writes are done in asynchronous fashion; that is, upon
  return of this function the write request is only being queued in the
  CM NV queue. The CM NV queue then services the request in the background.

DEPENDENCIES
  CM NV queue must have already been initialized with
  cmnv_q_init().

RETURN VALUE
  none

SIDE EFFECTS
  none

===========================================================================*/
void cmnv_write(

    nv_items_enum_type    nv_item,
        /* NV item to write */

    const nv_item_type    *data_ptr
        /* pointer to data associated with the NV item */
)
{
  cmnv_item_s_type  cmnv_item;
      /* Container to hold NV item to be enqueued */

  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

  CM_ASSERT(data_ptr != NULL); 

  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

  /* Prepare item for enqueuing.
  */
  cmnv_item.item    = nv_item;
  cmnv_item.data    = *((cmnv_data_s_type*) data_ptr);

  /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /* Try enqueuing item onto the CM NV write queue.
  */
  if( cmnv_q_put(&cmnv_item) )
  {
    CM_MSG_LOW( "cmnv_write(), nv_q_cnt=%d",cmnv_q_cnt(),0,0 );

    /* Enqueuing is successful - if queue was previously
    ** empty, start servicing the queue now.
    */
    if( cmnv_q_cnt() == 1 )
    {
      cmnv_q_srv();
    }
  }
  else
  {
    /* Queue is full!
    */
    CM_ERR( "NV write Q is full, nv_item=%d",cmnv_item.item,0,0 );
  }

}
Esempio n. 27
0
static void CMShake_nativeConstructor(JNIEnv* env, jobject thiz, jobject weak_this)
{
    jclass clazz = env->GetObjectClass(thiz);
    if (clazz == NULL) {
        CM_ERR("Can't find CMShake when setting up callback.");
        return;
    }
    callback_cookie_CMShake* pCookie = new callback_cookie_CMShake;
    pCookie->listener1 = new CMUpdateDataListener(gCMShakeFieldID.callback);
    pCookie->info_class = (jclass)env->NewGlobalRef(clazz);
    pCookie->ref = env->NewGlobalRef(weak_this);
    env->SetIntField(thiz, gCMShakeFieldID.jniData, (int)pCookie);

    CMShake* pObj = new CMShake(pCookie->listener1);
    pObj->SetUserData(pCookie);
    env->SetIntField(thiz, gCMShakeFieldID.nativeJavaObj, (int)pObj);
}
static void CMQuestionUpload_nativeConstructor(JNIEnv* env, jobject thiz, jobject weak_this)
{
    jclass clazz = env->GetObjectClass(thiz);
    if (clazz == NULL) {
        CM_ERR("Can't find CMQuestionUpload when setting up callback.");
        return;
    }
    callback_cookie_CMQuestionUpload* pCookie = new callback_cookie_CMQuestionUpload;
    pCookie->listener1 = new CMSimpleResultListener(gCMQuestionUploadFieldID.callback);
    pCookie->info_class = (jclass)env->NewGlobalRef(clazz);
    pCookie->ref = env->NewGlobalRef(weak_this);
    env->SetIntField(thiz, gCMQuestionUploadFieldID.jniData, (int)pCookie);

    CMQuestionUpload* pObj = CMQuestionUpload::GetInstance();
    pObj->SetListener(pCookie->listener1);
    pObj->SetUserData(pCookie);
    env->SetIntField(thiz, gCMQuestionUploadFieldID.nativeJavaObj, (int)pObj);
}
static void TTrainSignInItem_nativeConstructor(JNIEnv* env, jobject thiz, jobject weak_this)
{
    jclass clazz = env->GetObjectClass(thiz);
    if (clazz == NULL) {
        CM_ERR("Can't find TTrainSignInItem when setting up callback.");
        return;
    }
    callback_cookie_TTrainSignInItem* pCookie = new callback_cookie_TTrainSignInItem;
    pCookie->listener1 = new CMUpdateDataListener(gTTrainSignInItemFieldID.callback);
    pCookie->listener2 = new CMSimpleResultListener(gTTrainSignInItemFieldID.callback);
    pCookie->info_class = (jclass)env->NewGlobalRef(clazz);
    pCookie->ref = env->NewGlobalRef(weak_this);
    env->SetIntField(thiz, gTTrainSignInItemFieldID.jniData, (int)pCookie);

    TTrainSignInItem* pObj = new TTrainSignInItem();
    pObj->SetUserData(pCookie);
    env->SetIntField(thiz, gTTrainSignInItemFieldID.nativeJavaObj, (int)pObj);
}
Esempio n. 30
0
int iotx_local_conn_alcs_send(void* handle,
                              void* _context,
                              iotx_connection_msg_t* message)
{
    int ret = FAIL_RETURN;
    iotx_connection_t* connection = (iotx_connection_t*)handle;
    iotx_alcs_transfer_msg_context_t* context = (iotx_alcs_transfer_msg_context_t*)_context;
    iotx_alcs_msg_t alcs_msg;

    if (NULL == message) {
        CM_ERR(cm_log_error_parameter);
        return FAIL_RETURN;
    }

    memset(&alcs_msg, 0x0, sizeof(iotx_alcs_msg_t));

    alcs_msg.group_id = 0;  // TODO

    alcs_msg.ip = context ? context->ip : NULL;
    alcs_msg.port = context ? context->port : 0;
    alcs_msg.msg_code = (context && context->token_len && context->token) ? ITOX_ALCS_COAP_MSG_CODE_205_CONTENT : ITOX_ALCS_COAP_MSG_CODE_GET;
    alcs_msg.msg_type = IOTX_ALCS_MESSAGE_TYPE_CON;
    alcs_msg.uri = message->URI;
    alcs_msg.payload = message->payload;
    alcs_msg.payload_len = message->payload_length;

    // there is no target call IOT_ALCS_Observe_Notify
    // there is target call IOT_ALCS_Send
    // there is context call IOT_ALCS_Send_Response
    if (NULL == context) {
        ret = IOT_ALCS_Observe_Notify(connection->context, alcs_msg.uri, alcs_msg.payload_len, alcs_msg.payload);
    } else if (context->ip && context->port && NULL == context->token) {
        ret = IOT_ALCS_Send(connection->context, &alcs_msg);
    } else if (context->ip && context->port && context->token_len && context->token) {
        ret = IOT_ALCS_Send_Response(connection->context, &alcs_msg, (uint8_t)context->token_len, (uint8_t*)context->token);
    }

    if (context && context->ip) LITE_free(context->ip);
    if (context && context->token) LITE_free(context->token);
    if (context)  LITE_free(context);

    return ret;
}