📄 jam_adaptation.c
字号:
int i = 10;
myError = NULL;
pass = KAL_FALSE;
for (pos = storage_len; deleteFile[pos] != 0; pos++)
{
if (deleteFile[pos]=='_')
{
pass = KAL_TRUE;
break;
}
}
if (!pass)
{
do
{
/* unable to delete the file cause the file system is busy */
storageDeleteFile(&myError, deleteFile);
kal_sleep_task(10);
i --;
}while (i > 0 && myError != NULL);
}
/*ASSERT(myError == NULL);*/
}
deleteFile = allFiles + scanPos + 1;
}
scanPos ++;
}
if (deleteFile[0] != 0)
{
int i = 10;
myError = NULL;
for (pos = storage_len; deleteFile[pos] != 0; pos++)
{
if (deleteFile[pos]=='_')
{
pass = KAL_TRUE;
break;
}
}
if (!pass)
{
do
{
/* unable to delete the file cause the file system is busy */
storageDeleteFile(&myError, deleteFile);
kal_sleep_task(10);
i --;
}while (i > 0 && myError != NULL);
}
}
work_dir_path = j2me_save_path;
}
void removd_midlet_by_storage_name(game_type_enum type, kal_char* storageName)
{
kal_char *JarFileName;
/* Delete the jar file of default game will cause error */
/* use it to check if the file is a default game */
JarFileName = (kal_char*)midpMalloc(strlen(storageName) + 1 + strlen("suite.jar"));
strcpy(JarFileName, storageName);
strcat(JarFileName, "suite.jar");
/* force removal. not care if it is a default game */
Kunlink(JarFileName);
midpFree(JarFileName);
#ifndef __SUPPORT_NATIVE_INSTALLER__
/* add delete notify URL to DeleteNotifyURLList */
deleteNotifyURLList(storageName);
kal_sleep_task(40);
#endif
/* delete the suite from suite.utf */
removeSuiteFromSUITEUTF(storageName);
kal_sleep_task(40);
/* delete the suite from MIDSLIST.save */
removeSuiteFromMIDSLIST(type, storageName);
kal_sleep_task(40);
/* deregister push entity if available */
jpush_push_deletesuite(storageName);
deletMIDletFile(storageName);
}
void
removeMIDlet(game_type_enum type, kal_int32 MIDSID, kal_char* storageName)
{
if (!jam_get_removal_confirm(type, MIDSID))
{
return;
}
commit_removal = KAL_TRUE;
removd_midlet_by_storage_name(type, storageName);
}
/* for get list */
/*************************************************************************
* FUNCTION
* jam_free_mids_listfile
*
* DESCRIPTION
* Internal free mids listfile information
*
* All structure node memory is allocated from system memory, and raw data
* is from midslist_mem_pool.
*
* PARAMETERS
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void
jam_free_mids_listfile(game_type_enum type)
{
mids_list_info_struct* mids_info_ptr;
mids_list_info_struct* mids_info_ptr_next;
mid_struct* mid_ptr;
mid_struct* mid_ptr_next;
if (saved_mids_listfile_ptr)
{
mids_info_ptr = saved_mids_listfile_ptr->mids_info_list;
while (mids_info_ptr)
{
mids_info_ptr_next = mids_info_ptr->mids_list_info_next;
mid_ptr = mids_info_ptr->mid_info.mid_list;
while (mid_ptr)
{
mid_ptr_next = mid_ptr->mid_next;
j2me_midslist_mem_free(mid_ptr);
mid_ptr = mid_ptr_next;
}
j2me_midslist_mem_free(mids_info_ptr->mids_info_rawdata);
j2me_midslist_mem_free(mids_info_ptr);
mids_info_ptr = mids_info_ptr_next;
}
j2me_midslist_mem_free(saved_mids_listfile_ptr);
saved_mids_listfile_ptr = NULL;
}
}
/*************************************************************************
* FUNCTION
* jam_trans_midlist_icondata
*
* DESCRIPTION
* Internal icon transformation routine
*
* PARAMETERS
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void
jam_trans_midlist_icondata(kal_uint8* icon, kal_int32 icon_len,
kal_int32 width, kal_int32 height)
{
kal_uint8* icon_data = icon + 5*sizeof(kal_int32);
kal_uint8* icon_mmi_fmt = icon;
kal_uint16 lcd_mmi_value;
kal_int32 pixel_size = icon_len/sizeof(kal_uint32);
kal_uint8* pixel;
kal_int32 i, total_icon_size;
kal_uint8 pixel_alpha, pixel_r, pixel_g, pixel_b;
/*
data[0] = 4 (image type: means IMAGE_TYPE_DEVICE_BITMAP)
data[1..5] (reserved.)
data[6]|(data[7]<<8)|(data[8]<<16)|(data[9]<<24) (image width)
data[10]|(data[11]<<8)|(data[12]<<16)|(data[13]<<24) (image height)
data[14] (reserved. this field is depth, but not used)
data[15]|(data[16]<<8)|(data[17]<<16)|(data[18]<<24) (row data length)
data[19.. 19+ raw_data_length-1] (raw data, the raw data format is LCD shadow buffer data format)
*/
total_icon_size = jui_set_device_bmp_header(pixel_size, width, height, (kal_char*)icon_mmi_fmt);
if (icon_len)
{
for (i=0; i<pixel_size; i++)
{
/* icon bug fixed by Justin */
pixel = (kal_uint8*)&icon_data[i << 2];
pixel_alpha = *pixel;
pixel_r = *(pixel+1);
pixel_g = *(pixel+2);
pixel_b = *(pixel+3);
if (pixel_alpha == 0xff)
lcd_mmi_value = j2me_custom_lcd_hw_format(pixel_r, pixel_g, pixel_b);
else
lcd_mmi_value = RGB_TRANSPARENT_COLOR_16;
icon_mmi_fmt[total_icon_size+2*i] = lcd_mmi_value & 0xff;
icon_mmi_fmt[total_icon_size+2*i + 1] = (lcd_mmi_value>>8) & 0xff;
}
}
}
/*************************************************************************
* FUNCTION
* jam_adp_parse_midslistfile
*
* DESCRIPTION
* Internal parse mids listfile information
*
* All structure node memory is allocated from system memory, and raw data
* is from midslist_mem_pool.
*
* PARAMETERS
* int list_start_indx - mids start index on list
* int list_count - mids count on list
* enum parselist_mode - parse list mode - full information mode,
and reduced mode(only total count)
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_int32
jam_adp_parse_midslistfile(game_type_enum type,
mids_listfile_struct** this_saved_mids_listfile_ptr,
kal_int32 list_start_indx,
kal_int32 list_count,
mids_parselist_mode_enum mode,
kal_int32 parsing_pass)
{
kal_int32 error_code = J2ME_NO_ERROR;
/* File operation */
kal_int32 handle;
kal_wchar* buffer;
kal_int32 bytes_read;
kal_wchar* ucs2str_ptr;
/* Internal operation pointer */
mids_list_info_struct* mids_info_ptr;
mids_list_info_struct** cur_mids_info_ptr;
mid_struct* mid_ptr;
mid_struct** cur_mid_ptr;
/* Temp variable */
kal_int32 i, j;
volatile kal_int32 temp;
kal_int32 mids_start_indx;
kal_int32 mids_list_count;
/* mids list file field */
kal_int32 mids_count = 0;// mids_index = 0;
kal_int32 mids_info_size = 0;
kal_int32 mid_count = 0;
kal_int32 mid_info_size = 0;
/* Free last saved mids list memory first */
jam_free_mids_listfile(type);
/* Open mids list file */
handle = Kopen(JAM_MIDS_LIST_FILE, O_RDONLY);
if (-1 == handle)
{
#ifdef MIDP_FILE_DEBUG
sprintf(_kvmLogStr,"mids_getlist_req_handler failed %s\n", JAM_MIDS_LIST_FILE);
Kputs(_kvmLogStr);
#endif /* MIDP_FILE_DEBUG */
error_code = J2ME_READ_MIDS_LIST_FIlE_FAILURE;
goto _error_return;
}
/* Read and parse mids list file content */
/* a. Read mids count */
bytes_read = Kread(handle, (void*)&temp, sizeof(kal_int32));
if (bytes_read != sizeof(kal_int32))
{
error_code = J2ME_READ_MIDS_LIST_FIlE_FAILURE;
goto _error_return_closefile;
}
mids_count = TRANS_INTVALUE(temp);
if (mids_count == 0)
{
(*this_saved_mids_listfile_ptr) = (mids_listfile_struct*)j2me_midslist_mem_malloc(sizeof(mids_listfile_struct));
if ((*this_saved_mids_listfile_ptr) == NULL)
{
error_code = J2ME_INSUFFICIENT_MEMORY;
jam_free_mids_listfile(type);
goto _mem_error_return_closefile;
}
(*this_saved_mids_listfile_ptr)->mids_count = 0;
/* Extend available information*/
(*this_saved_mids_listfile_ptr)->mids_avail_indx = 0;
(*this_saved_mids_listfile_ptr)->mids_avail_count = 0;
(*this_saved_mids_listfile_ptr)->mids_info_list = NULL;
Kclose(handle);
return J2ME_NO_ERROR;
}
/* Check parameter */
mids_start_indx = (list_start_indx>=0) ? ((list_start_indx<mids_count)?list_start_indx:(mids_count-1)) : 0;
mids_list_count = (list_count>=0) ?
((list_count<(mids_count-mids_start_indx))?list_count:(mids_count-mids_start_indx)) :
(mids_count-mids_start_indx);
if (mids_list_count == 0)
{
error_code = J2ME_INVALID_REQUEST;
goto _error_return_closefile;
}
/* a.1 Allocate internal listfile */
if (mids_count)
{
(*this_saved_mids_listfile_ptr) = (mids_listfile_struct*)j2me_midslist_mem_malloc(sizeof(mids_listfile_struct));
if ((*this_saved_mids_listfile_ptr) == NULL)
{
error_code = J2ME_INSUFFICIENT_MEMORY;
jam_free_mids_listfile(type);
goto _mem_error_return_closefile;
}
(*this_saved_mids_listfile_ptr)->mids_count = mids_count;
/* Extend available information*/
(*this_saved_mids_listfile_ptr)->mids_avail_indx = mids_start_indx;
(*this_saved_mids_listfile_ptr)->mids_avail_count = 0;
(*this_saved_mids_listfile_ptr)->mids_info_list = NULL;
cur_mids_info_ptr = &(*this_saved_mids_listfile_ptr)->mids_info_list;
}
#ifdef __J2ME_SUPPORT_INDEX_STORAGE_NAME__
/* Read mids index and skip it, the value wont be used here */
bytes_read = Kread(handle, (void*)&temp, sizeof(kal_int32));
#endif
for (i=0; i<mids_count; i++)
{
/* From assigned start index, and stop at assigned count */
if ((mode == MIDS_PARSELIST_FULL_MODE) &&
(i >= mids_start_indx + mids_list_count))
break;
/* b. Read mids info */
bytes_read = Kread(handle, (void*)&temp, sizeof(kal_int32));
if (bytes_read != sizeof(kal_int32))
{
/* break to parse list file */
break;
}
/* b.1 Read mids info size */
mids_info_size = TRANS_INTVALUE(temp);
if (mids_info_size)
{
kal_bool is_mid_icon_shrinked = KAL_FALSE;
/* Reduce mode, or full mode start from assigned index */
if ((mode == MIDS_PARSELIST_REDUCED_MODE) ||
((mode==MIDS_PARSELIST_FULL_MODE) && (i<mids_start_indx)))
{
/* Reduced mode, increment avail_count directly.*/
if ((mode == MIDS_PARSELIST_REDUCED_MODE) && (i>=mids_start_indx))
{
(*this_saved_mids_listfile_ptr)->mids_avail_count++;
}
Klseek(handle, mids_info_size, SEEK_CUR);
continue;
}
/* b.2 Allocate memory for internal mids info and mids info read buffer */
mids_info_ptr = (mids_list_info_struct*)j2me_midslist_mem_malloc(sizeof(mids_list_info_struct));
if ( parsing_pass == 0)
{
buffer = (kal_wchar*)j2me_midslist_mem_malloc(mids_info_size);
} else
{
/* second pass, memory is not enough, do not parse the MIDlet icon */
if (mids_info_size > 4 * 1024)
{
kal_int32 scan_off = 0;
is_mid_icon_shrinked = KAL_TRUE;
buffer = (kal_wchar*)j2me_midslist_mem_malloc(4 * 1024);
ucs2str_ptr = buffer;
Kread(handle, buffer, 4);
/* be carefull, scan_off will be multiplied by 2 since
buffer is unsinged short */
scan_off += 2;
/* mids_name */
temp = TRANS_INT(ucs2str_ptr);
Kread(handle, buffer + scan_off, (temp << 1) + 4);
ucs2str_ptr +=2 + temp;
scan_off += temp + 2;
/* mids_root */
temp = TRANS_INT(ucs2str_ptr);
Kread(handle, buffer + scan_off, (temp << 1) + 4);
ucs2str_ptr +=2 + temp;
scan_off += temp + 2;
/* jad url */
temp = TRANS_INT(ucs2str_ptr);
Kread(handle, buffer + scan_off, (temp << 1) + 4);
ucs2str_ptr +=2 + temp;
scan_off += temp + 2;
/* jar url */
temp = TRANS_INT(ucs2str_ptr);
Kread(handle, buffer + scan_off, (temp << 1) + 4);
ucs2str_ptr +=2 + temp;
scan_off += temp + 2;
/* webside */
temp = TRANS_INT(ucs2str_ptr);
Kread(handle, buffer + scan_off, (temp << 1) + 4);
ucs2str_ptr +=2 + temp;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -