#include "stddef.h" #include "stdarg.h" #include "cos.h" #include "cswtype.h" #include "fs_type.h" #include "tm.h" #include "mmi_trace.h" #include "sxr_mem.h" #include "cfw.h" #include "sockets.h" #include "soc_api.h" #include "tcpip_tcp.h" #include "mmi_msg_struct.h" #include "internal.h" #include "javadef.h" #include "dual_sim.h" #include "settingprofile.h" #include "java.h" #ifdef __GPRS_MODE__ #include "dataaccountgprot.h" #include "dataaccount.h" #include "dataaccountenum.h" #include "dataaccountdef.h" #include "dataaccountstruct.h" #endif typedef struct sockt_t { char socketId; unsigned char taskId; unsigned char thisReadSem; unsigned char isWaitForGprs; unsigned char isPerpareForRead; struct sockt_t *next; }_SOCKET_T; _SOCKET_T socketHead; _GCJ_MUTEX_T netMutex; unsigned char socketReadSemaphore; //unsigned char gprsStateSemaphore; unsigned char gcj_IsGprsActived=0; unsigned char gcj_socke_count=0; void gcj_net_reset() { //if (gcj_StubIsForceToQuit() || !gcj_IsJavaOn()) gcj_StopGprs(); //else // gcjEventAPI_StopGprs(); _SOCKET_T *thisH = socketHead.next; while (thisH) { _SOCKET_T *tmp = thisH->next; CFW_SetTCPIPCallBackEx (NULL,thisH->socketId); free (thisH); thisH = tmp; } memset(&socketHead,0,sizeof(socketHead)); gcj_IsGprsActived = 0; gcj_socke_count = 0; } void gcj_StubPlatformRequest(unsigned short *url) { #ifdef JATAAYU_SUPPORT unsigned char urlstring [200]; UnicodeToAnsii(urlstring,url); gcj_TraceOut(0,"gcj_StubPlatformRequest URL :%s",urlstring); unsigned short *urldata = OslMalloc(mmi_ucs2strlen(url)*sizeof(unsigned short)+2) ; if (!urldata) abort(); UCS2Strncpy(urldata, url, mmi_ucs2strlen(url)); COS_EVENT evt; evt.nEventId = (unsigned int)MSG_ID_MMI_JAVA_RUN_WAP_REQ; evt.nParam1 = urldata; gcj_StubSendEvent(&evt,MOD_MMI); // gcj_media_semId = gcj_StubNewSemphone(); // gcj_StubTakeSemphone(gcj_media_semId); // gcj_SoundEnd = 1; #else #endif } void gcj_GprsCallback(void *info) { mmi_ps_gprs_connect_status_ind_struct *pGprsConnetStatus = (mmi_ps_gprs_connect_status_ind_struct*)info; if (pGprsConnetStatus->status != 0) { gcj_IsGprsActived =0; DisplayPopup((PU8)GetString(STR_GLOBAL_SOC_ERROR), IMG_GLOBAL_WARNING, 1, UI_POPUP_NOTIFYDURATION_TIME, (U8) WARNING_TONE); gcj_PrepareNetwork(); return; } else gcj_IsGprsActived=1; gcj_StubTakeMutex(&netMutex); _SOCKET_T *thisH = socketHead.next; while (thisH) { if (thisH->isWaitForGprs) { //gcj_StubReleaseSemphone(thisH->thisReadSem); gcj_StubCondNotify(thisH->thisReadSem); thisH->isWaitForGprs = 0; } thisH = thisH->next; } gcj_StubReleaseMutex(&netMutex); gcj_TraceOut(0,"j2me: file %s,function %s\n,gcj_IsGprsActived=%d",__FILE__,__FUNCTION__,gcj_IsGprsActived); } unsigned char gcj_PrepareNetworkError=0; #ifdef __MMI_GPRS_FEATURES__ extern GPRSDataAccountNode g_GPRS_DataAccount[]; #endif /* __MMI_GPRS_FEATURES__ */ int gcj_PrepareNetwork() { int ret=-1; uint32 whichSim=0; static int fistin=1; U8 APN[MAX_GPRS_MMI_APN_LEN + 1]; #ifdef __MMI_MULTI_SIM__ SetProtocolEventHandler(gcj_GprsCallback,MSG_ID_MMI_NW_GPRS_CONNECTED_RSP); // SetProtocolEventHandler(WEPTrueExit,MSG_ID_MMI_NW_GPRS_DECONNECTED_RSP); SetSlaveProtocolEventHandler(gcj_GprsCallback,MSG_ID_MMI_NW_GPRS_CONNECTED_RSP); // SetSlaveProtocolEventHandler(WEPTrueExit,MSG_ID_MMI_NW_GPRS_DECONNECTED_RSP); whichSim = g_mmi_java_sim_id ; #else SetProtocolEventHandler(gcj_GprsCallback,MSG_ID_MMI_NW_GPRS_CONNECTED_RSP); whichSim = 0; #endif memset(APN, 0x00, sizeof(APN)); UnicodeToAnsii(APN, g_GPRS_DataAccount[g_mmi_java_wap_prof_id].APN); gcj_TraceOut(0,"j2me: gcj_PrepareNetwork whichSim=%d APN = %s",whichSim, APN); ret = adp_PrepareGPRS(whichSim , strlen(APN) , ( char *)APN); gcj_TraceOut(0,"j2me: task=%d,file %s,function %s,ret=0x%x",sxr_GetCurrentTaskId(),__FILE__,__FUNCTION__,ret); if(ret != 0) { //gcj_StubNetAlert(); } return ret; }
/***************************************************************************** * FUNCTION * InitHardwareEvents * DESCRIPTION * Initialize the ProtocolEvents * PARAMETERS * void * RETURNS * void *****************************************************************************/ void InitHardwareEvents(void) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ SetProtocolEventHandler(mmi_frm_key_handle, MSG_ID_MMI_EQ_KEYPAD_DETECT_IND); #ifdef __MMI_DUAL_SIM__ SetSlaveProtocolEventHandler(mmi_frm_key_handle, MSG_ID_MMI_EQ_KEYPAD_DETECT_IND); #endif /* __MMI_DUAL_SIM__ */ SetProtocolEventHandler(L4SetClockRSP, MSG_ID_MMI_EQ_SET_RTC_TIME_RSP); SetProtocolEventHandler(L4GetClockTimeRSP, MSG_ID_MMI_EQ_GET_RTC_TIME_RSP); SetProtocolEventHandler(DateTimerIndication, MSG_ID_MMI_EQ_CLOCK_TICK_IND); SetProtocolEventHandler(GpioDetectInd, MSG_ID_MMI_EQ_GPIO_DETECT_IND); SetProtocolEventHandler(GpioCtrlReqHdlr, MSG_ID_MMIAPI_DEVICE_GET_CTRL_REQ); SetProtocolEventHandler(GpioPlayReqHdlr, MSG_ID_MMIAPI_DEVICE_PLAY_REQ); #ifdef __MMI_USB_SUPPORT__ SetProtocolEventHandler(UsbDetectIndHdlr, MSG_ID_MMI_EQ_USBDETECT_IND); #endif /* GPIO device Detect indication event handler */ SetProtocolEventHandler(GpioDetectInd, PRT_EQ_GPIO_DETECT_IND); #ifdef __MMI_USB_SUPPORT__ SetProtocolEventHandler(UsbDetectIndHdlr, PRT_EQ_USB_DETECT_IND); #endif /* volume change indication from L4 */ /* SetProtocolEventHandler( VolumeChangeIndication, MSG_ID_MMI_EQ_VOLUME_CHANGE_IND); */ #ifdef __MMI_IRDA_SUPPORT__ mmi_irda_init_protocol_event(); #endif SetProtocolEventHandler((PsFuncPtr)mmi_gpio_backlight_ctrl_req_hdlr, MSG_ID_MMIAPI_BACKLIGHT_CONTROL_REQ); SetProtocolEventHandler((PsFuncPtr)mmi_gpio_led_ctrl_req_hdlr, MSG_ID_MMIAPI_LED_CONTROL_REQ); #ifdef __MMI_TVOUT__ /* init tvout - to re-register message handler */ mmi_phnset_init_tvout(); #endif /* __MMI_TVOUT__ */ SetProtocolEventHandler(mmi_get_battery_level_req_hdlr, MSG_ID_MMIAPI_GET_BATTERY_LEVEL_REQ); SetProtocolEventHandler(mmi_battery_level_notify_start_req_hdlr, MSG_ID_MMIAPI_BATTERY_LEVEL_NOTIFY_START_REQ); SetProtocolEventHandler(mmi_battery_level_notify_stop_req_hdlr, MSG_ID_MMIAPI_BATTERY_LEVEL_NOTIFY_STOP_REQ); }