📄 jpush_general.c
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2001
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* jam_push.c
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
*
* Author:
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
/*************************************************************************
* Include Statements
*************************************************************************/
#include <stdlib.h> /* for atoll */
#include "jal.h"
#include "jvm_internal.h"
#include "stack_common.h"
#include "stack_msgs.h"
#include "app_ltlcom.h" /* Task message communiction */
#include "tst_ltlcom.h"
#include "syscomp_config.h"
#include "task_config.h" /* Task creation */
#include "stacklib.h" /* Basic type for dll, evshed, stacktimer */
#include "event_shed.h" /* Event scheduler */
#include "app_buff_alloc.h"
#include "jpush_interface.h"
#include "jwa_internal.h"
#include "jam_interface.h"
#include "jam_msg_handler.h"
#include "jam_internal.h"
#include "l4c_common_enum.h"
#include "l4a.h"
#define MMIAPI_USING_SMS
#include "mmiapi_struct.h"
/*************************************************************************
* Global Definition
*************************************************************************/
#define EUREKA_SMSQUEUE_FILE ("eureka_queuefile.txt")
#define EUREKA_SMSQUEUETMP_FILE ("eureka_queuefile_tmp.txt")
#define PPUSH_FILE ("ppush.txt")
#define PUSHPATH_NAME "pushlist.txt"
#define ALARMPATH_NAME "alarmlist.txt"
/*
* Active push list - all game_type's active pushes are on the list, but possible
* * save to different _pushlist.txt.
*/
pushentry_struct *g_jpush_pushlist_ptr = NULL;
static kal_bool g_jpush_push_enabled = 1;
kal_int32 g_push_length = 0;
static char _push_path[MAX_WCHAR_FILENAME_LEN];
extern mmi_java_timealarm_push_ind_struct timealarm_push_ind_msg[];
extern kal_bool timealarm_push_ind_msg_used[];
static kal_bool before_persistent_push_finished = KAL_FALSE;
extern jam_call_back_function_struct jam_call_back_functions;
int pushlist_len = 0;
/*************************************************************************
* Global Declaration
*************************************************************************/
extern alarmentry_struct *g_jpush_alarmlist_ptr;
extern kal_int32 g_timealarm_count;
extern void J2ME_mms_register(char *application_id, int op, int type);
extern int _jwa_sms_receive_binary_msg_req(long port);
extern int _jwa_sms_receive_text_msg_req(long port);
extern unsigned short *_jwa_sms_get_incoming_msg_addr(long portNumber, int *len);
extern kal_bool jwa_sms_get_ori_timestamp(long portNumber, kal_uint8 *time);
extern int _jwa_sms_check_incoming_msg(long portNumber, kal_bool only_new);
extern void java_mmi_timealarm_push_ind_handler(
game_type_enum game_type,
kal_uint32 type,
void *callback_entry,
kal_char *mid_name,
kal_char *mid_storagename);
/*************************************************************************
* Function Definition
*************************************************************************/
/*****************************************************************************
* FUNCTION
* jpush_push_enable
* DESCRIPTION
*
* PARAMETERS
* enable [IN]
* RETURNS
* void
*****************************************************************************/
void jpush_push_enable(kal_bool enable)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
g_jpush_push_enabled = enable;
}
/*****************************************************************************
* FUNCTION
* jpush_push_open
* DESCRIPTION
* Current implementation save different game_typ's pushlist at private
* folder, however, g_jpush_pushlist_ptr maintains all active push.
*
* Open the push Registry file, if it exists and populate
* an in memory cache of the file contents.
* PARAMETERS
* game_type [IN]
* push_path [?]
* RETURNS
* void
*****************************************************************************/
int jpush_push_open(game_type_enum game_type, char *push_path)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_int32 result = 0;
kal_int32 pushfd;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
work_info_ptr = _jvm_get_builtin_file_info(game_type);
work_sys_dir_path = _jvm_get_dir_path(game_type);
memcpy(_push_path, push_path, strlen(push_path) + 1);
sprintf(_kvmLogStr, "pe->jpush_push_open: game_type=%d, push_path = %s\n", game_type, push_path);
Kprintf();
#if !PERSISTENT_PUSH
/* Force to clean all registered push after re-boot */
if ((pushfd = jvm_file_open(push_path, O_CREAT | O_TRUNC)) == -1)
{
result = (-1);
}
#else /* !PERSISTENT_PUSH */
/* Now read the registered connections. */
if ((pushfd = jvm_file_open(push_path, O_RDONLY)) != -1)
{
/* Read through the file one line at a time */
if (jpush_push_parse(pushfd) == -2)
{
result = (-1);
}
}
else if ((pushfd = jvm_file_open(push_path, O_CREAT | O_TRUNC)) == -1)
{
result = (-1);
}
#endif /* !PERSISTENT_PUSH */
if (pushfd > 0)
{
jvm_file_close(pushfd);
}
return result;
}
/*****************************************************************************
* FUNCTION
* jpush_push_save
* DESCRIPTION
* Save the in memory cache of push registrations to a persistent
* file for use in subsequent runs.
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
int jpush_push_save()
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
pushentry_struct *p;
kal_int32 pushfd;
kal_char tmp_buf[4];
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if ((pushfd = jvm_file_open(_push_path, O_CREAT | O_TRUNC)) != -1)
{
/* Write a new list of push registrations to the persistent file */
for (p = g_jpush_pushlist_ptr; p != NULL; p = p->next)
{
jvm_file_write(pushfd, p->connection, strlen(p->connection));
jvm_file_write(pushfd, ",", 1);
jvm_file_write(pushfd, p->midlet, strlen(p->midlet));
jvm_file_write(pushfd, ",", 1);
jvm_file_write(pushfd, p->filter, strlen(p->filter));
jvm_file_write(pushfd, ",", 1);
jvm_file_write(pushfd, p->storagename, strlen(p->storagename));
jvm_file_write(pushfd, ",", 1);
tmp_buf[0] = (p->portNo & 0xff000000) >> 24;
tmp_buf[1] = (p->portNo & 0x00ff0000) >> 16;
tmp_buf[2] = (p->portNo & 0x0000ff00) >> 8;
tmp_buf[3] = p->portNo & 0x000000ff;
jvm_file_write(pushfd, tmp_buf, 4);
jvm_file_write(pushfd, ",", 1);
if (p->appid != NULL)
{
jvm_file_write(pushfd, p->appid, strlen(p->appid));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -