Beispiel #1
0
boolean LGPRSClass::gprsCheckSIM(void *userData)
{
	LGPRSClass *pThis =(LGPRSClass*)userData; 
	vm_log_info("Has SIM? %d", vm_has_sim_card());
	vm_log_info("SIM count? %d", vm_sim_card_count());
	vm_log_info("IMEI=%s", vm_get_imei());

	// Is there SIM card ready?
	VMINT simCardCount = vm_sim_card_count();
	if (simCardCount > 0)
	{
		pThis->m_simCardReady = 1;
	}

	vm_set_active_sim_card(VM_SIM_SIM1);

	VMINT simStatus = vm_get_sim_card_status(VM_SIM_SIM1);
	vm_log_info("SIM card state=%d", simStatus);


	// Let's enable GPRS
	VMINT32 result = vm_setting_srv_command(VM_SETTING_CELLULAR_GPRS_SERVICE, 
											VM_OPERATION_GPRS_SERVICE_ON, 
											NULL, 
											NULL, 
											NULL,
											NULL);
	if (result == VM_SETTING_RESULT_OK)
	{
	   vm_log_info("vm_setting_srv_command OK");
	}
	else if (result == VM_SETTING_RESULT_INVALID)
	{
		vm_log_info("vm_setting_srv_command INVALID");
	}
	else
	{
		vm_log_info("vm_setting_srv_command failed.");
	}
	
	// Is there GSM?
	VMINT protocol = vm_srv_nw_info_get_protocol(VM_SIM_SIM1);
	vm_log_info("SIM protocol=%d", protocol);

	// get APN info
	vm_apn_info_ext apnInfo;
	VMINT apnRet = vm_get_apn_info(&apnInfo);
	vm_log_info("vm_get_apn_info = %d", apnRet);
	vm_log_info("operator ID= %s", apnInfo.operator_id);
	vm_log_info("operator Name= %s", apnInfo.operator_name);
	
	return true;
}
Beispiel #2
0
static void vm_preload_do_connection(vm_preload_ctx_t * ctx_p, VMINT n)
{

    vm_apn_info_ext info = {0};
    VMUINT dtacct_id;
    vm_get_encoded_dtacct_id(VM_TCP_APN_CMWAP, &dtacct_id);
    
    if (vm_wifi_is_connected())
    {
        ctx_p->soc_id = vm_tcp_connect(ctx_p->host, ctx_p->port, ctx_p->apn, _vm_preload_cb); 
        MMI_PRINT(MOD_MRE, MMI_MRE_TRC_MOD_VMSOCK,"preload cnt wifi1[%s, %d] npx[%d]", 
            ctx_p->host, ctx_p->port, n);
    }
    else
    {
        if (0 == vm_get_apn_info(&info)) // px
        {
            memset(&info, 0, sizeof(info));
            if (0 == vm_get_default_apn_info(&info))
            {
                if (info.apn_info_id)
                {
                    //ctx_p->apn = 2;
                    ctx_p->soc_id = vm_tcp_connect(info.proxy_ip, info.proxy_port, VM_TCP_APN_CMWAP, _vm_preload_cb);
                    MMI_PRINT(MOD_MRE, MMI_MRE_TRC_MOD_VMSOCK,"preload cnt [%s, %d] px[%d]", 
                        info.proxy_ip, info.proxy_port, n);
                }
                else
                {
                    ctx_p->soc_id = vm_tcp_connect(ctx_p->host, ctx_p->port, ctx_p->apn, _vm_preload_cb); 
                    MMI_PRINT(MOD_MRE, MMI_MRE_TRC_MOD_VMSOCK,"preload cnt [%s, %d] npx[%d]", 
                        info.proxy_ip, info.proxy_port, n);
                }
            }
            else // wifi without sim
            {
                ctx_p->soc_id = vm_tcp_connect(ctx_p->host, ctx_p->port, ctx_p->apn, _vm_preload_cb); 
                MMI_PRINT(MOD_MRE, MMI_MRE_TRC_MOD_VMSOCK,"preload cnt 1[%s, %d] npx[%d]", 
                    ctx_p->host, ctx_p->port, n);
            }
        }
        else // npx
        {
            ctx_p->soc_id = vm_tcp_connect(ctx_p->host, ctx_p->port, ctx_p->apn, _vm_preload_cb); 
            MMI_PRINT(MOD_MRE, MMI_MRE_TRC_MOD_VMSOCK,"preload cnt 2[%s, %d] npx[%d]", 
                ctx_p->host, ctx_p->port, n);
        }
    }

}
Beispiel #3
0
static void gprsSettingCallback(VMINT32 result, void *user_data)
{
	vm_log_info("gprsSettingCallback result=%d", result);
	
	// check SIM support
	VMINT protocol = vm_srv_nw_info_get_protocol(VM_SIM_SIM1);
	vm_log_info("SIM protocol=%d", protocol);

	// get APN info
	vm_apn_info_ext apnInfo;
	VMINT apnRet = vm_get_apn_info(&apnInfo);
	vm_log_info("vm_get_apn_info = %d", apnRet);
	vm_log_info("operator ID= %s", apnInfo.operator_id);
	vm_log_info("operator Name= %s", apnInfo.operator_name);	

	// release blocking signal
	LTask.post_signal();
}
Beispiel #4
0
VMINT vm_preload_download_ex(VMINT hdl, const VMWCHAR * data, VMBOOL bDLA,void (*callback)(VMINT hdl, void * para), void * user_data)
{
    VMCHAR http_header[BUFFER_LEN] = {0};
    VMINT ret = 0;
    VMINT written = 0;
    vm_preload_ctx_t * ctx_p = NULL;
    VMINT bufSize = 0;

    MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_2997 );			
    if (NULL == data || 0 > hdl)
    {
        MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_3000 );         
        return -2;
    }

    if (vm_res_get_data(VM_RES_TYPE_PRELOAD, 
        hdl, (void**)&ctx_p, &bufSize) != VM_RES_OK)
    {
        MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_3058 , -6);           
        return -6;
    }
    
    if (NULL == ctx_p)
    {
        MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_3009 );      
        return -3;
    }
    
    
    vm_wstrcpy(ctx_p->path, (const VMWSTR)data);
    ctx_p->cb = callback;
    ctx_p->user_data = user_data;
    ctx_p->bDLA = bDLA;
    if (!bDLA || g_no_dla)
    {
        ret = _vm_preload_try_download(ctx_p);
        if (ret <= 0)
            return ret;
    }
    else
    {
#if defined(MMI_DA_HTTP_DOWNLOAD_SUPPORT)   
        VMUINT account_id;
        srv_da_start_download_struct da_param;
        vm_apn_info_ext info = {0};
        
        memset(&da_param,0,sizeof(da_param));
        vm_get_encoded_dtacct_id(VM_TCP_APN_CMWAP, &account_id);
        MMI_PRINT(MOD_MRE, MMI_MRE_TRC_MOD_VMSOCK,"preload dla dt[0x%x]", 
            account_id);
        if (0 == vm_get_apn_info(&info)) // px
        {
            if (0 == vm_get_default_apn_info(&info))
            {
                if (info.apn_info_id)
                {
                    vm_get_encoded_dtacct_id(VM_TCP_APN_CMWAP, &account_id);
                    MMI_PRINT(MOD_MRE, MMI_MRE_TRC_MOD_VMSOCK,"preload dla px[0x%x]", 
                        account_id);
                }
                else
                {
                    vm_get_encoded_dtacct_id(VM_TCP_APN_CMNET, &account_id);
                    MMI_PRINT(MOD_MRE, MMI_MRE_TRC_MOD_VMSOCK,"preload dla npx[0x%x]", 
                        account_id);
                }
            }
            else // wifi without sim
            {
                
            }
        }
        srv_dtcnt_get_auto_acc_id(account_id, &da_param.acc_id);
        mmi_asc_n_to_ucs2((CHAR *)http_header,ctx_p->url,BUFFER_LEN);
        da_param.url = (WCHAR*)http_header;
        //da_param.acc_id = account_id;
        da_param.show_confirm = MMI_FALSE;
        da_param.user_data = ctx_p;
        da_param.filepath = (U16 *)data;
        da_param.dl_progress = vm_preload_download_callback;
        da_param.dispatch_callback = NULL;
        da_param.setting_hdlr = srv_da_default_setting;// MAUI_03202723 srv_da_bypass_setting -> srv_da_default_setting; //vm_preload_download_setting;
        if (NULL == srv_da_start_http_download(&da_param))
        {
            //_vm_preload_clean(ctx_p);
            _vm_preload_free_ctx(ctx_p);
            return -5;
        }
#endif        
    }
    
    MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_3058 , ret);			
    ctx_p->update = 2;
    MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_3060 );			
    return 0;
}
Beispiel #5
0
VMINT vm_preload_query(VMINT apn,
                       const VMCHAR * url, 
                       VMINT port,
                       const vm_preload_query_info_t * info,
                       void (*callback)(VMINT hdl, void * para), 
                       void * user_data)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/    
    VMCHAR http_host[128] = {0};
    vm_apn_info_ext apn_info;
    vm_common_t common = {E_PRELOAD_QUERYING, NULL};
    vm_preload_ctx_t * ctx_p = NULL;
    //srv_dtcnt_sim_type_enum sim_type;
    VMINT with_port = 0;
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_2884 );			

    if (NULL == url ||
        0 > port ||
        NULL == info ||
        NULL == info->ua ||
        NULL == callback)
//        NULL == user_data)
    {
        MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_2893 );            
        return -2;
    }


    if (VM_TCP_APN_CMNET == apn || 
    VM_TCP_APN_CMNET_ONLY == apn ||
    VM_TCP_APN_WIFI == apn &&
        apn != VM_APN_USER_DEFINE)
    {
        VMINT pos = 7; // http://
        for(; url[pos]; pos ++)
        {
            if (url[pos] == ':')
            {
                with_port = atoi(&url[pos] + 1);
                break;
            }
            if (url[pos] == '/')
                break;
        }
        strncpy(http_host, url + 7, pos - 7);
        MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_2907 , http_host);
    }
    else if (VM_TCP_APN_CMWAP == apn ||
    VM_TCP_APN_CMWAP_ONLY == apn)
    {
        VMUINT dtacct_id;
        vm_get_encoded_dtacct_id(VM_TCP_APN_CMWAP, &dtacct_id);
        if (0 == vm_get_apn_info(&apn_info) && !apn_info.apn_info_id)
        {
            VMINT pos = 7; // http://
            for(; url[pos]; pos ++)
            {
                if (url[pos] == ':')
                {
                    with_port = atoi(&url[pos] + 1);
                    break;
                }
                if (url[pos] == '/')
                    break;
            }
            strncpy(http_host, url + 7, pos - 7);
            MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_2923 , apn_info.proxy_ip);
        }
        else
        {
            with_port = apn_info.proxy_port;// atoi(&url[pos] + 1);
            strncpy(http_host, apn_info.proxy_ip, sizeof(apn_info.proxy_ip));
        }
        MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_2929 , http_host);
    }
    else
    {
        MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_2933 );            
        return -3;
    }

    ctx_p = _vm_preload_get_ctx(vm_pmng_get_current_handle(), info->app_id, 0);
    if (NULL == ctx_p)
    {
        ctx_p = _vm_preload_malloc_ctx();
        if (NULL == ctx_p)
        {
            MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_2943 );            
            return -4;
        }
    }
    /*
    else
    {
        if (1 == ctx_p->update)
        {
            vm_trace("vm_preload_query res not enough -5");            
            return -5;
        }
    }
    */
    ctx_p->p_hdl = vm_pmng_get_current_handle();
    ctx_p->app_id = info->app_id;
    ctx_p->user_data = user_data;
    ctx_p->cb = callback;
    strcpy(ctx_p->url, url);
    ctx_p->port = with_port ? with_port : port;
    strcpy(ctx_p->host, http_host);
    ctx_p->apn = apn;
    ctx_p->update = 0;
    memcpy(&(ctx_p->query_info), info, sizeof(vm_preload_query_info_t));
    ctx_p->twice_confirmed = 0;

    MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_2959 , ctx_p->host, ctx_p->port, apn);            
#ifdef WIN32
    //strcpy(ctx_p->host, "172.21.87.241");
#endif
    if (ctx_p->soc_id > 0)
    {
        MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_2965 );       
        vm_tcp_close(ctx_p->soc_id);
    }
    //srv_dtcnt_get_sim_preference(&sim_type);
    if ((stub_tcp_is_support_wifi() && VM_TCP_APN_WIFI == ctx_p->apn)
#ifdef __COSMOS_MMI_PACKAGE__      
      //  || (srv_mre_da_get_account_id(SRV_MRE_DA_WIFI_ONLY) == 1)
      //  || (sim_type == SRV_DTCNT_SIM_TYPE_NONE)
#endif
        )
    {
        if (SRV_DTCNT_WLAN_STATUS_INACTIVE == srv_dtcnt_wlan_status())
        {
            //MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_UDP_E3, 2, __LINE__);
            _vm_preload_free_ctx(ctx_p);
            return -6;
        }
    }

#if 1
    vm_preload_do_connection(ctx_p, 1);
#else
/* under construction !*/
#endif

    if (0 > ctx_p->soc_id)
    {
        MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_2973 );       
        _vm_preload_free_ctx(ctx_p);
        return -5;
    }
    
    common.user_data = ctx_p->user_data;
    common.state = E_PRELOAD_CONNECTING;
    PRELOAD_PMNG_WRAP_CALLBACK(ctx_p->p_hdl, 
        ctx_p->cb, ctx_p->res_id, (void*)&common);
        
    MMI_TRACE(MMI_MRE_TRC_MOD_VMSOCK, TRC_MRE_VMSOCK_2983 );			

    ctx_p->status = E_PRELOAD_DOWNLOADING;
    
    return ctx_p->res_id;
}